/* ==========================================================================
   Legend Story Team — Design System
   components.css — Partagé par toutes les pages

   Requiert design-tokens.css chargé avant (source de vérité unique)
   ========================================================================== */

/* ── Alias courts (rétrocompatibilité interne) ────────────────────────── */
:root {
  /* Fond & surface */
  --bg:        var(--color-background);
  --surface:   var(--color-surface);
  --hover:     var(--color-surface-hover);
  --active-bg: var(--color-surface-active);

  /* Bordures */
  --border:    var(--color-border);
  --border-s:  var(--color-border-subtle);

  /* Texte */
  --t1: var(--color-foreground);
  --t2: var(--color-foreground-2);
  --t3: var(--color-foreground-3);
  --t4: var(--color-foreground-4);

  /* Brand */
  --green:       var(--color-primary);
  --green-h:     var(--color-primary-hover);
  --green-bg:    var(--color-primary-bg);
  --green-light: var(--color-primary-light);

  /* Statuts */
  --ok:    var(--color-success);
  --ok-bg: var(--color-success-bg);
  --ko:    var(--color-error);
  --ko-bg: var(--color-error-bg);

  /* Rayon */
  --r-sm: var(--radius-sm);
  --r-md: var(--radius-md);
  --r-lg: var(--radius-lg);
  --r-xl: var(--radius-xl);

  /* Ombre */
  /* --shadow-sm/md/lg sont déjà fournis par design-tokens.css */

  /* Layout */
  --topbar-h: var(--topbar-height);
}

/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--t1);
}

/* ── Focus ────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration:  0.01ms !important;
  }
  .skeleton { animation: none !important; background: var(--skeleton-color-from) !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════════════════════════════════ */

/* ── Top bar ──────────────────────────────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
}

.top-bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── Page content ─────────────────────────────────────────────────────── */
.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px;
}

/* ── Loading overlay ──────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
}

.loading-overlay p {
  font-size: 12px;
  color: var(--t4);
  letter-spacing: 0.06em;
}

/* ════════════════════════════════════════════════════════════════════════
   BOUTONS
   ════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 36px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
  text-decoration: none;
}

.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

/* Primaire */
.btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-primary:hover:not(:disabled) { background: var(--green-h); border-color: var(--green-h); }

/* Secondaire */
.btn-secondary {
  background: var(--surface);
  color: var(--t2);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: #aaa; color: var(--t1); }

/* Danger */
.btn-danger {
  background: var(--ko-bg);
  color: var(--ko);
  border-color: transparent;
}
.btn-danger:hover:not(:disabled) { background: var(--color-error-hover); }

/* Icône seul */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--t4);
  border-color: var(--border);
  min-height: unset;
}
.btn-icon:hover { border-color: #bbb; color: var(--t2); }

/* Pleine largeur */
.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════════════
   FORMULAIRES
   ════════════════════════════════════════════════════════════════════════ */

.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t4);
  margin-bottom: 6px;
}

.form-label .opt {
  color: var(--t4);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  border: 0.5px solid #e0e0de;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--t1);
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--t4); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: #888; }

.form-select {
  appearance: none;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Select custom wrapper */
.select-wrap {
  position: relative;
}
.select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--t4);
  pointer-events: none;
}

/* Message d'erreur inline */
.form-error {
  font-size: 11px;
  color: var(--ko);
  background: var(--ko-bg);
  border-radius: var(--r-md);
  padding: 9px 12px;
  margin-top: 8px;
  line-height: 1.5;
  display: none;
}
.form-error.visible { display: block; }

/* Message de succès inline */
.form-success {
  font-size: 11px;
  color: var(--ok);
  background: var(--ok-bg);
  border-radius: var(--r-md);
  padding: 9px 12px;
  margin-top: 8px;
  line-height: 1.5;
  display: none;
}
.form-success.visible { display: block; }

/* ════════════════════════════════════════════════════════════════════════
   CARTE
   ════════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}

.card-padded {
  padding: 24px 28px;
}

/* ════════════════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 28px 30px;
  width: min(500px, 100%);
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 22px;
}

/* Fermeture modal au clic sur l'overlay */
.modal-overlay[data-dismiss="overlay"] { cursor: pointer; }
.modal-overlay[data-dismiss="overlay"] .modal { cursor: default; }

/* ════════════════════════════════════════════════════════════════════════
   SKELETON / CHARGEMENT
   ════════════════════════════════════════════════════════════════════════ */

.skeleton {
  background: linear-gradient(90deg, #f0f0ee 25%, #e8e8e6 50%, #f0f0ee 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--r-md);
}

@keyframes skeleton-shimmer {
  to { background-position: -200% 0; }
}

/* ════════════════════════════════════════════════════════════════════════
   ÉTATS VIDES
   ════════════════════════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--t4);
  font-size: 13px;
  line-height: 1.6;
}

.empty-state svg {
  display: block;
  margin: 0 auto 16px;
  opacity: 0.3;
}

/* ════════════════════════════════════════════════════════════════════════
   BADGE
   ════════════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-green  { background: var(--green-light); color: var(--green); }
.badge-muted  { background: var(--active-bg);   color: var(--t3);   }
.badge-error  { background: var(--ko-bg);        color: var(--ko);   }
.badge-white  { background: rgba(255,255,255,0.2); color: #fff;      }

/* ════════════════════════════════════════════════════════════════════════
   BOUTONS BOUTIQUE (sélection multi-choix)
   ════════════════════════════════════════════════════════════════════════ */

.boutique-row {
  display: flex;
  gap: 8px;
}

.btn-boutique {
  flex: 1;
  padding: 10px;
  border: 0.5px solid var(--border);
  background: var(--surface);
  color: var(--t3);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--r-md);
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-height: 40px;
}
.btn-boutique:hover  { border-color: #aaa; color: var(--t2); }
.btn-boutique.active { border-color: var(--green); color: var(--green); background: var(--green-bg); font-weight: 500; }

/* ════════════════════════════════════════════════════════════════════════
   ZONE DE DÉPÔT (upload)
   ════════════════════════════════════════════════════════════════════════ */

.drop-zone {
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fafaf8;
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag     { border-color: var(--green); background: var(--green-bg); }
.drop-zone.filled   { border-style: solid; border-color: var(--green); }
.drop-zone input[type="file"] { display: none; }

.drop-zone-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  color: var(--t4);
}

.drop-zone.filled .drop-zone-icon { color: var(--green); }

.drop-hint {
  font-size: 12px;
  color: var(--t4);
  line-height: 1.55;
}

.drop-hint b { color: var(--t3); font-weight: 500; }

.drop-filename {
  font-size: 12px;
  color: var(--t2);
  margin-top: 4px;
  word-break: break-all;
}

/* ════════════════════════════════════════════════════════════════════════
   UTILITAIRES
   ════════════════════════════════════════════════════════════════════════ */

.text-muted   { color: var(--t4); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.text-ok      { color: var(--ok); }
.text-ko      { color: var(--ko); }
.text-green   { color: var(--green); }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.mt-auto      { margin-top: auto; }

/* Séparateur */
.divider {
  height: 1px;
  background: var(--border-s);
  margin: 0;
}

/* Responsive — sidebar pages */
@media (max-width: 768px) {
  .top-bar  { padding: 0 16px; }
  .page-content { padding: 16px; }
  .modal { padding: 22px 20px; }
}
