/* base.css — Tokens, reset, nav, composants partagés file-review-gui */

/* ── Tokens ── */
:root {
  --bg: #0f172a; --surface: #1e293b; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8;
  --green: #22c55e; --yellow: #f59e0b; --red: #ef4444;
  --blue: #60a5fa; --orange: #f97316; --purple: #a78bfa;
  --shadow: 0 1px 6px rgba(0,0,0,.4);
  --shadow-hover: 0 2px 12px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f8fafc; --surface: #ffffff; --border: #e2e8f0;
          --text: #0f172a; --muted: #64748b;
          --shadow: 0 1px 6px rgba(32,33,36,.18);
          --shadow-hover: 0 2px 12px rgba(32,33,36,.25); }
}
:root[data-theme="dark"]  { --bg: #0f172a; --surface: #1e293b; --border: #334155;
                             --text: #e2e8f0; --muted: #94a3b8; }
:root[data-theme="light"] { --bg: #f8fafc; --surface: #ffffff; --border: #e2e8f0;
                             --text: #0f172a; --muted: #64748b; }

/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 "Inter", system-ui, sans-serif;
       min-height: 100vh; }

/* ── Nav ── */
nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 1.5rem;
      display: flex; align-items: center; gap: 2rem; height: 52px; }
nav a { color: var(--muted); text-decoration: none; font-size: .875rem; }
nav a:hover, nav a.active { color: var(--text); }
nav .brand { color: var(--accent); font-weight: 700; font-size: 1rem; }
nav .brand a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.subtitle { color: var(--muted); font-size: .875rem; margin-bottom: 1.5rem; }

/* ── Boutons ── */
.btn { padding: .44rem .9rem; border-radius: 6px; border: none; cursor: pointer;
       font-size: .8125rem; font-weight: 500; font-family: inherit; }
.btn-primary { background: var(--accent); color: #0f172a; }
.btn-primary:hover { background: #7dd3fc; }
.btn-accent { background: var(--accent); color: #0f172a; }
.btn-accent:hover { filter: brightness(1.1); }
.btn-accent:disabled { opacity: .4; cursor: default; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,.1); }
.btn-sm { padding: .25rem .55rem; font-size: .72rem; }

/* ── Stats cards ── */
.stats { display: flex; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
        padding: .875rem 1.25rem; min-width: 120px; }
.stat .val { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: .68rem; text-transform: uppercase;
             letter-spacing: .06em; margin-top: 2px; }
.stat.green .val  { color: var(--green); }
.stat.yellow .val { color: var(--yellow); }
.stat.blue .val   { color: var(--blue); }
.stat.red .val    { color: var(--red); }
.stat.orange .val { color: var(--orange); }
.stat.gray .val   { color: var(--muted); }
.stat.purple .val { color: var(--purple); }
.stat.accent .val { background: linear-gradient(135deg, var(--accent), var(--purple));
                    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
                    background-clip: text; }

/* ── Onglets ── */
.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap;
        border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
       color: var(--muted); font: inherit; font-size: .875rem; padding: .5rem .85rem;
       margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .n { font-size: .72rem; opacity: .8; font-variant-numeric: tabular-nums; }

/* ── Recherche ── */
.search-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
                padding: .75rem 1rem; margin-bottom: 1rem;
                display: flex; flex-wrap: wrap; gap: .625rem; align-items: center; }
.search-wrap { flex: 1; min-width: 220px; position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: .65rem; width: 14px; height: 14px;
               color: var(--muted); pointer-events: none; }
.search-wrap input[type=text] { width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: .44rem 2rem .44rem 2.1rem;
  font-size: .875rem; font-family: inherit; }
.search-wrap input[type=text]:focus { outline: none; border-color: var(--accent); }
.search-wrap input[type=text]::placeholder { color: var(--muted); }

/* ── Formulaires ── */
select, .modal select, .modal input, .modal textarea, .filters select, .filters input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: .38rem .6rem; font-size: .8125rem; font-family: inherit; }
select:focus, .modal select:focus, .modal input:focus, .modal textarea:focus,
.filters select:focus, .filters input:focus { outline: none; border-color: var(--accent); }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
                 z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
         padding: 1.5rem; width: 90%; max-width: 480px; }
.modal h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal label { display: block; font-size: .78rem; color: var(--muted);
               margin-bottom: .25rem; margin-top: .65rem; }
.modal textarea { resize: vertical; min-height: 80px; }
.modal-footer { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; }
.modal-erreur { color: var(--red); font-size: .78rem; margin-top: .5rem; min-height: 1.2em; }

/* ── Toolbar ── */
.toolbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
     color: var(--muted); padding: .625rem 1rem; background: var(--surface);
     border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .625rem 1rem; border-bottom: 1px solid var(--border);
     vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Badges ── */
.badge { display: inline-block; font-size: .68rem; font-weight: 600; padding: 2px 7px;
         border-radius: 9999px; white-space: nowrap; }
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-red    { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-gray   { background: rgba(148,163,184,.1); color: var(--muted); }
.badge-purple { background: rgba(167,139,250,.15); color: var(--purple); }

/* ── Utilitaires ── */
.fname-mono { font-family: ui-monospace, monospace; font-size: .75rem; word-break: break-all; }
.empty { padding: 3rem; text-align: center; color: var(--muted); }
.spin { display: none; animation: spin .7s linear infinite; }
.spinning .spin { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Live dot ── */
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
            background: var(--green); margin-right: .4rem; vertical-align: middle;
            animation: pulse-live 2s ease-in-out infinite; }
@keyframes pulse-live { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ── Date group (filtres par date) ── */
.date-group { display: flex; align-items: center; gap: .4rem; font-size: .8125rem;
              color: var(--muted); white-space: nowrap; }
.date-group input[type=date] { background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: .38rem .5rem; font-size: .78rem;
  font-family: inherit; }
.date-group input[type=date]:focus { outline: none; border-color: var(--accent); }

/* ── Cloche + tiroir alertes ── */
.nav-cloche {
  background: none; border: none; color: var(--muted); cursor: pointer;
  position: relative; padding: .3rem; margin-left: auto; display: flex; align-items: center;
}
.nav-cloche:hover { color: var(--text); }
.cloche-badge {
  position: absolute; top: -2px; right: -6px; min-width: 16px; height: 16px;
  background: var(--red); color: #fff; font-size: .62rem; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}
.alert-drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; width: min(420px, 92vw);
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .25s ease;
  z-index: 60; display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,.3);
}
.alert-drawer.open { transform: translateX(0); }
.ad-head {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .875rem;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ad-titre { font-weight: 700; font-size: .9rem; }
.ad-onglet {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .78rem; padding: .25rem .5rem; border-radius: 4px;
}
.ad-onglet.actif { color: var(--text); background: rgba(148,163,184,.12); font-weight: 600; }
.ad-onglet:hover:not(.actif) { color: var(--text); }
.ad-fermer {
  margin-left: auto; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 1rem; padding: .2rem .4rem; border-radius: 4px;
}
.ad-fermer:hover { color: var(--text); background: rgba(148,163,184,.12); }
.ad-corps { flex: 1; overflow-y: auto; padding: .5rem; }
.ad-carte {
  padding: .6rem .75rem; border-radius: 8px; border-left: 3px solid var(--border);
  background: var(--bg); margin-bottom: .4rem; position: relative;
  transition: opacity .2s;
}
.ad-carte.urgent { border-left-color: var(--red); }
.ad-carte.attention { border-left-color: var(--yellow); }
.ad-carte.info { border-left-color: var(--blue); }
.ad-carte .ad-lib { font-size: .82rem; line-height: 1.35; }
.ad-carte .ad-meta {
  display: flex; gap: .5rem; align-items: center; margin-top: .3rem;
  font-size: .72rem; color: var(--muted);
}
.ad-carte .ad-niv {
  font-size: .68rem; padding: .08rem .35rem; border-radius: 999px; font-weight: 600;
}
.ad-niv-urgent { background: #5a1d1d; color: #ffb4b4; }
.ad-niv-attention { background: #4a3a12; color: #ffe08a; }
.ad-niv-info { background: #1d3a4a; color: #a8d8ff; }
.ad-carte .ad-arch {
  position: absolute; top: .5rem; right: .5rem; background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: .82rem; padding: .15rem .35rem;
  border-radius: 4px; opacity: 0; transition: opacity .15s;
}
.ad-carte:hover .ad-arch { opacity: 1; }
.ad-carte .ad-arch:hover { color: var(--text); background: rgba(148,163,184,.12); }
.ad-vide { text-align: center; color: var(--muted); padding: 2rem .5rem; font-size: .85rem; }
@media (prefers-color-scheme: light) {
  .ad-niv-urgent { background: #fee2e2; color: #b91c1c; }
  .ad-niv-attention { background: #fef3c7; color: #92400e; }
  .ad-niv-info { background: #dbeafe; color: #1e40af; }
}

/* ── Visionneuse (panneau latéral partagé) ── */
.pdf-panel {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 40%;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .3s ease;
  z-index: 50; overflow: auto;
  box-shadow: -12px 0 32px rgba(0,0,0,.3);
}
.pdf-panel.open { transform: translateX(0); }
.pdf-head { position: sticky; top: 0; z-index: 2; height: 60px;
            display: flex; align-items: center; gap: .5rem; padding: 0 .875rem;
            background: var(--surface); border-bottom: 1px solid var(--border); }
.pdf-title { flex: 1; font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
             font-size: .75rem; font-weight: 600; color: var(--text);
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pdf-btn { background: transparent; border: 1px solid var(--border); color: var(--muted);
           padding: .3rem .6rem; font-size: .75rem; border-radius: 5px; cursor: pointer;
           white-space: nowrap; text-decoration: none; display: inline-block; flex-shrink: 0; }
.pdf-btn:hover { border-color: var(--accent); color: var(--accent); }
.pdf-zoom-val { font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums;
                min-width: 38px; text-align: center; flex-shrink: 0; }
.pdf-close { background: transparent; border: none; color: var(--muted); font-size: 1rem;
             cursor: pointer; padding: .25rem .45rem; border-radius: 5px; flex-shrink: 0; }
.pdf-close:hover { color: var(--text); background: rgba(148,163,184,.12); }
#pdf-frame { width: 100%; height: calc(100% - 60px); border: none; display: block;
             background: var(--bg); transform-origin: top left;
             transition: transform .15s ease, opacity .15s ease; }
#pdf-frame.md-mode { background: #fff; color-scheme: light; }
#preview-img { width: 100%; height: calc(100% - 60px); object-fit: contain; display: none;
               background: var(--bg); padding: .5rem; box-sizing: border-box;
               transition: opacity .15s ease; }
.zoom-controls { display: flex; align-items: center; gap: .5rem; }
@keyframes vis-pulse {
  0%, 100% { background: var(--surface,#fff); }
  50% { background: rgba(56,142,204,.18); }
}
.vis-nav { position: fixed; top: 50%; transform: translateY(-50%);
           z-index: 52; background: var(--surface); color: var(--accent);
           border: 2px solid var(--accent);
           font-size: 2rem; font-weight: 700; line-height: 1; padding: .7rem .5rem; cursor: pointer;
           border-radius: 8px; display: none; transition: background .15s, color .15s;
           box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.vis-nav.visible { display: block; }
.vis-nav.visible:hover { background: var(--accent); color: #0f172a; }
.vis-nav:disabled { display: none !important; }
.vis-nav-prev { left: 10px; right: auto; }
.vis-nav-next { right: 10px; }

@media (max-width: 900px) {
  .pdf-panel { width: 100%; top: 0; z-index: 999; box-shadow: none; }
  .vis-goto-row { display: none !important; }
  .vis-nav-prev { left: 10px; right: auto; }
  .vis-nav-next { right: 10px; }
}

/* ── Volet retraitement (bas de page, global) ── */
.job-tray {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  transform: translateY(100%); transition: transform .3s ease;
}
.job-tray.visible { transform: translateY(0); }

.job-tray-tab {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--accent);
  border-bottom: none; border-radius: 8px 8px 0 0;
  padding: .3rem .9rem; cursor: pointer;
  display: flex; align-items: center; gap: .5rem;
  box-shadow: 0 -4px 16px rgba(56,189,248,.08);
  transition: box-shadow .3s;
}
.job-tray-tab:hover { box-shadow: 0 -4px 20px rgba(56,189,248,.15); }
.job-tray.done .job-tray-tab { border-color: var(--green); box-shadow: 0 -4px 16px rgba(34,197,94,.08); }

.job-tray-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: tray-pulse 1.8s ease-in-out infinite;
}
.job-tray.done .job-tray-dot { background: var(--green); animation: none; }
@keyframes tray-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(56,189,248,.45); }
  50% { opacity: .5; box-shadow: 0 0 0 5px rgba(56,189,248,0); }
}

.job-tray-label { font-size: .75rem; font-weight: 600; color: var(--accent); white-space: nowrap;
                  font-variant-numeric: tabular-nums; }
.job-tray.done .job-tray-label { color: var(--green); }

.job-tray-body {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: .7rem 1.5rem; display: none; align-items: center; gap: 1.2rem;
  box-shadow: 0 -8px 28px rgba(0,0,0,.3);
}
.job-tray.open .job-tray-body { display: flex; }

.job-tray-bar-wrap {
  flex: 1; max-width: 280px; height: 6px;
  background: var(--border); border-radius: 3px; overflow: hidden;
}
.job-tray-bar-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width .4s ease;
}
.job-tray.done .job-tray-bar-fill { background: var(--green); }

.job-tray-detail { font-size: .8rem; color: var(--text); font-variant-numeric: tabular-nums; }
.job-tray-sub { font-size: .72rem; color: var(--muted); }
.job-tray-dismiss {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: .25rem .6rem; border-radius: 5px; cursor: pointer; font-size: .72rem;
  margin-left: auto;
}
.job-tray-dismiss:hover { color: var(--text); border-color: var(--text); }
