/* Sweet Médias à la demande — interface sobre, claire / sombre automatique */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --accent: #111827;
  --accent-text: #ffffff;
  --focus: #2563eb;
  --success: #047857; --success-bg: #ecfdf5;
  --warning: #b45309; --warning-bg: #fffbeb;
  --danger: #b91c1c;  --danger-bg: #fef2f2;
  --info: #1d4ed8;    --info-bg: #eff6ff;
  --track: #eef0f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1d212a;
    --border: #2a2f3a;
    --text: #f3f4f6;
    --text-2: #c7cbd3;
    --muted: #9097a3;
    --accent: #f3f4f6;
    --accent-text: #111827;
    --focus: #60a5fa;
    --success: #34d399; --success-bg: #0f2a22;
    --warning: #fbbf24; --warning-bg: #2b2210;
    --danger: #f87171;  --danger-bg: #2d1416;
    --info: #93c5fd;    --info-bg: #142036;
    --track: #232833;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.5rem 0 .75rem; color: var(--text-2); }
code, .filename { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 1rem; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: .5rem 0; margin: 0; }

/* ---------- En-tête */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; min-height: 64px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 14px; margin-right: auto; min-width: 0; }
.brand img { height: 38px; width: auto; max-width: 140px; object-fit: contain; }
.brand-sep { width: 1px; height: 28px; background: var(--border); }
.brand-text { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #db2777, #7c3aed); }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-logout { margin-left: 8px; }
@media (max-width: 1080px) { .brand-text small { display: none; } }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch;
         background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; }
  .nav.is-open { display: flex; }
  .nav-logout { margin-left: 0; }
  .brand img { height: 30px; }
}

/* ---------- Mise en page */
.main { max-width: 1180px; margin: 0 auto; padding: 28px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head-logo { height: 52px; width: auto; max-width: 180px; object-fit: contain; }
.back { display: inline-block; text-decoration: none; color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
.eyebrow { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card.narrow { max-width: 640px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head a { font-size: .9rem; color: var(--muted); }
.card-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin-bottom: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }
.subnav { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.subnav a { text-decoration: none; font-size: .88rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.subnav a:hover { color: var(--text); }
section[id] { scroll-margin-top: 80px; }

/* ---------- Alertes */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .93rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }

/* ---------- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px;
       padding: 9px 16px; font: inherit; font-size: .92rem; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.2; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.danger-text { color: var(--danger); }
form { margin: 0; }

/* ---------- Formulaires */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-items: end; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid > h3 { margin: .75rem 0 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .84rem; color: var(--text-2); font-weight: 550; }
.field-wide { grid-column: 1 / -1; }
.field-end { justify-content: flex-end; }
.form-actions { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; color: var(--text-2); cursor: pointer; }
.check input { margin-top: 3px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
input:not([type="checkbox"]):not([type="file"]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
input[type="file"] { font: inherit; font-size: .88rem; color: var(--text-2); padding: 6px 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.field input[data-password] + .btn { align-self: flex-start; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input { max-width: 200px; min-height: 34px; padding: 6px 9px; }
.upload-form { margin-top: 20px; padding-top: 20px; border-top: 1px dashed var(--border); }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 200px; }
@media (max-width: 720px) {
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .filters input, .filters select { width: 100%; }
}

/* ---------- Tableaux */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
            padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table-click tbody tr { cursor: pointer; }
.table-click tbody tr:hover { background: var(--surface-2); }
.table a { text-decoration: none; }
.table tr.is-muted { opacity: .55; }
.logo-cell { width: 56px; }
.logo-cell img { width: 44px; height: 32px; object-fit: contain; display: block; }
tr.level-error td { color: var(--danger); }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }

/* ---------- Badges et pastilles */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
         background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); vertical-align: middle; }
.badge-planned { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-active { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-missed, .badge-level-error { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-level-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-generic { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #9ca3af); margin-right: 8px; vertical-align: middle; flex-shrink: 0; }
.warn { color: var(--warning); cursor: help; }

/* ---------- À l'antenne */
.onair { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 10px; background: var(--surface-2);
         border: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.onair > div { flex: 1; min-width: 200px; }
.onair-hero { background: var(--surface); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow); border-radius: var(--radius); }
.onair-hero strong { font-size: 1.25rem; display: block; margin: 2px 0; }
.onair-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex-shrink: 0;
             box-shadow: 0 0 0 5px color-mix(in srgb, var(--muted) 18%, transparent); }
.onair.is-specific .onair-dot { background: #ef4444; box-shadow: 0 0 0 5px rgba(239, 68, 68, .18); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(239, 68, 68, .05); } }
@media (prefers-reduced-motion: reduce) { .onair.is-specific .onair-dot { animation: none; } }
.filename { background: var(--surface); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; color: var(--text-2); }

/* ---------- Aperçu (timeline) */
.timeline { font-size: .8rem; }
.tl-head, .tl-row { display: grid; grid-template-columns: 82px 1fr; gap: 10px; align-items: center; }
.tl-scale { display: flex; justify-content: space-between; color: var(--muted); padding-bottom: 4px; }
.tl-scale span:first-child { transform: translateX(0); }
.tl-row { padding: 3px 0; }
.tl-day { color: var(--text-2); white-space: nowrap; }
.tl-row.is-today .tl-day { font-weight: 700; color: var(--text); }
.tl-track { position: relative; height: 20px; background: var(--track); border-radius: 5px; overflow: hidden;
            background-image: linear-gradient(90deg, transparent calc(25% - 1px), var(--border) 25%, transparent calc(25% + 1px),
                              transparent calc(50% - 1px), var(--border) 50%, transparent calc(50% + 1px),
                              transparent calc(75% - 1px), var(--border) 75%, transparent calc(75% + 1px)); }
.tl-seg { position: absolute; top: 2px; bottom: 2px; background: var(--c); border-radius: 4px; cursor: help; }
.tl-seg.tl-planned { background: repeating-linear-gradient(135deg, var(--c) 0 6px, color-mix(in srgb, var(--c) 70%, transparent) 6px 12px); }
.tl-seg.tl-done { opacity: .55; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #ef4444; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; color: var(--text-2); }
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-key { width: 14px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; }
.tl-key-generic { background: var(--track); border: 1px solid var(--border); }
@media (max-width: 600px) { .tl-head, .tl-row { grid-template-columns: 64px 1fr; } }

/* ---------- Spots */
.spot-list { display: flex; flex-direction: column; gap: 10px; }
.spot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); gap: 8px 16px; align-items: center;
        padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.spot.is-generic { background: var(--surface-2); }
.spot.is-archived { opacity: .55; }
.spot-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spot audio { width: 100%; height: 38px; }
.spot-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.spot-actions:empty { display: none; }
.inline-edit input { border-color: transparent !important; background: transparent !important; font-weight: 600; padding: 4px 6px !important;
                     min-height: 0 !important; width: auto !important; min-width: 12ch; }
.inline-edit input:hover, .inline-edit input:focus { border-color: var(--border) !important; background: var(--surface) !important; }
@media (max-width: 720px) { .spot { grid-template-columns: 1fr; } }

/* ---------- Tableau de bord */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .85rem; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.event-list li:last-child { border-bottom: 0; }
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { display: flex; align-items: center; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.upcoming li:last-child { border-bottom: 0; }
.upcoming-main { flex: 1; min-width: 0; }

/* ---------- Radios */
.radio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.radio-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; margin: 0; transition: border-color .15s; }
.radio-card:hover { border-color: var(--muted); }
.radio-logo { height: 90px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 8px; margin-bottom: 8px; }
.radio-logo img { max-height: 64px; max-width: 80%; object-fit: contain; }

/* ---------- Connexion / installation */
.main-public { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }
.main-public > .alert { max-width: 400px; margin: 0 auto 16px; width: 100%; }
.login-shell { display: flex; justify-content: center; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login-card.wide { max-width: 520px; }
.login-card h1 { margin-bottom: 4px; }
.login-card > .muted { margin-top: 0; margin-bottom: 20px; }
.login-logos { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.login-logos img { height: 42px; width: auto; max-width: 140px; object-fit: contain; }
.checklist { list-style: none; padding: 0; margin: 16px 0; font-size: .92rem; }
.checklist li { padding: 4px 0; }
.checklist .ok { color: var(--success); }
.checklist .ko { color: var(--danger); }

/* ---------- Synthèse imprimable */
.report { background: var(--bg); }
.report-bar { max-width: 900px; margin: 0 auto; padding: 20px 16px 0; display: flex; justify-content: space-between; gap: 8px; }
.report-page { max-width: 900px; margin: 16px auto 48px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; }
.report-head { display: flex; align-items: center; gap: 24px; padding-bottom: 20px; margin-bottom: 8px; border-bottom: 2px solid var(--text); }
.report-head img { height: 56px; width: auto; max-width: 150px; object-fit: contain; }
.report-title { flex: 1; }
.report-title p { margin: 4px 0 0; color: var(--text-2); }
.report-page h2 { margin-top: 28px; }
.report-foot { margin-top: 28px; }
@media (max-width: 640px) {
  .report-page { padding: 20px; }
  .report-head { flex-wrap: wrap; gap: 12px; }
}
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --border: #d1d5db; color-scheme: light; }
  .no-print { display: none !important; }
  .report-page { border: 0; margin: 0; padding: 0; max-width: none; }
  body { font-size: 12px; }
}
