/* ===================== MOBILE RESPONSIVENESS ===================== */


/* --- Tablet / small-desktop (≤1200px) --- */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .main-grid.left-collapsed,
    .main-grid.right-collapsed,
    .main-grid.left-collapsed.right-collapsed {
        grid-template-columns: 1fr !important;
    }

    /* Override desktop collapse transforms — panels should never fly off-screen in stacked layout */
    .controls-panel.collapsed,
    .right-panel.collapsed {
        transform: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .visualization-panel {
        order: -1;
        /* Bloch sphere first */
        min-height: 420px !important;
        height: 55vw;
        max-height: 70vh;
    }

    .controls-panel,
    .right-panel {
        max-height: none !important;
        overflow-y: visible !important;
    }

    .container {
        padding: 0;
    }

    body {
        padding: 80px 12px 24px 12px;
    }

    .collapse-toggle {
        display: none !important;
    }

    /* Header — keep it compact, move indicators to sub-bar */
    .app-header {
        padding: 0 12px;
        height: 50px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .brand-title {
        font-size: 1.35em !important;
    }

    .brand-author {
        font-size: 0.65em !important;
    }

    /* ── Sub-header info bar for indicators ── */
    .header-indicators {
        /* Override desktop layout: become a full-width row BELOW the header */
        display: flex !important;
        position: fixed;
        top: 50px;
        /* right below the header */
        left: 0;
        right: 0;
        z-index: 1999;
        background: rgba(10, 10, 10, 0.85);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-bottom: 1px solid rgba(212, 175, 55, 0.15);
        padding: 4px 12px;
        gap: 10px;
        justify-content: center;
        align-items: center;
        height: 32px;
    }

    .header-indicator {
        height: 24px !important;
        padding: 2px 10px !important;
        border-radius: 8px !important;
        font-size: 0.75em;
        min-width: auto !important;
        flex: 1;
        max-width: 50%;
    }

    .history-indicator {
        min-width: auto !important;
        max-width: 60%;
    }

    .indicator-value {
        font-size: 0.75em !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .indicator-icon {
        width: 12px !important;
        height: 12px !important;
        flex-shrink: 0;
    }

    .status-dot {
        width: 7px !important;
        height: 7px !important;
        margin-right: 4px !important;
    }

    /* Push body down to account for sub-bar */
    body {
        padding-top: 92px !important;
        /* 50px header + 32px sub-bar + 10px gap */
    }

    .global-actions span {
        display: none;
    }

    .header-btn {
        padding: 7px 10px;
    }

    /* Glass panels */
    .glass-panel {
        border-radius: 14px;
        padding: 12px;
    }

    /* ── Toolbar: wrap into 2 rows on medium screens ── */
    .viz-control-pane {
        max-width: calc(100% - 24px) !important;
        border-radius: 16px !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        padding: 6px 8px !important;
    }

    .viz-control-pane.expanded .toolbar-collapsible {
        max-width: none !important;
        flex-wrap: wrap !important;
        justify-content: center;
    }

    /* Hide separators in wrapped layout to save space */
    .viz-control-pane .v-sep {
        display: none;
    }
}

/* --- Phone (≤600px) --- */
@media (max-width: 600px) {
    body {
        padding: 90px 6px 16px 6px !important;
    }

    .app-header {
        height: 46px;
        padding: 0 8px;
    }

    .header-indicators {
        top: 46px !important;
        /* match reduced header */
        height: 30px;
        padding: 3px 8px;
        gap: 6px;
    }

    .brand-title {
        font-size: 1.15em !important;
    }

    .brand-author {
        font-size: 0.6em !important;
    }

    .global-actions {
        gap: 4px;
    }

    .header-btn {
        padding: 6px 8px;
        border-radius: 8px;
    }

    .header-icon {
        width: 14px;
        height: 14px;
    }

    .visualization-panel {
        min-height: 300px !important;
        height: 65vw;
        max-height: 55vh;
        border-radius: 12px !important;
    }

    .glass-panel {
        border-radius: 12px;
        padding: 10px;
    }

    .section-card {
        padding: 12px;
        border-radius: 10px;
    }

    .section-title {
        font-size: 0.85em;
        letter-spacing: 0.8px;
    }

    /* Gate grids — auto-fill on phone */
    .gate-grid,
    .preset-grid-2 {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)) !important;
    }

    /* Viz toolbar — even smaller */
    .viz-control-pane {
        bottom: 8px !important;
        padding: 4px 6px !important;
        gap: 2px !important;
    }

    .viz-control-pane .quantum-btn.tool {
        width: 30px !important;
        height: 30px !important;
    }

    .viz-control-pane .viz-icon {
        width: 14px !important;
        height: 14px !important;
    }

    /* Tighter spacing on section cards */
    .controls-panel,
    .right-panel {
        gap: 12px !important;
    }
}
