/* ============================================================
   TV Mark — Feuille de style partagée (dashboard admin, portail
   ayants droit, pages légales).
   Tokens repris de docs/06-design-system.md.
   ============================================================ */

:root {
  --bg: #0B0A12;
  --surface: #15131F;
  --surface-alt: #1D1A2B;
  --primary: #7C5CFC;
  --primary-bright: #9B7DFF;
  --on-primary: #FFFFFF;
  --text-primary: #F2F0FA;
  --text-secondary: #9A93B5;
  --outline: #2A2740;
  --success: #4ADE80;
  --warning: #FBBF24;
  --danger: #F87171;
  --gradient-premium: linear-gradient(135deg, #7C5CFC, #4C3AAB);

  --radius-card: 20px;
  --radius-btn: 14px;
  --radius-pill: 999px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

p { color: var(--text-primary); }

.muted { color: var(--text-secondary); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.hidden { display: none !important; }

/* ---------- En-tête / nav commun (pages publiques) ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--outline);
  background: rgba(11, 10, 18, 0.92);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text-primary);
}
.brand:hover { text-decoration: none; }

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--gradient-premium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }

.site-nav a {
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
}
.site-nav a:hover { color: var(--text-primary); background: var(--surface-alt); text-decoration: none; }
.site-nav a.active { color: var(--on-primary); background: var(--primary); }

/* ---------- Mise en page générale ---------- */

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.page-wide { max-width: 1200px; }

.page header.page-head { margin-bottom: 28px; }
.page-head .subtitle { color: var(--text-secondary); margin-top: 6px; }

.legal-content h2 { margin: 32px 0 10px; }
.legal-content h3 { margin: 22px 0 8px; }
.legal-content p, .legal-content li { color: var(--text-secondary); margin-bottom: 10px; }
.legal-content li { margin-left: 22px; margin-bottom: 6px; }
.legal-content strong { color: var(--text-primary); }
.legal-content .updated { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 24px; }

.back-link { display: inline-block; margin-bottom: 20px; font-size: 13.5px; }

.site-footer {
  border-top: 1px solid var(--outline);
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12.5px;
}
.site-footer a { color: var(--text-secondary); text-decoration: underline; }
.site-footer a:hover { color: var(--text-primary); }

/* ---------- Cards & surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 18px 20px;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-label { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--primary);
  color: var(--on-primary);
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
  text-decoration: none;
}
.btn:hover { background: var(--primary-bright); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: var(--surface-alt); color: var(--text-primary); border-color: var(--outline); }
.btn-secondary:hover { background: #262238; }

.btn-ghost { background: transparent; color: var(--primary-bright); }
.btn-ghost:hover { background: var(--surface-alt); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.12); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }

.btn-block { width: 100%; }

/* ---------- Formulaires ---------- */

label.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 14px 0 6px;
}
label.field-label .req { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-alt);
  border: 1px solid var(--outline);
  border-radius: var(--radius-btn);
  padding: 11px 14px;
  outline: none;
  transition: border-color 120ms ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 96px; }
select { appearance: none; }
::placeholder { color: #6B6486; }

.field-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ---------- Dashboard : layout sidebar ---------- */

.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--outline);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-sidebar .brand { padding: 4px 10px 18px; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.tab-btn:hover { background: var(--surface-alt); color: var(--text-primary); }
.tab-btn.active { background: var(--primary); color: var(--on-primary); font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--outline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user { font-size: 12.5px; color: var(--text-secondary); word-break: break-all; padding: 0 10px; }

.admin-main { padding: 32px 32px 80px; min-width: 0; }
.admin-main > section { max-width: 1100px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-head p { color: var(--text-secondary); font-size: 13.5px; margin-top: 4px; }

/* ---------- Tables & listes ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 16px; vertical-align: top; }
th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--outline);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--outline); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(124, 92, 252, 0.05); }
tr.row-click { cursor: pointer; }

.list-stack { display: flex; flex-direction: column; gap: 12px; }

.item-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 16px 18px;
}
.item-card .item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.item-card .item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.quote-block {
  background: var(--surface-alt);
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.kv-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px 16px;
  font-size: 13.5px;
  margin-top: 8px;
}
.kv-grid dt { color: var(--text-secondary); }
.kv-grid dd { word-break: break-word; }

/* ---------- Badges / pills ---------- */

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--outline);
  background: var(--surface-alt);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge-primary { background: rgba(124, 92, 252, 0.15); border-color: var(--primary); color: var(--primary-bright); }
.badge-success { background: rgba(74, 222, 128, 0.12); border-color: var(--success); color: var(--success); }
.badge-warning { background: rgba(251, 191, 36, 0.12); border-color: var(--warning); color: var(--warning); }
.badge-danger  { background: rgba(248, 113, 113, 0.12); border-color: var(--danger); color: var(--danger); }

/* ---------- États ---------- */

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 20px;
  border: 1px dashed var(--outline);
  border-radius: var(--radius-card);
  font-size: 14px;
}

.loading { color: var(--text-secondary); padding: 24px 4px; font-size: 13.5px; }

.load-more-row { display: flex; justify-content: center; margin-top: 16px; }

/* ---------- Écrans login / accès refusé ---------- */

.gate-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.gate-card .brand { justify-content: center; margin-bottom: 20px; }
.gate-card h1 { font-size: 22px; margin-bottom: 8px; }
.gate-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

/* ---------- Modale de confirmation ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 26px;
  width: 100%;
  max-width: 460px;
}
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--text-secondary); font-size: 14px; }
.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Toasts ---------- */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
  max-width: 380px;
}
.toast {
  background: var(--surface-alt);
  border: 1px solid var(--outline);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 180ms ease;
  word-break: break-word;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Portail ayants droit ---------- */

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0 8px; }
.step {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-card);
  padding: 18px;
}
.step .step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.step h3 { font-size: 14.5px; margin-bottom: 4px; }
.step p { font-size: 13px; color: var(--text-secondary); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--outline);
  }
  .admin-sidebar .brand { padding: 4px 10px; width: 100%; }
  .tab-btn { width: auto; }
  .sidebar-foot { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; flex-direction: row; align-items: center; }
  .admin-main { padding: 20px 16px 60px; }
  .steps { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .kv-grid dt { margin-top: 8px; }
}
