/* ============================================================
   Éditeur de données ESH Médias — thème partagé
   Basé sur la maquette "Claude Design" (design system Le
   Nouvelliste), recoloré à la marque ESH Médias (rouge #931F38,
   extrait du logo). Police Libre Franklin auto-hébergée (pas de
   dépendance réseau externe).
   ============================================================ */

@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/libre-franklin-variable.woff2') format('woff2');
}

:root {
  /* --- Rouge ESH Médias (primaire) --- */
  --red-50:  #F7EDEF;
  --red-100: #EBD2D8;
  --red-500: #A82340;
  --red-600: #931F38;   /* rouge de marque, extrait du logo */
  --red-700: #7A182E;
  --red-800: #5E1224;

  /* --- Encre & neutres --- */
  --black:    #000000;
  --ink:      #16181D;
  --ink-2:    #3B3F47;
  --gray-600: #6B6F76;
  --gray-500: #8A8E95;
  --gray-400: #B6B8BD;
  --gray-300: #D9D9D7;
  --gray-200: #E6E6E3;
  --gray-100: #F0F0EE;
  --gray-50:  #F6F6F4;
  --white:    #FFFFFF;

  /* --- Barre latérale (surface sombre) --- */
  --sidebar-bg:          #14181E;
  --sidebar-border:      rgba(255,255,255,0.10);
  --sidebar-text:        rgba(255,255,255,0.72);
  --sidebar-text-strong: #FFFFFF;
  --sidebar-text-muted:  rgba(255,255,255,0.45);
  --sidebar-hover:       rgba(255,255,255,0.07);
  --sidebar-active:      rgba(255,255,255,0.12);
  --accent-on-dark:      #E2879A;

  /* --- Alias sémantiques --- */
  --color-bg:       var(--white);
  --color-bg-alt:   var(--gray-50);
  --surface-card:   var(--white);

  --text-strong:    var(--ink);
  --text-body:      var(--ink);
  --text-secondary: var(--ink-2);
  --text-muted:     var(--gray-600);

  --accent:         var(--red-600);
  --accent-hover:   var(--red-700);
  --accent-tint:    var(--red-50);

  --border:         var(--gray-200);
  --border-strong:  var(--gray-300);
  --focus-ring:     var(--red-600);

  --danger:         var(--red-600);
  --danger-border:  var(--red-100);
  --danger-bg-hover: var(--red-50);

  --ok:        #1F7A4D;
  --ok-bg:     #E9F5EE;
  --ok-border: #BFE3CE;
  --warn:      #8A5A00;
  --warn-bg:   #FFF4E5;
  --warn-border: #FFD8A8;

  --font-ui: 'Libre Franklin', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
}

/* --- Reset & éléments de base ------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text-body);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
input, select, button, textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus-ring); outline-offset: -1px;
}
input:disabled, select:disabled {
  background: var(--gray-50); border-color: var(--border); color: var(--ink-2); opacity: 1;
}

/* --- Coquille de page : barre latérale + contenu ------------------------ */
.app-shell { min-height: 100vh; display: flex; background: var(--white); }

.sidebar {
  width: 248px; flex: 0 0 248px; align-self: stretch; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: #fff;
}
.sidebar-brand {
  padding: 20px 20px 18px; display: flex; flex-direction: column; gap: 3px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo {
  font-weight: 900; font-size: 21px; letter-spacing: -0.03em; color: #fff;
  display: inline-flex;
}
.sidebar-logo span { color: var(--accent-on-dark); }
.sidebar-logo:hover { color: #fff; }
.sidebar-kicker {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--sidebar-text-muted);
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 22px; padding: 18px 12px; overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  padding: 0 12px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.10em;
  font-weight: 700; color: var(--sidebar-text-muted);
}
.nav-item {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 10px;
  background: transparent; color: var(--sidebar-text); border: 0; border-radius: 7px;
  padding: 10px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active); color: #fff; font-weight: 700;
}
.nav-item.active.nav-item--sub { border-left: 3px solid var(--accent-on-dark); }
.sidebar-user {
  border-top: 1px solid var(--sidebar-border); padding: 14px 16px;
  display: flex; align-items: center; gap: 11px;
}
.sidebar-avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--red-600); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 12.5px; font-weight: 800; letter-spacing: 0.02em;
}
.sidebar-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user-name {
  font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: #fff;
}
.sidebar-user-role { font-size: 11.5px; color: var(--sidebar-text-muted); }
.sidebar-logout {
  background: transparent; border: 1px solid rgba(255,255,255,0.18); border-radius: 6px;
  color: rgba(255,255,255,0.7); font-size: 11px; font-weight: 700; padding: 6px 8px;
  cursor: pointer; text-decoration: none; display: inline-flex;
}
.sidebar-logout:hover { background: rgba(255,255,255,0.10); color: #fff; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 16px 28px;
  border-bottom: 2px solid var(--ink); background: var(--white); flex-wrap: wrap;
}
.topbar-title { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.topbar-spacer { flex: 1; }
.topbar-meta { font-size: 13px; color: var(--gray-600); }
.main-content { flex: 1; padding: 32px 28px; background: var(--color-bg-alt); }
.app-footer {
  padding: 16px; text-align: center; font-size: 12.5px; color: var(--gray-500);
  border-top: 1px solid var(--border); background: var(--white);
}
.app-footer a { color: var(--accent); text-decoration: none; }

/* --- Boutons -------------------------------------------------------------- */
.btn {
  font: inherit; border: 1px solid var(--border-strong); background: var(--white);
  color: var(--ink); border-radius: var(--radius-sm); padding: 10px 18px;
  font-size: 14px; font-weight: 700; cursor: pointer; transition: .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--ink); background: var(--gray-100); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--white); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg-hover); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--gray-600); }
.btn-ghost:hover { color: var(--ink); background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.spin {
  display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite;
  vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Barre de chargement globale (affichée automatiquement pendant les
   appels réseau — voir static/ui-utils.js) ---------------------------------- */
#global-loading-bar {
  position: fixed; top: 0; left: 0; width: 100%; height: 3px;
  z-index: 9999; pointer-events: none; background: transparent;
}
#global-loading-bar.show {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 55% 100%; background-repeat: no-repeat;
  animation: loading-bar-slide 1.1s linear infinite;
}
@keyframes loading-bar-slide {
  0%   { background-position: -55% 0; }
  100% { background-position: 155% 0; }
}
button:disabled .spin, .btn:disabled .spin { border-color: currentColor; border-right-color: transparent; }

/* --- Cartes / panneaux ----------------------------------------------------- */
.card {
  background: var(--surface-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px 22px;
}

/* --- Badges & chips --------------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: var(--radius-sm);
  font-weight: 700; letter-spacing: 0.02em;
}
.badge-accent { background: var(--red-50); color: var(--red-600); }
.badge-muted  { background: var(--gray-100); color: var(--gray-600); }
.badge-off    { background: var(--red-50); color: var(--red-600); }
.badge-warn   { background: var(--warn-bg); color: var(--warn); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--gray-100);
  border-radius: var(--radius-sm); padding: 4px 9px; font-size: 12px; color: var(--ink-2);
}

/* --- Formulaires ------------------------------------------------------------ */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px;
}
.field label .type { font-family: var(--mono); font-size: 10.5px; color: var(--gray-500); }
.field label .req { color: var(--danger); }
input[type=text], input[type=number], input[type=date], input[type=datetime-local],
input[type=time], input[type=email], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; background: var(--white); color: var(--ink);
}

/* --- Tableaux simples (admin, journal) -------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--gray-600); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.data-table .mono { font-family: var(--mono); font-size: 11.5px; color: var(--gray-600); }

.hint { color: var(--gray-600); font-size: 12.5px; }
.section-kicker {
  display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--ink); padding-bottom: 8px;
}
.section-kicker .label {
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; font-size: 11px; color: var(--red-600);
}
