/* Mobile PWA — loaded alongside base.css, no overrides unless inside media query */

/* Mobile menu toggle button — hidden on desktop */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* Mobile overlay — hidden on desktop */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ========================
   MOBILE: max-width 768px
   ======================== */
@media (max-width: 768px) {
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
        left: 12px;
        right: auto;
    }

    .mobile-overlay {
        display: block;
    }

    /* Layout — stack vertically */
    #app {
        flex-direction: column;
        overflow: auto;
    }

    /* Sidebar — offscreen drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        right: auto;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }
    .sidebar.open {
        left: 0;
    }

    /* Content — full width */
    .content {
        width: 100%;
        height: 100vh;
        overflow-y: auto;
    }

    /* Topbar — compact */
    .topbar {
        padding: 12px 16px;
        padding-left: 60px; /* space for menu btn */
        flex-wrap: wrap;
        gap: 8px;
    }
    .topbar h2 {
        font-size: 16px;
    }
    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }
    .topbar-actions .btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Cards — full width, smaller padding */
    .card, .glass-card {
        padding: 14px;
        border-radius: var(--radius-md);
    }

    /* Grids — single column */
    .stats-row, .ceo-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .bot-grid, .ceo-bot-grid, .missions-grid, .ceo-models-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Stat cards — compact */
    .stat-card, .ceo-stat-card {
        padding: 12px;
    }
    .stat-card .value, .ceo-stat-card .value {
        font-size: 22px;
    }

    /* Tabs — horizontal scroll */
    .ceo-tabs, .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 4px;
        padding-bottom: 4px;
    }
    .ceo-tabs::-webkit-scrollbar, .tabs::-webkit-scrollbar {
        display: none;
    }
    .ceo-tab, .tab {
        white-space: nowrap;
        font-size: 12px;
        padding: 8px 12px;
        flex-shrink: 0;
    }

    /* Tables — compact */
    .ceo-table, table {
        font-size: 12px;
    }
    .ceo-table th, .ceo-table td, table th, table td {
        padding: 6px 8px;
    }
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Chat — full screen */
    .chat-container {
        height: calc(100vh - 60px);
    }
    .chat-messages {
        padding: 10px;
    }
    .message {
        max-width: 95%;
        font-size: 14px;
        padding: 10px 12px;
    }
    .chat-input-row {
        padding: 8px 10px;
        gap: 6px;
    }
    .chat-input-row textarea {
        font-size: 15px; /* prevent iOS zoom */
        min-height: 40px;
    }

    /* Buttons — touch-friendly */
    .btn, button {
        min-height: 40px;
        font-size: 13px;
    }

    /* Forms — touch-friendly */
    input, select, textarea {
        font-size: 16px; /* prevent iOS zoom */
        min-height: 40px;
        padding: 8px 12px;
    }

    /* Modal — full width on mobile */
    .modal-content, .dialog-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 85vh;
        margin: auto;
    }

    /* Nav items — bigger touch targets */
    .nav-item {
        padding: 12px 14px;
        min-height: 44px;
    }

    /* Company tree — compact */
    .tree-node {
        padding: 8px;
    }

    /* Bot cards — compact */
    .bot-card {
        padding: 12px;
    }
    .bot-card-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Empty states */
    .empty-state {
        padding: 30px 20px;
    }
    .empty-state .icon {
        font-size: 36px;
    }

    /* Hide non-essential on mobile */
    .desktop-only {
        display: none !important;
    }

    /* Safe areas for notch phones */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Pull to refresh indicator */
    .pull-refresh-indicator {
        position: fixed;
        top: -40px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        transition: top 0.2s ease;
        z-index: 1002;
    }
    .pull-refresh-indicator.visible {
        top: 12px;
    }
}

/* ===========================
   SMALL MOBILE: max-width 380px
   =========================== */
@media (max-width: 380px) {
    .stats-row, .ceo-stats-row {
        grid-template-columns: 1fr;
    }
    .topbar h2 {
        font-size: 14px;
    }
    .sidebar {
        width: 260px;
    }
}
