/* Mobile-specific styles */
.hamburger-menu {
    display: block;
    background-color: transparent;
    border: none;
    padding: 10px;
    cursor: pointer;
    position: relative;
    z-index: 1001;
    color: #333;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* Smaller hamburger menu when active (X state) */
.hamburger-menu.active {
    padding: 8px;
    width: 30px;
    height: 30px;
}

/* Sidebar toggle button (hidden on mobile) */
.sidebar-toggle {
    display: block;
}

.hamburger-menu span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 5px 0;
    background-color: #333;
    transition: all 0.3s ease;
}

/* Mobile styles (max-width: 768px) */
@media (max-width: 768px) {
    /* Hamburger menu is now part of mobile header */
    
    /* Hide sidebar toggle on mobile */
    .sidebar-toggle {
        display: none;
    }

    .sidebar {
        position: fixed;
        left: -280px; /* Start off-screen - match the new width */
        top: 56px; /* Below mobile header */
        bottom: 0;
        width: 280px; /* Match the updated sidebar width */
        background-color: #f5f5f7;
        transition: left 0.3s ease;
        z-index: 1100;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    .sidebar.active {
        left: 0;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
    }

    /* Overlay when menu is open */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .menu-overlay.active {
        display: block;
    }

    /* Adjust main content for mobile */
    .main-content {
        margin-left: 0;
        width: 100%;
        overflow-x: hidden;
    }
    .chat-container {
        overflow-x: hidden;
    }

    /* Model selector styles moved to model-selector.css */
    
    /* Ensure chat messages don't get hidden */
    .chat-messages {
        padding-top: 1rem; /* Space below fixed header */
    }
    
    /* Make sources more compact on mobile */
    .sources-list {
        grid-template-columns: 1fr; /* Single column on mobile */
    }
    
    /* Adjust message buttons for mobile */
    .message-buttons {
        flex-direction: column;
        gap: 0.35rem;
        align-items: flex-start;
        margin-top: 0.5rem;
        width: 100%;
        display: flex;
    }
    
    .refresh-button, .sources-button {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
        margin-bottom: 0.25rem;
        display: inline-flex;
        align-items: center;
    }
    
    /* Reduce padding in messages for mobile */
    .message {
        padding: 0.75rem 0;
        min-height: 3rem;
        overflow: visible;
    }
    
    .message-content {
        gap: 0.5rem;
        overflow: visible;
        padding: 0 0.5rem;
    }
    
    /* Ensure message text container expands properly */
    .message-text {
        min-height: 2.5rem;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }

    /* Custom icon animation when menu is open */
    .hamburger-menu.active .hamburger-icon {
        transform: rotate(180deg);
    }
    

    /* Touch target and spacing improvements */
    .send-button,
    .thinking-toggle,
    .photo-upload-button {
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
        touch-action: manipulation;
    }
    .sidebar-action-btn {
        min-height: 48px;
        font-size: 1.1rem;
        padding: 0.75rem 1rem;
    }
    .selector-icon {
        min-width: 120px;
        min-height: 44px; /* Ensure proper touch target */
        font-size: 0.95rem;
        padding: 0.75rem 0.5rem;
    }
    .input-wrapper {
        gap: 0.5rem; /* Reduce gap for more input space */
    }
    
    /* Improve chat input on mobile */
    .chat-input {
        font-size: 16px !important; /* Prevent iOS zoom */
        min-height: 44px;
    }
    
    /* Fix refresh and sources buttons */
    .refresh-button, .sources-button {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
        min-height: 36px;
        min-width: 80px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .selectors-container {
        flex-direction: row; /* Keep horizontal on small screens */
        gap: 0.5rem;
        padding: 0.5rem 0.5rem 0.25rem 0.5rem;
        min-height: 48px;
        flex-wrap: wrap; /* Allow wrapping if needed */
    }
    .selector-icon {
        min-width: 100px;
        min-height: 44px;
        font-size: 0.9rem;
        padding: 0.5rem 0.4rem;
        flex: 1; /* Allow flexible width */
    }
    .send-button,
    .thinking-toggle,
    .photo-upload-button {
        min-width: 44px;
        min-height: 44px;
        font-size: 0.95rem;
    }
    .input-wrapper {
        gap: 0.5rem;
    }
    
    /* Hide avatars on very small screens to save space */
    .avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }
}

/* Very small devices */
@media (max-width: 375px) {
    .selectors-container {
        gap: 0.5rem;
        padding: 0.25rem 0.25rem 0.1rem 0.25rem;
        min-height: 44px; /* Keep minimum touch target */
    }
    .selector-icon {
        min-width: 80px;
        min-height: 44px; /* Maintain touch target */
        font-size: 0.85rem;
        padding: 0.5rem 0.3rem;
    }
    .send-button,
    .thinking-toggle,
    .photo-upload-button {
        min-width: 44px; /* Keep 44px minimum */
        min-height: 44px;
        font-size: 0.9rem;
    }
    .input-wrapper {
        gap: 0.25rem;
    }
    
    /* Optimize message display for very small screens */
    .message-content {
        padding: 0 0.25rem;
    }
    
    /* Hide thinking toggle on very small screens to save space */
    .thinking-toggle {
        display: none;
    }
}

/* --- Amari: Gentle logout button spacing and touch feedback --- */
@media (max-width: 768px) {
    .sidebar-action-btn.logout-btn {
        margin-top: 1.25rem !important;
        background: #f8e9e9;
        color: #b23a48;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(178,58,72,0.06);
        transition: background 0.2s, box-shadow 0.2s;
    }
    .sidebar-action-btn.logout-btn:hover,
    .sidebar-action-btn.logout-btn:focus {
        background: #ffeaea;
        color: #a12a38;
        box-shadow: 0 4px 16px rgba(178,58,72,0.12);
    }
}

/* --- Amari: Sidebar and main content breathing room for mobile --- */
@media (max-width: 768px) {
    .sidebar {
        padding-top: 2.5rem;
        padding-bottom: 2rem;
    }
    .sidebar-actions {
        display: flex;
        flex-direction: column;
        gap: 1.1rem;
        margin-top: 2.5rem;
    }
    .main-content {
        padding-top: 1.2rem;
        padding-bottom: 5rem; /* Space for bottom navbar */
    }
    .chat-messages {
        padding-top: 1.2rem !important;
        padding-bottom: 5rem !important; /* Space for bottom navbar */
    }
}

/* --- Mobile Bottom Navbar --- */
.mobile-bottom-navbar {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-navbar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0.75rem 0;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
        z-index: 1000;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }
    
    .navbar-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 0.25rem;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.7);
        transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        text-decoration: none;
        min-height: 48px;
        border-radius: 12px;
        margin: 0 0.25rem;
        position: relative;
        overflow: hidden;
    }
    
    .navbar-item::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0);
        border-radius: 12px;
        transition: all 0.3s ease;
        z-index: -1;
    }
    
    .navbar-item:hover::before,
    .navbar-item:focus::before {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .navbar-item.active::before {
        background: rgba(255, 255, 255, 0.2);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    }
    
    .navbar-item svg {
        width: 24px;
        height: 24px;
        margin-bottom: 0.25rem;
        transition: all 0.3s ease;
        stroke-width: 1.5;
    }
    
    .navbar-item span {
        font-size: 0.75rem;
        font-weight: 500;
        text-align: center;
        line-height: 1;
        white-space: nowrap;
        transition: all 0.3s ease;
    }
    
    .navbar-item:hover,
    .navbar-item:focus {
        color: rgba(255, 255, 255, 0.9);
        transform: translateY(-2px);
    }
    
    .navbar-item.active {
        color: #ffffff;
        transform: translateY(-2px);
    }
    
    .navbar-item.active svg {
        stroke-width: 2;
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
    }
    
    .navbar-item.active span {
        font-weight: 600;
        text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    }
    
    /* Keep hamburger menu visible in header */
    
    /* Hide sidebar on mobile with bottom navbar when not active */
    .sidebar:not(.active) {
        display: flex;
        left: -280px;
    }
    
    
    /* Ensure input container has proper spacing */
    .chat-input-container {
        margin-bottom: 0;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    }
}
