/* ═══════════════════════════════════════════════════════════
   Webradio Manager v2 — Responsive
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet / Small Desktop (≤ 1200px) ── */
@media (max-width: 1200px) {
    .decks-container {
        grid-template-columns: 1fr;
    }

    .mixer-center {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .deck-eq {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── Tablet Portrait (≤ 900px) ── */
@media (max-width: 900px) {
    .sidebar {
        width: var(--sidebar-w-collapsed, 56px);
        min-width: var(--sidebar-w-collapsed, 56px);
    }

    .sidebar .logo-text,
    .sidebar .logo-version,
    .sidebar .nav-item span,
    .sidebar .sidebar-status span:last-child {
        display: none;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: var(--sp-sm);
    }

    .main-content {
        margin-left: var(--sidebar-w-collapsed, 56px);
    }

    .deck {
        padding: var(--sp-sm);
    }

    .deck-controls {
        gap: var(--sp-xs);
    }

    .deck-panels {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .btn-play {
        width: 40px;
        height: 40px;
        font-size: var(--fs-md);
    }
}

/* ── Mobile (≤ 640px) ── */
@media (max-width: 640px) {
    :root {
        --sidebar-w: 0px;
        --footer-h: 80px;
    }

    .hamburger {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        min-width: 240px;
        transform: translateX(-100%);
        z-index: 99;
        transition: transform var(--duration) var(--ease);
        display: flex;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.open {
        pointer-events: auto;
    }

    .sidebar-close {
        display: inline-flex;
    }

    .main-content {
        margin-left: 0;
        height: calc(100vh - var(--footer-h));
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--sp-sm);
    }

    .view-header h1 {
        font-size: var(--fs-lg);
    }

    .view-header-actions {
        width: 100%;
    }

    .view-header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Mobile: Stack decks vertically */
    .decks-container {
        grid-template-columns: 1fr;
        gap: var(--sp-md);
    }

    .deck {
        min-height: auto;
    }

    .deck-waveform-container {
        height: 40px;
    }

    .deck-slider-row {
        flex-direction: column;
        gap: var(--sp-sm);
    }

    .deck-eq {
        grid-template-columns: repeat(3, 1fr);
    }

    .mixer-center {
        flex-direction: column;
        align-items: stretch;
    }

    .mixer-vumeters {
        justify-content: center;
    }

    .vu-meter canvas {
        height: 60px;
        width: 16px;
    }

    /* Footer mobile */
    .footer {
        height: var(--footer-h);
        flex-direction: column;
        align-items: stretch;
        padding: var(--sp-sm);
        gap: var(--sp-xs);
    }

    .footer-left,
    .footer-right {
        justify-content: center;
    }

    .footer-center {
        order: -1;
        justify-content: center;
        font-size: var(--fs-sm);
        font-weight: 600;
    }

    #footer-live-badge {
        font-size: var(--fs-xs);
        padding: 1px 6px;
    }

    /* Mobile PWA Control Bar */
    .mobile-pwa-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: var(--bg-panel);
        border-top: 1px solid var(--border);
        z-index: 100;
        justify-content: space-around;
        align-items: center;
        padding: 0 env(safe-area-inset-left) 0 env(safe-area-inset-right);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
    }

    .mobile-pwa-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        padding: 6px 8px;
        border-radius: var(--radius-sm);
        min-width: 56px;
        transition: color var(--duration-fast), background var(--duration-fast);
        font-size: 10px;
        font-weight: 500;
    }

    .mobile-pwa-btn:active,
    .mobile-pwa-btn.active {
        color: var(--accent);
        background: var(--accent-dim);
    }

    .mobile-pwa-btn svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
    }

    .mobile-pwa-btn.main {
        position: relative;
    }

    .mobile-pwa-btn.main svg {
        width: 28px;
        height: 28px;
    }

    .mobile-pwa-btn span {
        display: block;
        white-space: nowrap;
    }

    /* Adjust main content for PWA bar */
    .main-content {
        padding-bottom: 64px;
    }
}
}

/* ── Very Small (≤ 380px) ── */
@media (max-width: 380px) {
    body {
        font-size: 12px;
    }

    .deck-controls {
        flex-wrap: wrap;
    }

    .btn-play {
        width: 36px;
        height: 36px;
    }

    .btn-cue,
    .btn-pause,
    .btn-stop {
        font-size: 9px;
        padding: 3px 6px;
    }
}

/* ── Landscape Mobile ── */
@media (max-height: 500px) and (orientation: landscape) {
    .deck-waveform-container {
        height: 30px;
    }

    .deck-bpm,
    .deck-eq {
        display: none;
    }

    .mixer-vumeters {
        display: none;
    }
}

/* ── Large Desktop (≥ 1600px) ── */
@media (min-width: 1600px) {
    .main-scroll {
        max-width: 1600px;
        margin: 0 auto;
    }

    .deck-waveform-container {
        height: 100px;
    }
}

/* ── Print ── */
@media print {
    .sidebar,
    .footer,
    .deck-controls,
    .mixer-center,
    .btn,
    .toast-container {
        display: none !important;
    }

    .main-content {
        margin: 0;
        height: auto;
        overflow: visible;
    }

    body {
        background: #fff;
        color: #000;
    }
}

/* ── Mobile : le pied de page ne doit pas recouvrir la barre de navigation ── */
@media (max-width: 640px) {
    .mobile-pwa-bar {
        height: 56px;
    }

    .footer {
        bottom: 56px;
        height: var(--footer-h);
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: var(--sp-md);
        padding: 0 var(--sp-sm);
        overflow: hidden;
    }

    .footer-center {
        order: 0;
        font-size: var(--fs-xs);
        font-weight: 500;
    }

    .main-content {
        height: calc(100vh - var(--footer-h) - 56px);
    }

    /* Le contenu des vues ne passe pas sous la barre du bas */
    .view {
        padding-bottom: calc(var(--footer-h) + 64px);
    }
}

/* ── Mobile : formulaires de Paramètres empilés (libellé au-dessus du champ) ── */
@media (max-width: 640px) {
    .settings-form .settings-group {
        min-width: 0;
        padding: var(--sp-md);
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: var(--sp-xs);
    }

    .field-label label {
        white-space: normal;
    }

    .settings-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}

/* ── Mobile : tableau Bibliothèque — on garde case, titre et actions ── */
@media (max-width: 640px) {
    .lib-table col:nth-child(2),
    .lib-table col:nth-child(4),
    .lib-table col:nth-child(5),
    .lib-table col:nth-child(6) {
        display: none;
    }

    .lib-table th:nth-child(2), .lib-table td:nth-child(2),
    .lib-table th:nth-child(4), .lib-table td:nth-child(4),
    .lib-table th:nth-child(5), .lib-table td:nth-child(5),
    .lib-table th:nth-child(6), .lib-table td:nth-child(6) {
        display: none;
    }

    .lib-table col.col-act { width: 120px; }
}
