/* ═══════════════════════════════════════
   SLATE — Responsive Layout
   Loaded LAST — overrides all other CSS
═══════════════════════════════════════ */

/* ── Mobile Top Bar ── */
.mobile-topbar {
    display: none; /* Shown by media query */
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 16px;
    background: var(--s1);
    border-bottom: 1px solid var(--b1);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}
.mobile-topbar-hamburger,
.mobile-topbar-action {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm, 6px);
    border: none;
    background: none;
    color: var(--tx);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.mobile-topbar-hamburger:hover,
.mobile-topbar-action:hover {
    background: var(--s3);
}
.mobile-topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--tx);
}

/* ── Bottom Navigation ── */
.mobile-bottom-nav {
    display: none; /* Shown by media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--s1);
    border-top: 1px solid var(--b1);
    z-index: 400;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
    /* Safe area for notched phones */
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.mob-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    border: none;
    background: none;
    color: var(--t3);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
    transition: color 0.15s;
}
.mob-nav-item.active {
    color: var(--accent, #6366f1);
}
.mob-nav-item:hover {
    color: var(--tx);
}
.mob-nav-item svg {
    width: 22px;
    height: 22px;
}

/* ── Hamburger in topbar (tablet) ── */
.topbar-hamburger {
    display: none; /* Shown by media query */
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm, 6px);
    border: none;
    background: none;
    color: var(--tx);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 8px;
}
.topbar-hamburger:hover {
    background: var(--s3);
}

/* ═══════════════════════════════════════
   TABLET: 768px – 1024px
   Sidebar collapses, hamburger appears
═══════════════════════════════════════ */
@media (max-width: 1024px) {
    /* Hide the icon rail */
    #icon-rail {
        display: none !important;
    }

    /* Sidebar becomes an overlay, hidden by default */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 500;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }
    #sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    /* Overlay backdrop when sidebar is open */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 499;
    }
    .sidebar-backdrop.active {
        display: block;
    }

    /* Show hamburger button in topbar */
    .topbar-hamburger {
        display: flex !important;
    }

    /* Main area takes full width */
    #mainArea {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Right panel becomes overlay */
    #right-panel {
        position: fixed !important;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 400px;
        z-index: 500;
        box-shadow: -4px 0 24px rgba(0,0,0,0.3);
    }

    /* Topbar adjustments */
    .topbar-chips {
        display: none;
    }

    /* Kanban board scrolls horizontally */
    .kanban-wrap {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 16px;
    }
    .k-col {
        min-width: 280px;
        flex-shrink: 0;
    }

    /* Editor 2-column becomes 1-column */
    .ed-2col {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════
   MOBILE: < 768px
   Single column, bottom nav bar
═══════════════════════════════════════ */
@media (max-width: 767px) {
    /* Hide icon rail */
    #icon-rail {
        display: none !important;
    }

    /* Sidebar: slide-in overlay */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85vw;
        max-width: 320px;
        z-index: 500;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    #sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    /* Hide desktop topbar */
    .topbar {
        display: none !important;
    }

    /* Show mobile top bar */
    .mobile-topbar {
        display: flex !important;
    }

    /* Show bottom navigation */
    .mobile-bottom-nav {
        display: flex !important;
    }

    /* Main area full width, account for bottom nav */
    #mainArea {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: 64px;
    }

    /* Hero header compact */
    .cc-hero {
        padding: 16px 16px 0 !important;
    }
    .cc-hero-title {
        font-size: 20px !important;
    }
    .cc-sparkline {
        display: none !important;
    }

    /* Stage tabs scroll horizontally */
    .cc-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .cc-tabs button {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Kanban: horizontal scroll */
    .kanban-wrap {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 12px !important;
        padding: 12px !important;
    }
    .k-col {
        min-width: 85vw;
        flex-shrink: 0;
    }

    /* Editor: stack vertically */
    .ed-2col {
        grid-template-columns: 1fr !important;
    }
    .editor-body {
        flex-direction: column !important;
    }
    .ed-stepper {
        width: 100% !important;
        max-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--b1);
        flex-direction: row !important;
        overflow-x: auto;
        padding: 8px 12px !important;
    }
    .ed-connector {
        width: 24px !important;
        height: 2px !important;
        align-self: center;
    }

    /* Right panel: full screen */
    #right-panel {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        z-index: 600;
    }

    /* Modals full screen on mobile */
    .modal-box {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* Competitors grid single column */
    .comp-grid {
        grid-template-columns: 1fr !important;
    }

    /* Prompts grid single column */
    .prompts-grid {
        grid-template-columns: 1fr !important;
    }

    /* Backup cards stack */
    .backup-cards {
        grid-template-columns: 1fr !important;
    }

    /* Quick actions 2-col on mobile */
    .dash-actions-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
