/* ═══════════════════════════════════════════════
   Spectral – Style
   Inspiré du design RadioTools / LevelMeter
   ═══════════════════════════════════════════════ */

:root {
    --bg-app:     #1c1c20;
    --bg-panel:   #26262b;
    --bg-element: #303037;
    --bg-hover:   #3a3a42;
    --border:     #3d3d45;

    --text-main:  #fafafa;
    --text-muted: #a1a1aa;

    --accent:       #6366f1;
    --accent-hover: #4f46e5;
    --danger:       #ef4444;
    --success:      #22c55e;
    --warning:      #f59e0b;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --gap:       10px;
    --radius:    8px;
    --radius-sm: 4px;

    --freq-axis-w: 42px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
    height: 100%;
    background: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-family);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════ */
#top-header {
    height: 52px;
    min-height: 52px;
    flex-shrink: 0;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 14px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    height: 28px;
    width: 28px;
    border-radius: 6px;
    flex-shrink: 0;
}

.title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.subtitle {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

/* ─── Groupes de contrôles ─── */
.control-group {
    display: flex;
    align-items: center;
    gap: 7px;
}

.control-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.control-value {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    min-width: 48px;
}

/* ─── Segmented control ─── */
.segmented {
    display: flex;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.seg-btn {
    padding: 4px 9px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.seg-btn:last-child { border-right: none; }

.seg-btn:hover { background: var(--bg-hover); color: var(--text-main); }

.seg-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ─── Range input ─── */
.range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-panel);
    cursor: pointer;
    transition: background 0.15s;
}

.range-input::-webkit-slider-thumb:hover { background: var(--accent-hover); }

.range-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-panel);
    cursor: pointer;
}

/* ─── Boutons ─── */
.control-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-element);
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.control-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

/* ═══════════════════════════════════════════════
   DROP ZONE
   ═══════════════════════════════════════════════ */
.drop-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    transition: background 0.2s;
}

.drop-zone.hidden { display: none; }

.drop-zone.drag-active {
    background: rgba(99, 102, 241, 0.06);
}

.drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 56px;
    background: var(--bg-panel);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    max-width: 480px;
    width: calc(100% - 32px);
}

.drop-inner.drag-over {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.drop-icon {
    font-size: 3.5rem;
    line-height: 1;
    filter: grayscale(0.3);
}

.drop-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
}

.drop-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════
   OVERLAY PROGRESSION
   ═══════════════════════════════════════════════ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 28, 32, 0.94);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.overlay.active { display: flex; }

.overlay-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 48px;
    text-align: center;
    max-width: 400px;
    width: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.overlay-icon { font-size: 2.6rem; line-height: 1; }
.overlay-card h2 { font-size: 1.15rem; font-weight: 700; }

.progress-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.12s ease;
}

.progress-pct {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

/* ═══════════════════════════════════════════════
   MAIN APP
   ═══════════════════════════════════════════════ */
#app {
    flex: 1;
    min-height: 0;
    padding: var(--gap);
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    overflow: hidden;
}

#app.hidden { display: none; }

/* ─── Card base ─── */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.card-header {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-element);
    flex-shrink: 0;
}

.section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.08em;
}

.card-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Info bar ─── */
.info-bar {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
}

.info-icon { font-size: 1.4rem; flex-shrink: 0; }

.info-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.info-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 600px;
}

.info-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ─── Hover badge ─── */
.freq-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(99, 102, 241, 0.12);
    padding: 3px 8px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hover-badge {
    visibility: hidden;
    transition: none;
}

/* ═══════════════════════════════════════════════
   SPECTROGRAMME
   ═══════════════════════════════════════════════ */
.card-spectro {
    flex: 1;
    min-height: 0;
}

.spectro-layout {
    flex: 1;
    display: flex;
    min-height: 0;
    min-width: 0;
}

/* ─── Axe fréquences ─── */
.freq-axis {
    width: var(--freq-axis-w);
    flex-shrink: 0;
    position: relative;
    background: var(--bg-panel);
}

.freq-tick {
    position: absolute;
    right: 6px;
    font-size: 0.58rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    line-height: 1;
    transform: translateY(-50%);
    white-space: nowrap;
}

/* ─── Canvas wrapper ─── */
.canvas-wrap {
    flex: 1;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
}

#spectroCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

/* Crosshairs */
.crosshair {
    position: absolute;
    pointer-events: none;
    display: none;
    z-index: 10;
}

.xhair-h {
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.25);
}

.xhair-v {
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.25);
}

/* ─── Axe temps ─── */
.time-axis-row {
    display: flex;
    flex-shrink: 0;
    padding-bottom: 4px;
}

.freq-axis-spacer {
    width: var(--freq-axis-w);
    flex-shrink: 0;
}

.time-axis {
    flex: 1;
    position: relative;
    height: 20px;
    min-width: 0;
}

.time-tick {
    position: absolute;
    font-size: 0.58rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    transform: translateX(-50%);
    top: 4px;
    white-space: nowrap;
}

/* Trait vertical sur le tick */
.time-tick::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -4px;
    width: 1px;
    height: 3px;
    background: var(--border);
}

/* ═══════════════════════════════════════════════
   BARRE DE COULEUR (légende dB)
   ═══════════════════════════════════════════════ */
.scale-card {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    padding: 6px 14px;
    gap: 10px;
}

.scale-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.scale-lbl {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.scale-canvas {
    flex: 1;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border);
    display: block;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 900px) {
    .control-group:first-child { display: none; } /* cache canal sur petit écran */
    .range-input { width: 70px; }
}

@media (max-width: 600px) {
    #top-header { height: auto; padding: 8px 14px; flex-wrap: wrap; gap: 8px; }
    .header-controls { flex-wrap: wrap; gap: 8px; }
    .control-group { display: none; }
    #app { padding: 6px; gap: 6px; }
    .info-name { font-size: 0.8rem; }
}
