/* Entosya — Design tokens (client beta).
   Source unique de vérité pour couleurs, rayons, ombres, typographie et
   primitives d'UI partagées entre pages publiques et workspace connecté.
   NE PAS forker : toute nouvelle surface (settings, connections, imports)
   doit inclure ce fichier et consommer les variables exposées ici. */

:root {
  /* ── Couleurs de fond ─────────────────────────────── */
  --bg:              #f8f9fc;
  --bg-elev:         #ffffff;
  --bg-card:         #ffffff;
  --bg-subtle:       #f1f4fb;
  --bg-hover:        rgba(99, 102, 241, 0.06);
  --overlay:         rgba(15, 23, 42, 0.45);

  /* ── Bords ─────────────────────────────────────────── */
  --border:          #e8ecf4;
  --border-strong:   #d9deea;
  --border-focus:    #6366f1;

  /* ── Texte ─────────────────────────────────────────── */
  --text:            #0f172a;
  --text-body:       #1e293b;
  --text-dim:        #64748b;
  --text-light:      #94a3b8;
  --text-invert:     #ffffff;

  /* ── Marque ─────────────────────────────────────────── */
  --brand:           #6366f1;   /* Primary — Indigo Entosya. Utilisée
                                    partout dans le workspace + auth. */
  --brand-strong:    #4f46e5;
  --brand-soft:      rgba(99, 102, 241, 0.08);
  --brand-softer:    rgba(99, 102, 241, 0.04);
  --brand-accent:    #8b5cf6;   /* Secondary purple pour les dégradés. */

  /* Alias historiques (à ne pas casser). --primary + --primary-light sont
     utilisés dans base.html + de nombreux templates. */
  --primary:         var(--brand);
  --primary-light:   var(--brand-soft);
  --primary-strong:  var(--brand-strong);

  /* ── Sémantique ─────────────────────────────────────── */
  --success:         #22c55e;
  --success-soft:    rgba(34, 197, 94, 0.10);
  --success-border:  rgba(34, 197, 94, 0.22);
  --warning:         #f59e0b;
  --warning-soft:    rgba(245, 158, 11, 0.10);
  --warning-border:  rgba(245, 158, 11, 0.22);
  --danger:          #ef4444;
  --danger-soft:     rgba(239, 68, 68, 0.06);
  --danger-border:   rgba(239, 68, 68, 0.22);
  --info:            #3b82f6;
  --info-soft:       rgba(59, 130, 246, 0.08);

  /* ── Rayons ─────────────────────────────────────────── */
  --r-xs:            6px;
  --r-sm:            8px;
  --r-md:            10px;
  --r-lg:            12px;
  --r-xl:            14px;
  --r-2xl:           18px;
  --r-pill:          999px;
  --radius:          var(--r-xl);       /* alias historique */

  /* ── Ombres ─────────────────────────────────────────── */
  --shadow-xs:       0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:       0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md:       0 4px 16px rgba(99, 102, 241, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg:       0 12px 32px rgba(99, 102, 241, 0.10), 0 4px 8px rgba(15, 23, 42, 0.04);
  --shadow-brand:    0 8px 24px rgba(99, 102, 241, 0.25);
  --shadow:          var(--shadow-md);   /* alias historique */

  /* ── Espacement ──────────────────────────────────────── */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

  /* ── Typographie ─────────────────────────────────────── */
  --font-sans:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs-xs:           11px;
  --fs-sm:           12px;
  --fs-base:         13.5px;
  --fs-md:           14px;
  --fs-lg:           16px;
  --fs-xl:           19px;
  --fs-2xl:          22px;
  --fs-3xl:          28px;
  --lh-tight:        1.25;
  --lh-body:         1.55;

  /* ── Motions ─────────────────────────────────────────── */
  --ease-out:        cubic-bezier(.4, 0, .2, 1);
  --dur-fast:        .12s;
  --dur-base:        .18s;

  /* ── Layout ─────────────────────────────────────────── */
  --sidebar-w:       240px;
  --focus-ring:      0 0 0 3px rgba(99, 102, 241, 0.18);
  --focus-outline:   2px solid var(--brand);

  /* ── Tap targets ─────────────────────────────────────── */
  --tap-min:         44px;
}

/* ─────────────────────────────────────────────────────────────
   PRIMITIVES — Réutilisables sur toutes les surfaces.
   Nommage `ds-*` (design-system) pour éviter les collisions.
   ───────────────────────────────────────────────────────────── */

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 11px 20px;
  border-radius: var(--r-lg);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              background-color var(--dur-base) var(--ease-out);
  /* Autorise le retour à la ligne du label sur écrans étroits ; conserve
     l'intégrité tactile via min-height + padding. */
  white-space: normal;
  text-align: center;
  max-width: 100%;
}
.ds-btn:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }
.ds-btn:disabled { opacity: .55; cursor: not-allowed; }
.ds-btn i { font-size: 16px; }

.ds-btn--primary {
  background: var(--brand);
  color: var(--text-invert);
}
.ds-btn--primary:hover:not(:disabled) {
  background: var(--brand-strong);
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}
.ds-btn--primary:active:not(:disabled) { transform: translateY(0); }

.ds-btn--secondary {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
}
.ds-btn--secondary:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-softer);
}

.ds-btn--ghost {
  background: transparent;
  color: var(--brand);
}
.ds-btn--ghost:hover:not(:disabled) { background: var(--brand-soft); }

.ds-btn--danger {
  background: var(--bg-elev);
  color: #b91c1c;
  border-color: var(--danger-border);
}
.ds-btn--danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.ds-btn--sm { min-height: 36px; padding: 8px 14px; font-size: var(--fs-sm); }
.ds-btn--block { width: 100%; }

/* ── Card ──────────────────────────────────────────────── */
.ds-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.ds-card--elevated {
  box-shadow: var(--shadow-md);
}
.ds-card--interactive {
  cursor: pointer;
  transition: box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.ds-card--interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

/* ── Badge / chip ──────────────────────────────────────── */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  border: 1px solid transparent;
  line-height: 1.4;
}
.ds-badge--ok      { background: var(--success-soft); color: #15803d; border-color: var(--success-border); }
.ds-badge--warn    { background: var(--warning-soft); color: #b45309; border-color: var(--warning-border); }
.ds-badge--danger  { background: var(--danger-soft);  color: #b91c1c; border-color: var(--danger-border); }
.ds-badge--info    { background: var(--info-soft);    color: #1d4ed8; border-color: rgba(59,130,246,.22); }
.ds-badge--neutral { background: var(--bg-subtle);    color: var(--text-dim); border-color: var(--border); }
.ds-badge--brand   { background: var(--brand-soft);   color: var(--brand-strong); border-color: rgba(99,102,241,.22); }
.ds-badge i        { font-size: 11px; }

/* ── Field (input / textarea / select) ───────────────── */
.ds-field { display: flex; flex-direction: column; gap: 6px; }
.ds-field label {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .4px;
}
.ds-field input,
.ds-field textarea,
.ds-field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  font-family: var(--font-sans);
  font-size: 16px; /* évite le zoom iOS */
  color: var(--text);
  background: var(--bg-card);
  outline: none;
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow  var(--dur-base) var(--ease-out);
}
.ds-field input:focus,
.ds-field textarea:focus,
.ds-field select:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.ds-field-hint { font-size: var(--fs-sm); color: var(--text-light); line-height: 1.5; }
.ds-field-error {
  font-size: var(--fs-sm); color: #b91c1c;
  background: var(--danger-soft); border: 1px solid var(--danger-border);
  padding: 8px 12px; border-radius: var(--r-md);
}

/* ── Empty state ───────────────────────────────────────
   Pattern uniforme sur toutes les listes / boards / vues :
     .ds-empty
       .ds-empty-icon
       h3
       p
       .ds-empty-actions > .ds-btn
   Utilisé sur : /notes, /agenda, /nex, /actions (empty),
   /projets (empty), pricing (aucune offre), /account (aucun
   abonnement), et à venir sur /settings/connections, /imports. */
.ds-empty {
  max-width: 520px;
  margin: 32px auto;
  padding: 36px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.ds-empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto var(--sp-4);
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--brand-soft), rgba(139,92,246,.10));
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  border: 1px solid rgba(99,102,241,.16);
}
.ds-empty h3 {
  margin: 0 0 6px;
  font-size: var(--fs-xl); font-weight: 700; color: var(--text);
}
.ds-empty p {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-md); color: var(--text-dim); line-height: var(--lh-body);
}
.ds-empty-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center;
}
@media (max-width: 480px) {
  .ds-empty { margin: 20px 8px; padding: 28px 20px; border-radius: var(--r-xl); }
  .ds-empty-icon { width: 56px; height: 56px; font-size: 24px; }
  .ds-empty h3 { font-size: 17px; }
  .ds-empty-actions { flex-direction: column; align-items: stretch; }
  .ds-empty-actions .ds-btn { width: 100%; }
}

/* ── Section header ────────────────────────────────────── */
.ds-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.ds-section-head h2 {
  font-size: var(--fs-2xl); font-weight: 800; color: var(--text);
  letter-spacing: -0.3px; line-height: 1.2;
}
.ds-section-head p {
  font-size: var(--fs-md); color: var(--text-dim); margin-top: 2px;
}
.ds-kicker {
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-light);
  text-transform: uppercase; letter-spacing: 1.2px;
}

/* ── Notice / bannière informationnelle ─────────────────
   Utilisable comme rappel de statut trial, ou pour les futures
   surfaces /connections (statut oauth) et /imports (état d'import). */
.ds-notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: var(--fs-md); color: var(--text-body); line-height: 1.5;
}
.ds-notice i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.ds-notice--info   { background: var(--info-soft);    border-color: rgba(59,130,246,.22); color: #1e40af; }
.ds-notice--brand  { background: var(--brand-soft);   border-color: rgba(99,102,241,.20); color: var(--brand-strong); }
.ds-notice--ok     { background: var(--success-soft); border-color: var(--success-border); color: #14532d; }
.ds-notice--warn   { background: var(--warning-soft); border-color: var(--warning-border); color: #78350f; }
.ds-notice--danger { background: var(--danger-soft);  border-color: var(--danger-border); color: #7f1d1d; }

/* ── Skeleton (loading) ────────────────────────────────── */
.ds-skeleton {
  display: block;
  background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--bg-elev) 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-md);
  height: 14px;
  animation: ds-shimmer 1.4s var(--ease-out) infinite;
}
.ds-skeleton--tall { height: 40px; }
.ds-skeleton--card { height: 96px; border-radius: var(--r-xl); }
@keyframes ds-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── List row (utilisé pour connections, imports, historique
   futur — chaque item = ligne cliquable avec icône, titre, sous-titre,
   badge de statut et actions à droite). ─────────────────── */
.ds-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--r-xl);
  overflow: hidden; background: var(--bg-card);
}
.ds-list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background-color var(--dur-fast) var(--ease-out);
}
.ds-list-row:last-child { border-bottom: none; }
.ds-list-row:hover { background: var(--bg-hover); }
.ds-list-row-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.ds-list-row-body { flex: 1; min-width: 0; }
.ds-list-row-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.ds-list-row-sub { font-size: var(--fs-sm); color: var(--text-dim); margin-top: 2px; overflow-wrap: anywhere; }
.ds-list-row-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
@media (max-width: 560px) {
  .ds-list-row { padding: 12px 14px; gap: 10px; }
  .ds-list-row-actions { flex-direction: column; align-items: stretch; }
}

/* ── Accessibilité — reduced motion ───────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ds-btn, .ds-card--interactive, .ds-skeleton,
  .ds-list-row, .ds-field input, .ds-field textarea, .ds-field select {
    animation: none !important;
    transition: none !important;
  }
}
