/* Shooorts — styles communs
   Concu ordinateur ET mobile en meme temps : chaque bloc porte ses regles
   pour petit ecran juste apres ses regles pour grand ecran. */

:root {
  --bg: #0F0D13;
  --surface: #1A1720;
  --surface-2: #241F2C;
  --border: #2E2838;

  --text: #FFFFFF;
  --muted: #A09AAB;

  --accent-from: #FF5E7A;
  --accent-to: #FF9457;
  --accent: #FF7A6B;
  --gradient: linear-gradient(135deg, var(--accent-from), var(--accent-to));

  --ok: #5BD98A;
  --warn: #FFC65E;

  --radius: 18px;
  --radius-sm: 12px;

  --header-h: 64px;
  --sidebar-w: 220px;
  /* Largeur du panneau de categories en mode mobile */
  --panel-w: 260px;
}

* { box-sizing: border-box; }

/* L'attribut hidden doit toujours masquer, meme sur un element en flex ou
   grid — dont le display l'emporterait sinon. Regle globale : evite d'avoir
   a le repeter pour chaque composant. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }

/* --- Logo ---------------------------------------------------------------- */

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

/* Pastille du logo : degrade corail + glyphe de lecture en SVG
   (injecte par js/icons.js, comme toutes les icones de l'interface). */
.logo-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #fff;
}

/* Le glyphe est dense : il lui faut plus de marge interne qu'un simple
   triangle pour rester lisible a cette taille. */
.logo-mark svg {
  width: 17px;
  height: 17px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* 44px minimum : taille de cible tactile confortable au doigt. */
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, border-color .15s, opacity .15s;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Les icones heritent de la couleur du bouton : aucun reglage par etat. */
.btn svg, .icon-btn svg, [data-icon] svg { display: block; flex: none; }
.btn svg { width: 17px; height: 17px; }
.btn-sm svg { width: 15px; height: 15px; }

/* Le degrade ne porte jamais de texte fin : uniquement des libelles en gras,
   sinon le contraste devient insuffisant. */
.btn-primary {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .85rem; }
.btn-danger { border-color: #6B2637; color: #FF8FA3; }
.btn-danger:hover:not(:disabled) { background: #33161F; border-color: #FF5E7A; }

/* --- Champs -------------------------------------------------------------- */

.field { display: block; margin-bottom: 16px; }

.field span {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  /* 16px minimum : en dessous, iOS zoome automatiquement sur le champ. */
  font-size: 16px;
  font-family: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input::placeholder { color: #6B6577; }

/* Champ mot de passe avec bouton d'affichage.
   Le bouton se pose dans le champ, qui reserve la place a droite. */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }

.pw-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 19px; height: 19px; }

/* --- Messages ------------------------------------------------------------ */

.msg {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  line-height: 1.45;
  margin-bottom: 16px;
}

.msg-error   { background: #33161F; color: #FF9FAF; }
.msg-ok      { background: #14301F; color: #7FE0A4; }
.msg-info    { background: var(--surface-2); color: var(--muted); }

/* --- Boites de dialogue -------------------------------------------------- */

.dlg-host { position: fixed; inset: 0; z-index: 100; }

.dlg-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .62);
}

.dlg {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  margin: 12vh auto 0;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
}

.dlg-title { margin: 0 0 8px; font-size: 1.08rem; }
.dlg-text { margin: 0 0 18px; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.dlg-field { margin-bottom: 18px; }

.dlg-actions { display: flex; gap: 10px; }
.dlg-actions .btn { flex: 1; }

@media (max-width: 480px) {
  .dlg { margin-top: 8vh; padding: 20px; }
  .dlg-actions { flex-direction: column-reverse; }
}

/* --- Accessibilite clavier ----------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
