/* Mobile-first responsive design for HintBid */

/* Mobile Device Styles */
.mobile-device {
    font-size: 16px; /* Prevent zoom on iOS */
}

/* Simple mobile viewport fix */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
}

/* Force mobile layout for small screens */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    /* Scoped layout overrides for specific components */
    .main-layout-container {
        flex-direction: column !important;
    }
    
    .app-main {
        flex: 1 !important;
    }
    
    /* Mobile main content */
    .main-content-wrapper {
        flex: 1 !important;
        width: 100% !important;
        overflow: visible !important;
    }
}

/* Enhanced Mobile Sidebar */
@media (max-width: 768px) {
    /* Force sidebar to be hidden by default on mobile */
    .sidebar-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        z-index: 1000 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        background: #f9fafb !important;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3) !important;
    }
    
    .sidebar-container.sidebar-open {
        transform: translateX(0) !important;
    }
    
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    
    /* Mobile Navigation Improvements */
    .sidebar-container a {
        padding: 16px 20px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        margin: 4px 12px !important;
        color: #374151 !important;
        background: transparent !important;
    }
    
    .sidebar-container a:hover {
        background: #e5e7eb !important;
    }
    
    .sidebar-container i {
        font-size: 18px !important;
        width: 24px !important;
        color: #6b7280 !important;
    }
    
    /* Mobile Header Button */
    #sidebarToggle {
        background: rgba(255, 255, 255, 0.9) !important;
        border-radius: 8px !important;
        padding: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        color: #374151 !important;
        border: none !important;
        position: fixed !important;
        top: 16px !important;
        left: 16px !important;
        z-index: 1001 !important;
    }
}

/* Mobile Chat Interface */
@media (max-width: 768px) {
    /* Mobile Typography */
    .headline {
        font-size: 1.5rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.8rem !important;
        padding: 0 16px !important;
    }
    
    .typing-text {
        font-size: 0.9rem !important;
        margin-bottom: 0.6rem !important;
        padding: 0 16px !important;
    }
    
    /* Mobile Container Spacing */
    .max-w-4xl,
    .max-w-7xl {
        max-width: 100% !important;
        padding: 0 12px !important;
        margin: 0 !important;
    }
    
    .container {
        padding: 12px !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    
    /* Service Type Selector */
    #serviceTypeSelector {
        margin-bottom: 0.8rem !important;
        padding: 0 16px !important;
    }
    
    #serviceType {
        font-size: 14px !important;
        padding: 10px 12px !important;
        border-radius: 6px !important;
        border: 1px solid #e0e0e0 !important;
        background-color: #fff !important;
        width: 100% !important;
        color: #333 !important;
        box-sizing: border-box !important;
    }
    
    /* Chat Input */
    .message-input,
    #userInput {
        font-size: 14px !important;
        padding: 10px 50px 10px 12px !important;
        border-radius: 8px !important;
        border: 1px solid #e0e0e0 !important;
        min-height: 40px !important;
        max-height: 80px !important;
        background-color: #fff !important;
        color: #333 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        resize: none !important;
        overflow-y: auto !important;
    }
    
    .input-container {
        width: 100% !important;
        padding: 12px 16px !important;
        background-color: #fff !important;
        position: fixed !important;
        bottom: 40px !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        border-top: 1px solid #e0e0e0 !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
    }
    
    .send-button {
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        padding: 6px !important;
        background: none !important;
        border: none !important;
        color: #007AFF !important;
        min-height: auto !important;
        margin: 0 !important;
    }
    
    .send-button i {
        font-size: 20px !important;
    }
    
    /* Mobile Chat Messages */
    .chat-message,
    .message {
        margin-bottom: 8px !important;
        max-width: 80% !important;
        clear: both !important;
        display: block !important;
    }
    
    .message-bubble,
    .message-content,
    .message.bot {
        padding: 8px 12px !important;
        font-size: 12px !important;
        line-height: 1.3 !important;
        border-radius: 12px !important;
        word-wrap: break-word !important;
        display: inline-block !important;
        max-width: 100% !important;
    }
    
    .user-message {
        text-align: right !important;
    }
    
    .user-message .message-bubble,
    .user .message-content {
        border-bottom-right-radius: 4px !important;
        background-color: #007AFF !important;
        color: white !important;
        margin-left: auto !important;
    }
    
    .ai-message {
        text-align: left !important;
    }
    
    .ai-message .message-bubble,
    .bot .message-content,
    .message.bot {
        border-bottom-left-radius: 4px !important;
        background-color: #f1f1f1 !important;
        color: #333 !important;
        margin-right: auto !important;
    }
    
    /* Chat Window */
    #chatWindow {
        background-color: #fff !important;
        padding: 8px 16px 8px 16px !important;
        border: none !important;
        max-height: calc(100vh - 200px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
        margin-bottom: 80px !important;
        transition: all 0.3s ease !important;
        flex: 1 !important;
    }
    
    /* Selected Service Display */
    .selected-service {
        background-color: #f8f9fa !important;
        padding: 8px 12px !important;
        margin: 8px 16px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
        text-align: center !important;
    }
}

/* Touch-friendly buttons and form elements */
@media (max-width: 768px) {
    button,
    .btn,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px !important;
        padding: 12px 20px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        touch-action: manipulation !important;
        background-color: #007AFF !important;
        color: #fff !important;
        border: none !important;
        margin: 8px 0 !important;
    }
    
    .form-select,
    select,
    .form-control {
        min-height: 44px !important;
        font-size: 16px !important;
        padding: 12px 16px !important;
        border: 2px solid #e0e0e0 !important;
        border-radius: 8px !important;
        background-color: #fff !important;
        color: #333 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea {
        min-height: 44px !important;
        font-size: 16px !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        border: 2px solid #e0e0e0 !important;
        background-color: #fff !important;
        color: #333 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Fix specific button styles */
    .bg-blue-600,
    .bg-blue-700 {
        background-color: #007AFF !important;
    }
    
    .text-blue-600 {
        color: #007AFF !important;
    }
}

/* Mobile-specific layout improvements */
@media (max-width: 768px) {
    /* Main Content Layout */
    .main-content-wrapper {
        padding: 60px 16px 20px 16px !important;
        width: 100% !important;
        margin: 0 !important;
        background-color: #fff !important;
        flex: 1 !important;
    }
    
    /* All containers should be full width on mobile */
    .container,
    .max-w-4xl,
    .max-w-7xl,
    .mx-auto {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 16px !important;
        margin: 0 !important;
    }
    
    /* Ensure proper mobile layout for app structure */
    .app-main {
        min-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .chat-container-wrapper {
        margin-bottom: 20px !important;
        padding: 16px !important;
        border-radius: 12px !important;
        background-color: #fff !important;
    }
    
    .chat-container {
        background-color: #fff !important;
        border: none !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Mobile page sections */
    .pt-8,
    .py-4,
    .py-12 {
        padding-top: 16px !important;
        padding-bottom: 16px !important;
    }
    
    .mb-16,
    .mt-16,
    .mb-20,
    .mt-8 {
        margin-top: 16px !important;
        margin-bottom: 16px !important;
    }
    
    /* Mobile FAQ improvements */
    .space-y-4 > div {
        border-radius: 12px !important;
        margin-bottom: 12px !important;
    }
    
    .space-y-4 button {
        padding: 16px !important;
        font-size: 16px !important;
        text-align: left !important;
    }
    
    /* Mobile form improvements */
    .form-group,
    .mb-3 {
        margin-bottom: 20px !important;
    }
    
    label,
    .form-label {
        font-size: 16px !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
        display: block !important;
        color: #333 !important;
    }
    
    /* Mobile cards and sections */
    .bg-white,
    .card {
        background-color: #fff !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important;
    }
    
    .card-body {
        padding: 16px !important;
    }
    
    /* Mobile grid layouts */
    .md\\:flex {
        flex-direction: column !important;
    }
    
    .md\\:w-1\\/2 {
        width: 100% !important;
    }
    
    /* Service provider features */
    .bg-blue-600 {
        padding: 20px 16px !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    .p-8 {
        padding: 16px !important;
    }
}

/* Tablet-specific styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .tablet-device .sidebar-container {
        width: 280px;
    }
    
    .tablet-device .main-content-wrapper {
        padding: 24px 20px;
    }
    
    .tablet-device .headline {
        font-size: 3.5rem;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .message-input,
    #userInput {
        transform: translateZ(0) !important;
        -webkit-appearance: none !important;
        border-radius: 8px !important;
    }
    
    .input-container {
        /* Fix for iOS Safari viewport issues */
        bottom: env(safe-area-inset-bottom, 0) !important;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0)) !important;
    }
    
    #chatWindow.keyboard-open {
        padding-bottom: calc(160px + env(safe-area-inset-bottom, 0)) !important;
        height: calc(100vh - 350px - env(safe-area-inset-bottom, 0)) !important;
    }
}

/* Mobile keyboard and viewport fixes */
@media (max-width: 768px) {
    /* Prevent automatic zoom on iOS */
    input, textarea, select {
        font-size: 16px !important;
        transform: translateZ(0);
    }
    
    /* Container positioning */
    .container, .max-w-4xl {
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* When keyboard is open, lock scroll */
    body.keyboard-open {
        position: fixed !important;
        overflow: hidden !important;
        width: 100% !important;
        height: 100% !important;
    }
}

/* High DPI display improvements */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mobile-device .sidebar-container {
        border-right: 0.5px solid #e0e0e0;
    }
    
    .mobile-device .message-bubble {
        border: 0.5px solid rgba(0, 0, 0, 0.1);
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    .mobile-device {
        background-color: #000;
        color: #fff;
    }
    
    .mobile-device .sidebar-container {
        background-color: #1c1c1e;
        border-right-color: #38383a;
    }
    
    .mobile-device .message-input {
        background-color: #1c1c1e;
        border-color: #38383a;
        color: #fff;
    }
    
    .mobile-device .ai-message .message-bubble {
        background-color: #1c1c1e;
        color: #fff;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    .mobile-device *:focus {
        outline: 2px solid #007AFF;
        outline-offset: 2px;
    }
    
    .mobile-device button:focus,
    .mobile-device a:focus {
        transform: scale(1.05);
        transition: transform 0.1s ease;
    }
    
    /* Larger touch targets for accessibility */
    .mobile-device .touch-target {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Performance optimizations for mobile */
.mobile-device * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-device input,
.mobile-device textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Smooth scrolling for mobile */
.mobile-device {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.mobile-device #chatWindow {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}