/* mobile.css - Complete Refactor for Modern Mobile Devices with Light Steel Theme */
/* UPDATED v2.6: Fixed iPhone chat-log visibility and input container positioning */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --vh: 1vh;
    --header-height: 56px;
    --safe-area-inset-top: 0px;
    --safe-area-inset-bottom: 0px;
    --chat-input-height: 60px;
    --chat-gap: 70px;
    --keyboard-active: 0;
    
    /* Light Steel Theme Variables */
    --color-light-1: #f8f9fa;
    --color-light-2: #e9ecef;
    --color-light-3: #dee2e6;
    --color-medium-1: #ced4da;
    --color-medium-2: #adb5bd;
    --color-medium-3: #6c757d;
    --color-dark-1: #495057;
    --color-dark-2: #343a40;
    --color-dark-3: #212529;
    
    --color-background: #212529;
    --color-surface: #343a40;
    --color-text-primary: #f8f9fa;
    --color-text-secondary: #adb5bd;
    --color-accent: #6c757d;
    --color-border: #495057;
    --color-shadow: rgba(248, 249, 250, 0.1);
    
    /* Adjusted for dark mode */
    --color-chat-bg: #1a1a1a;
    
    /* --color-header-bg: #2c3e50; */
    --color-header-text: white;
}

/* ============================================
   DEFAULT: DESKTOP STYLES
   ============================================ */
.desktop-only {
    display: flex !important;
}

.mobile-only {
    display: none !important;
}

.mobile-nav-container {
    display: none;
}

.site-name {
    display: inline;
}

/* ============================================
   PRIMARY MOBILE DETECTION
   Multiple detection methods for maximum compatibility
   ============================================ */
@media (hover: none) and (pointer: coarse),
       (max-width: 768px),
       (-webkit-min-device-pixel-ratio: 2) and (max-width: 1024px) {
    
    /* ===== BASE RESETS ===== */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    html {
        margin: 0 !important;
        padding: 0 !important;
        height: 100%;
        overflow-x: hidden;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        padding-top: 0 !important;
        height: 100%;
        width: 100%;
        overflow-x: hidden;
        touch-action: pan-y;
        background-color: var(--color-background);
    }

    /* ===== APP CONTAINER ===== */
    .app-container {
        min-height: 100vh;
        min-height: calc(var(--vh, 1vh) * 100);
        display: flex;
        flex-direction: column;
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ===== HEADER ===== */
    .header {
        position: fixed;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000;
        height: var(--header-height);
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        /* background-color: var(--color-header-bg); */
        /* box-shadow: 0 2px 4px var(--color-shadow); */
    }

    .header-inner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 12px;
        height: var(--header-height);
        margin: 0 !important;
    }

    /* ===== SITE TITLE ===== */
    .site-title {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0;
        padding: 0;
    }

    .site-title a {
        display: flex;
        align-items: center;
        gap: 8px;
        color: var(--color-header-text);
        text-decoration: none;
        margin: 0;
        padding: 0;
    }

    .site-title i {
        font-size: 1.5rem;
        margin: 0;
        color: var(--color-header-text);
    }

    .site-name {
        display: none;
    }

    /* ===== CONTENT AREA ===== */
    .content {
        flex: 1;
        padding-top: var(--header-height) !important;
        padding-bottom: var(--safe-area-inset-bottom);
        padding-left: 8px;
        padding-right: 8px;
        margin: 0 !important;
        overflow-y: auto;
        scroll-behavior: smooth;
        overscroll-behavior-y: contain;
        width: 100%;
        background-color: var(--color-background);
    }

    /* Remove spacing from first element */
    .content > *:first-child {
        margin-top: 0 !important;
        padding-top: 12px;
    }

    /* ===== MOBILE NAVIGATION ===== */
    .mobile-nav-container {
        display: flex !important;
        align-items: center;
        gap: 12px;
        margin: 0;
    }

    .mobile-menu-toggle {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--color-header-text);
        cursor: pointer;
        padding: 0;
        margin: 0;
        font-size: 1.3rem;
    }

    .mobile-menu-toggle:active {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .mobile-menu-toggle i {
        color: var(--color-header-text);
    }

    /* ===== MOBILE DROPDOWN MENU ===== */
    .mobile-dropdown {
        position: fixed;
        top: var(--header-height) !important;
        right: 0;
        width: min(280px, 80vw);
        max-width: 90vw;
        background: #34495e;
        box-shadow: -2px 4px 12px var(--color-shadow);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        margin: 0 !important;
    }

    .mobile-dropdown.show {
        transform: translateX(0);
    }

    .mobile-dropdown-header {
        padding: 16px;
        background: var(--color-header-bg);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-weight: 600;
        color: var(--color-header-text);
        margin: 0;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-dropdown-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px;
        color: #ecf0f1;
        text-decoration: none;
        border: none;
        background: none;
        width: 100%;
        text-align: left;
        font-size: 16px;
        transition: background-color 0.2s;
        cursor: pointer;
        font-family: inherit;
        margin: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .mobile-dropdown-item:active {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .mobile-dropdown-item i {
        width: 20px;
        text-align: center;
        color: #ecf0f1;
    }

    .mobile-dropdown-form {
        margin: 0;
        width: 100%;
    }

    .logout-item {
        border-top: 2px solid rgba(255, 255, 255, 0.1);
        color: #ff6b6b;
        margin-top: 8px;
    }

    .logout-item i {
        color: #ff6b6b;
    }

    /* ===== MOBILE DROPDOWN OVERLAY ===== */
    .mobile-dropdown-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-dropdown-overlay.show {
        display: block;
        opacity: 1;
    }

    /* ===== NOTIFICATION INDICATOR ===== */
    .notification-icon {
        position: relative;
        color: var(--color-header-text);
        font-size: 1.2rem;
        cursor: pointer;
        padding: 8px;
        border-radius: 50%;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
    }

    .notification-icon i {
        color: var(--color-header-text);
    }

    .notification-icon:active {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .notification-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        background-color: #e74c3c;
        color: white;
        border-radius: 50%;
        width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.65rem;
        font-weight: bold;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    /* ===== DESKTOP NAVIGATION HIDING ===== */
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }

    /* ===== ROOM CARDS ===== */
    .rooms-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0;
        margin: 0 !important;
    }

    .room-card {
        background-color: var(--color-surface);
        border-radius: 8px;
        padding: 16px;
        box-shadow: 0 1px 3px var(--color-shadow);
        margin: 0;
    }

    .room-card h3 {
        font-size: 1.1rem;
        margin-bottom: 8px;
        color: var(--color-text-primary);
    }

    .room-info {
        font-size: 0.85rem;
        color: var(--color-text-secondary);
    }

    .created-at,
    .created-by {
        color: var(--color-text-secondary);
    }

    /* ===== ROOM HEADER ===== */
    .room-header {
        background-color: var(--color-surface);
        padding: 12px;
        border-radius: 8px;
        margin: 0 !important;
        margin-bottom: 12px !important;
        box-shadow: 0 1px 3px var(--color-shadow);
    }

    .room-header h3 {
        font-size: 1.1rem;
        margin: 0 0 8px 0;
        color: var(--color-text-primary);
    }

    .room-meta {
        font-size: 0.85rem;
        gap: 8px;
        color: var(--color-text-secondary);
    }

    .room-actions {
        margin-top: 8px;
        gap: 8px;
    }

    .room-actions .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* ===== SECTION TITLE ===== */
    .section-title {
        font-size: 1.3rem;
        margin: 12px 0 !important;
        padding: 0 4px;
        color: var(--color-text-primary);
    }

    .section-title .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* ===== NO ROOMS MESSAGE ===== */
    .no-rooms-message {
        padding: 2rem 1rem;
        background-color: var(--color-surface);
        color: var(--color-text-secondary);
        box-shadow: 0 1px 3px var(--color-shadow);
    }

    .no-rooms-message i {
        font-size: 2.5rem;
        color: var(--color-accent);
    }

    /* ===== FILTER SECTION ===== */
    .filter-section {
        background-color: var(--color-surface);
        padding: 12px;
        border-radius: 8px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px var(--color-shadow);
    }

    .filter-section h3 {
        font-size: 1rem;
        margin-bottom: 12px;
        color: var(--color-text-primary);
    }

    .filter-input-group {
        flex-direction: column;
        gap: 8px;
    }

    .filter-input,
    .filter-select {
        width: 100%;
        padding: 10px;
        font-size: 16px;
        border: 1px solid var(--color-border);
        border-radius: 8px;
        background-color: white;
        color: var(--color-text-primary);
    }

    .filter-btn,
    .clear-btn {
        width: 100%;
        padding: 10px;
        font-size: 16px;
        border-radius: 8px;
    }

    /* ===== CHAT CONTAINER ===== */
    .chat-container {
        position: relative;
        display: flex;
        flex-direction: column;
        height: calc(100vh - var(--header-height));
        height: calc(var(--vh, 1vh) * 100 - var(--header-height));
        overflow: hidden;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ===== CHAT LOG ===== */
    #chat-log {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        background-color: #e5ddd5;
        padding: 12px 8px;
        padding-bottom: calc(var(--chat-input-height) + var(--chat-gap)) !important;
        margin: 0 !important;
        width: 100%;
        scroll-behavior: smooth;
        position: relative;
        overscroll-behavior: contain;
    }

    /* ===== MESSAGE BUBBLES ===== */
    .message-row {
        max-width: 85%;
        margin-bottom: 8px;
    }

    .message-bubble {
        padding: 10px 12px;
        border-radius: 16px;
        font-size: 0.95rem;
    }

    .timestamp {
        font-size: 0.65rem;
    }

    .username {
        font-size: 0.8rem;
    }

    /* ===== CHAT INPUT CONTAINER ===== */
    .chat-input-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0;
        right: 0;
        z-index: 1001;
        background-color: #f0f0f0;
        padding: 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 10px var(--color-shadow);
        display: flex;
        gap: 8px;
        align-items: flex-end;
        margin: 0 !important;
        border-radius: 0;
    }

    #chat-message-input {
        flex: 1;
        min-height: 44px;
        max-height: 120px;
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 22px;
        border: none;
        background-color: white;
        resize: none;
        overflow-y: auto;
    }

    #chat-message-input:focus {
        outline: none;
        box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
    }

    #chat-message-submit {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        border-radius: 50%;
        background-color: #0d6efd;
        color: white;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    #chat-message-submit:active {
        background-color: #0b5ed7;
        transform: scale(0.95);
    }

    #chat-message-submit i {
        font-size: 1.1rem;
    }

    /* ===== AUTHENTICATION FORMS ===== */
    .auth-container {
        margin: 1rem;
        padding: 1.5rem;
        background-color: var(--color-surface);
        box-shadow: 0 1px 3px var(--color-shadow);
    }

    .auth-container h2 {
        font-size: 1.3rem;
        color: var(--color-text-primary);
    }

    .form-control {
        padding: 12px;
        font-size: 16px;
        border: 1px solid var(--color-border);
        background-color: white;
        color: var(--color-text-primary);
    }

    .help-text {
        font-size: 0.8rem;
        color: var(--color-text-secondary);
    }

    /* ===== MODALS ===== */
    .modal-content,
    .encryption-modal-content {
        width: 95%;
        max-width: 95%;
        margin: 0 auto;
        background-color: var(--color-surface);
    }

    .modal-header h3,
    .encryption-modal-header h3 {
        font-size: 1.1rem;
        color: var(--color-text-primary);
    }

    .modal-body,
    .encryption-modal-body {
        padding: 16px;
        font-size: 0.95rem;
        color: var(--color-text-primary);
    }

    .modal-footer,
    .encryption-modal-footer {
        padding: 12px 16px;
        gap: 8px;
    }

    .modal-footer .btn,
    .encryption-modal-footer .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    /* ===== KEY DISPLAY ===== */
    .key-display {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        background-color: var(--color-surface);
        border: 1px solid var(--color-border);
    }

    .key-text {
        font-size: 0.8rem;
        padding: 8px;
        background-color: white;
        color: var(--color-text-primary);
        border: 1px solid var(--color-border);
    }

    .key-btn {
        width: 100%;
        justify-content: center;
        padding: 10px;
        font-size: 0.9rem;
        background-color: white;
        color: var(--color-text-primary);
        border: 1px solid var(--color-border);
    }

    /* ===== ADMIN PANEL ===== */
    .admin-panel {
        padding: 0;
        gap: 12px;
    }

    .admin-section {
        background-color: var(--color-surface);
        padding: 12px;
        box-shadow: 0 1px 3px var(--color-shadow);
    }

    .admin-section h2 {
        font-size: 1.2rem;
        color: var(--color-text-primary);
        border-bottom: 1px solid var(--color-border);
    }

    .admin-controls {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .admin-table {
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px;
        border-bottom: 1px solid var(--color-border);
        color: var(--color-text-primary);
    }

    .admin-table th {
        background-color: var(--color-light-1);
    }
}

/* ============================================
   iOS-SPECIFIC FIXES (iPhone, iPad)
   ============================================ */
@supports (-webkit-touch-callout: none) {
    @media (hover: none) and (pointer: coarse) {
        
        /* Fix 1: Prevent body scroll */
        html, body {
            position: fixed;
            overflow: hidden;
            width: 100%;
            height: 100%;
        }
        
        /* Fix 2: Chat container takes full viewport */
        .chat-container {
            position: fixed;
            top: var(--header-height);
            left: 0;
            right: 0;
            bottom: 0;
            height: auto !important;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        /* Fix 3: Chat log must be scrollable */
        #chat-log {
            flex: 1;
            overflow-y: scroll !important;
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
            padding-bottom: calc(var(--chat-input-height) + var(--chat-gap) + 5px) !important;
        }
        
        /* Fix 4: Input container stays at bottom */
        .chat-input-container {
            position: fixed !important;
            bottom: 0 !important;
            left: 0 !important;
            right: 0 !important;
            z-index: 1001 !important;
            flex-shrink: 0;
        }
        
        /* Fix 5: Notch support */
        .header {
            padding-top: env(safe-area-inset-top, 0);
            height: calc(var(--header-height) + env(safe-area-inset-top, 0));
        }
        
        .chat-container {
            top: calc(var(--header-height) + env(safe-area-inset-top, 0));
        }
        
        .chat-input-container {
            padding-bottom: calc(8px + env(safe-area-inset-bottom, 0)) !important;
        }
        
        /* Fix 6: Prevent zoom on input focus */
        #chat-message-input {
            font-size: 16px !important;
        }
        
        /* Fix 7: Ensure proper stacking */
        .content {
            position: relative;
            z-index: 1;
        }
        
        .header {
            position: fixed;
            z-index: 1000;
        }
        
        .chat-input-container {
            z-index: 1001 !important;
        }
        
        .mobile-dropdown {
            z-index: 999;
        }
        
        .mobile-dropdown-overlay {
            z-index: 998;
        }
        
        /* Fix 8: Body class for keyboard state tracking */
        body.ios-keyboard-open .chat-container {
            bottom: 0;
        }
        
        body.ios-keyboard-open #chat-log {
            padding-bottom: 20px !important;
        }
        
        body.ios-keyboard-open .chat-input-container {
            position: fixed !important;
            bottom: 0 !important;
        }
        
        /* Fix 9: Visual Viewport API support */
        @supports (height: 100dvh) {
            .chat-container {
                height: 100dvh;
                top: 0;
                padding-top: calc(56px + env(safe-area-inset-top, 0px));
            }
        }
        
        /* Fix 10: Prevent body scroll/bounce */
        body {
            position: fixed;
            overflow: hidden;
            width: 100%;
        }
        
        /* Allow only chat log to scroll */
        #chat-log {
            touch-action: pan-y;
        }
        
        /* Prevent pull-to-refresh in chat */
        .chat-container {
            overscroll-behavior: contain;
            -webkit-overscroll-behavior: contain;
        }
    }
}

/* ============================================
   KEYBOARD DETECTION FIX
   ============================================ */
@supports (-webkit-touch-callout: none) {
    @media (max-height: 500px) {
        #chat-log {
            padding-bottom: 20px !important;
        }
        
        .chat-input-container {
            position: fixed !important;
            bottom: 0 !important;
        }
    }
}

/* ============================================
   NOTCH SUPPORT (iPhone X and newer)
   ============================================ */
@supports (-webkit-touch-callout: none) and (env(safe-area-inset-top)) {
    .header {
        padding-top: env(safe-area-inset-top) !important;
        height: calc(56px + env(safe-area-inset-top)) !important;
    }
    
    .chat-container {
        top: calc(56px + env(safe-area-inset-top));
    }
    
    .chat-input-container {
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
}

/* ============================================
   INPUT FOCUS FIX
   ============================================ */
@supports (-webkit-touch-callout: none) {
    #chat-message-input:focus {
        font-size: 16px !important;
        transform: translateZ(0);
    }
}

/* ============================================
   BROWSER VS PWA SPECIFIC ADJUSTMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse),
       (max-width: 768px) {
    
    body.in-browser .chat-container {
        height: calc(var(--actual-viewport-height, 100vh));
    }
    
    body.in-browser #chat-log {
        padding-bottom: calc(var(--chat-input-height) + var(--chat-gap) + 4px) !important;
    }
    
    body.pwa-standalone .chat-container {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    body.pwa-standalone #chat-log {
        padding-bottom: calc(var(--chat-input-height) + var(--chat-gap) + 3px) !important;
    }
    
    body.in-browser .room-header ~ #chat-log {
        height: calc(var(--actual-viewport-height, 100vh) - var(--header-height) - var(--room-header-height, 0px));
    }
    
    body.in-browser .chat-input-container {
        bottom: 0 !important;
        bottom: env(safe-area-inset-bottom, 0) !important;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   DARK MODE SUPPORT (Light Steel Dark Theme)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --color-background: #212529;
        --color-surface: #343a40;
        --color-text-primary: #f8f9fa;
        --color-text-secondary: #adb5bd;
        --color-accent: #6c757d;
        --color-border: #495057;
        --color-shadow: rgba(248, 249, 250, 0.1);
        --color-chat-bg: #1a1a1a;
    }
    
    @media (hover: none) and (pointer: coarse) {
        body {
            background-color: var(--color-background);
            color: var(--color-text-primary);
        }
        
        .content {
            background-color: var(--color-background);
        }
        
        .room-card {
            background-color: var(--color-surface);
            color: var(--color-text-primary);
        }
        
        .room-card h3 {
            color: var(--color-text-primary) !important;
        }
        
        .created-at,
        .created-by {
            color: var(--color-text-secondary) !important;
        }
        
        .modal-content,
        .encryption-modal-content {
            background-color: var(--color-surface);
            color: var(--color-text-primary);
        }
        
        #chat-log {
            background-color: var(--color-chat-bg);
        }
        
        .own-message .message-bubble {
            background-color: #dcf8c6;
        }
        
        .own-message .message-content {
            color: #1a1a1a !important;
        }
        
        .other-message .message-bubble {
            background-color: #ffffff;
        }
        
        .other-message .message-content {
            color: #1a1a1a !important;
        }
        
        #chat-message-input {
            background-color: white;
            color: #1a1a1a !important;
        }
        
        input, textarea, select {
            background-color: #333;
            color: var(--color-text-primary);
            border-color: var(--color-border);
        }

        .chat-input-container {
            background-color: var(--color-surface);
        }
        
        .section-title {
            color: var(--color-text-primary);
        }
        
        .room-header {
            background-color: var(--color-surface);
        }
        
        .room-header h3 {
            color: var(--color-text-primary) !important;
        }
        
        .no-rooms-message {
            background-color: var(--color-surface);
            color: var(--color-text-secondary);
        }
        
        .filter-section {
            background-color: var(--color-surface);
        }
        
        .filter-input,
        .filter-select {
            background-color: #333;
            color: var(--color-text-primary);
            border-color: var(--color-border);
        }
        
        .auth-container {
            background-color: var(--color-surface);
        }
        
        .form-control {
            background-color: #333;
            color: var(--color-text-primary);
            border-color: var(--color-border);
        }
        
        .admin-section {
            background-color: var(--color-surface);
        }
        
        .admin-table th {
            background-color: var(--color-dark-2);
        }
    }
}

/* ============================================
   PWA STANDALONE MODE
   ============================================ */
@media (display-mode: standalone) {
    :root {
        --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
    }
    
    .header {
        padding-top: 0 !important;
    }
    
    #chat-log {
        padding-bottom: calc(var(--chat-input-height) + var(--chat-gap)) !important;
    }
    
    .chat-input-container {
        position: fixed !important;
        bottom: 0 !important;
        bottom: env(safe-area-inset-bottom, 0) !important;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    #chat-log::-webkit-scrollbar {
        width: 4px;
    }

    #chat-log::-webkit-scrollbar-track {
        background: transparent;
    }

    #chat-log::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }

    .mobile-dropdown::-webkit-scrollbar {
        width: 4px;
    }

    .mobile-dropdown::-webkit-scrollbar-track {
        background: transparent;
    }

    .mobile-dropdown::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.touchable {
    touch-action: manipulation;
}

.scrollable {
    overflow-y: auto;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}