/* ==========================================================================
   PaperTrade — THÈME (refonte visuelle complète, 16/09/2026)
   --------------------------------------------------------------------------
   Rôle : porter l'identité visuelle et la structure générale. Chargé APRÈS
   styles.css et refonte.css, il redéfinit les jetons (couleurs, surfaces,
   rayons, ombres, typographie) puis la charpente : barre latérale à gauche,
   en-tête, boutons, navigation, responsive.

   Direction : bleu électrique (primaire, action, navigation active), violet
   (accent), corail (alerte / baisse), vert (hausse), fond bleu-noir profond,
   surfaces différenciées, halos discrets, univers d'exploration.
   ========================================================================== */

/* --- 1. Jetons ------------------------------------------------------------ */
:root {
  /* Trois couleurs principales */
  --bleu: #3b82f6;            /* primaire : actions, liens, navigation active */
  --violet: #8b5cf6;          /* accent : éléments spéciaux, dégradés, focus */
  --corail: #ff6b6b;          /* alerte, négatif, action destructive douce */

  /* Trois couleurs complémentaires */
  --vert: #10b981;            /* performance positive */
  --clair: #e5e7eb;           /* texte principal, surfaces claires ponctuelles */
  --ardoise: #0f172a;         /* surfaces secondaires, fonds de panneaux */

  /* Déclinaisons */
  --bleu-clair: #60a5fa;
  --bleu-profond: #1d4ed8;
  --bleu-sombre: #1e3a8a;
  --violet-clair: #a78bfa;
  --corail-clair: #fca5a5;
  --vert-clair: #34d399;

  /* Fonds et surfaces (base bleu-noir, jamais de noir pur) */
  --fond: #070c18;
  --fond-2: #0a1120;
  --surface: #0f1728;
  --surface-2: #131d33;
  --surface-3: #1a2440;
  --surface-hover: #182340;
  --entete: rgba(10, 17, 32, .82);

  /* Texte */
  --texte: #e8edf7;
  --texte-dim: #9fb0c9;
  --texte-faible: #7d8da6;

  /* Lignes et ombres */
  --ligne: rgba(255, 255, 255, .07);
  --ligne-forte: rgba(255, 255, 255, .14);
  --ligne-bleue: rgba(59, 130, 246, .35);
  --ombre: 0 18px 40px -18px rgba(0, 0, 0, .85);
  --ombre-carte: 0 10px 30px -16px rgba(2, 8, 25, .9);
  --ombre-haute: 0 26px 60px -24px rgba(2, 8, 25, .95);
  --halo-bleu: 0 0 0 1px rgba(59, 130, 246, .35), 0 12px 34px -14px rgba(59, 130, 246, .45);
  --halo-violet: 0 0 0 1px rgba(139, 92, 246, .35), 0 12px 34px -14px rgba(139, 92, 246, .45);

  /* Dégradés d'identité */
  --degrade-primaire: linear-gradient(115deg, var(--bleu) 0%, var(--violet) 62%, var(--corail) 120%);
  --degrade-bleu-violet: linear-gradient(120deg, var(--bleu) 0%, var(--violet) 100%);
  --degrade-hero: linear-gradient(100deg, rgba(7, 12, 24, .96) 0%, rgba(11, 18, 38, .82) 45%, rgba(30, 27, 75, .55) 100%);
  --degrade-surface: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0));

  /* Formes */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Rythme */
  --e1: 4px; --e2: 8px; --e3: 12px; --e4: 16px; --e5: 24px; --e6: 32px; --e7: 48px;

  /* Typographie : Inter auto-hébergée (chargée par refonte.css) */
  --police: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --police-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --t-xs: 11.5px;
  --t-sm: 12.5px;
  --t-md: 14px;
  --t-lg: 16px;
  --t-xl: 21px;
  --t-2xl: 28px;
  --t-3xl: 40px;
  --t-hero: clamp(28px, 4.4vw, 46px);

  /* Mouvement */
  --trans: .18s cubic-bezier(.32, .72, .28, 1);
  --trans-lente: .32s cubic-bezier(.32, .72, .28, 1);

  /* Charpente */
  --rail: 258px;
  --rail-compact: 78px;
  --entete-h: 64px;
  --z-rail: 60;
  --z-entete: 50;
  --z-flottant: 200;
}

/* --- 2. Base -------------------------------------------------------------- */
html { background: var(--fond); }
body {
  margin: 0;
  font-family: var(--police);
  font-size: var(--t-md);
  color: var(--texte);
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(139, 92, 246, .17), transparent 62%),
    radial-gradient(900px 480px at 8% 4%, rgba(59, 130, 246, .14), transparent 60%),
    radial-gradient(760px 420px at 92% 82%, rgba(255, 107, 107, .07), transparent 65%),
    linear-gradient(180deg, var(--fond) 0%, var(--fond-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(59, 130, 246, .32); color: #fff; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: var(--r-xs); }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .16) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .24); background-clip: content-box; }

h1, h2, h3, h4 { font-family: var(--police); letter-spacing: -.02em; color: var(--texte); }
h1 { font-size: var(--t-xl); font-weight: 650; }
h2 { font-size: var(--t-lg); font-weight: 600; }
h3 { font-size: var(--t-md); font-weight: 600; }
a { color: var(--bleu-clair); text-decoration: none; }
a:hover { color: #fff; }
code, .mono, .num { font-variant-numeric: tabular-nums; }
hr { border: 0; border-top: 1px solid var(--ligne); margin: var(--e4) 0; }

/* --- 3. Charpente : rail latéral + colonne principale ---------------------- */
body { display: block; }
.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}
.app-col { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
#view { flex: 1 0 auto; width: 100%; max-width: 1560px; margin: 0 auto; padding: var(--e5) var(--e6) var(--e7); }

/* --- 4. Rail de navigation (bureau) --------------------------------------- */
.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh; z-index: var(--z-rail);
  display: flex; flex-direction: column; gap: var(--e4);
  padding: var(--e5) var(--e3) var(--e4);
  background: linear-gradient(180deg, rgba(15, 23, 40, .92), rgba(10, 17, 32, .92));
  border-right: 1px solid var(--ligne);
  backdrop-filter: blur(12px);
  overflow-y: auto;
}
.rail-marque { display: flex; align-items: center; gap: 10px; padding: 0 var(--e2) var(--e4); }
.rail-marque .embleme { width: 34px; height: 34px; flex: 0 0 auto; }
.rail-marque .nom { font-size: 17px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
.rail-marque .nom span { color: var(--violet-clair); }

.rail-groupe { display: flex; flex-direction: column; gap: 2px; }
.rail-titre {
  padding: var(--e3) var(--e3) var(--e1);
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--texte-faible);
}
.rail-separateur { height: 1px; background: var(--ligne); margin: var(--e2) var(--e3); }

.rail-item {
  position: relative; display: flex; align-items: center; gap: var(--e3);
  padding: 10px var(--e3); min-height: 44px;
  border-radius: var(--r-sm); color: var(--texte-dim);
  font-size: var(--t-md); font-weight: 500;
  transition: color var(--trans), background var(--trans);
}
.rail-item .ico { flex: 0 0 auto; display: inline-flex; color: currentColor; opacity: .85; }
.rail-item .libelle { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item:hover { color: var(--texte); background: rgba(255, 255, 255, .05); }
.rail-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(59, 130, 246, .26), rgba(139, 92, 246, .16));
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, .38);
}
.rail-item.active .ico { opacity: 1; color: var(--bleu-clair); }
.rail-item.active::before {
  content: ""; position: absolute; left: -12px; top: 12px; bottom: 12px; width: 3px;
  border-radius: var(--r-pill); background: var(--degrade-bleu-violet);
}
.rail-item .nav-count {
  flex: 0 0 auto; min-width: 20px; text-align: center;
  padding: 1px 6px; border-radius: var(--r-pill);
  background: rgba(59, 130, 246, .18); color: var(--bleu-clair);
  font-size: var(--t-xs); font-weight: 600;
}
.rail-pied { margin-top: auto; padding: var(--e3) var(--e2) 0; border-top: 1px solid var(--ligne); }
.rail-pied .rail-item { padding-left: var(--e2); }

/* --- 5. En-tête ----------------------------------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: var(--z-entete);
  display: flex; align-items: center; gap: var(--e3);
  min-height: var(--entete-h); padding: 10px var(--e6);
  background: var(--entete);
  border-bottom: 1px solid var(--ligne);
  backdrop-filter: blur(14px);
}
.appbar .brand { display: none; }        /* la marque vit dans le rail */
.appbar .search { order: 1; flex: 1 1 420px; max-width: 620px; }
.appbar-right { order: 2; margin-left: auto; display: flex; align-items: center; gap: var(--e2); }
.appbar .icon-btn { width: 40px; height: 40px; border-radius: var(--r-sm); }

.search { position: relative; display: flex; align-items: center; }
.search .search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--texte-faible); font-size: 15px; pointer-events: none;
}
.search input[type="search"] {
  width: 100%; height: 42px; padding: 0 84px 0 40px;
  border-radius: var(--r-pill); border: 1px solid var(--ligne);
  background: rgba(255, 255, 255, .04); color: var(--texte);
  font-size: var(--t-md); font-family: var(--police);
}
.search input[type="search"]::placeholder { color: var(--texte-faible); }
.search input[type="search"]:focus {
  border-color: var(--ligne-bleue); background: rgba(59, 130, 246, .08); outline: none;
  box-shadow: var(--halo-bleu);
}
.search .raccourci {
  position: absolute; right: 12px; display: inline-flex; gap: 4px; align-items: center;
  font-size: var(--t-xs); color: var(--texte-faible);
}
.search .raccourci kbd {
  font-family: var(--police); padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--ligne-forte); background: rgba(255, 255, 255, .05);
}
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: var(--z-flottant);
  max-height: 60vh; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--ligne-forte);
  border-radius: var(--r); box-shadow: var(--ombre-haute);
}
.search-results .sr-item { display: flex; align-items: center; gap: var(--e3); padding: 10px 12px; border-radius: var(--r-sm); }
.search-results .sr-item:hover { background: rgba(59, 130, 246, .12); }

/* --- 6. Boutons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
  min-height: 42px; padding: 0 18px;
  border-radius: var(--r-sm); border: 1px solid var(--ligne-forte);
  background: rgba(255, 255, 255, .04); color: var(--texte);
  font-family: var(--police); font-size: var(--t-md); font-weight: 550;
  cursor: pointer; transition: transform var(--trans), box-shadow var(--trans), background var(--trans), border-color var(--trans);
  text-decoration: none;
}
.btn:hover { background: rgba(255, 255, 255, .08); border-color: var(--ligne-forte); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  border-color: transparent; color: #fff;
  background: var(--degrade-bleu-violet);
  box-shadow: 0 10px 26px -12px rgba(59, 130, 246, .75);
}
.btn.primary:hover { background: linear-gradient(120deg, var(--bleu-clair) 0%, var(--violet-clair) 100%); }
.btn.secondary { border-color: var(--ligne-bleue); background: rgba(59, 130, 246, .12); color: var(--bleu-clair); }
.btn.ghost { background: transparent; border-color: var(--ligne); color: var(--texte-dim); }
.btn.ghost:hover { color: var(--texte); border-color: var(--ligne-forte); }
.btn.danger { border-color: rgba(255, 107, 107, .45); background: rgba(255, 107, 107, .12); color: var(--corail-clair); }
.btn.danger:hover { background: rgba(255, 107, 107, .2); }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: tourne .7s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }
.btn.small { min-height: 36px; padding: 0 12px; font-size: var(--t-sm); }
.btn.large { min-height: 48px; padding: 0 24px; font-size: var(--t-lg); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--ligne); background: rgba(255, 255, 255, .04);
  color: var(--texte-dim); cursor: pointer; transition: all var(--trans);
}
.icon-btn:hover { color: #fff; border-color: var(--ligne-bleue); background: rgba(59, 130, 246, .12); }
.star-btn { border-radius: var(--r-sm); border: 1px solid var(--ligne); background: rgba(255, 255, 255, .04); color: var(--texte-faible); cursor: pointer; transition: all var(--trans); }
.star-btn.on { color: var(--violet-clair); border-color: rgba(139, 92, 246, .45); background: rgba(139, 92, 246, .14); }

/* --- 7. Navigation basse (mobile) ---------------------------------------- */
.bottomnav { display: none; }

/* --- 8. Responsive de la charpente --------------------------------------- */
/* Tablette : rail compact (icônes + libellés courts) */
@media (max-width: 1180px) {
  :root { --rail: var(--rail-compact); }
  .rail-marque .nom, .rail-item .libelle, .rail-titre { display: none; }
  .rail-item { justify-content: center; padding: 12px 0; }
  .rail-marque { justify-content: center; padding-bottom: var(--e3); }
  .rail-separateur { margin: var(--e2) var(--e2); }
  #view { padding: var(--e4) var(--e5) var(--e6); }
  .appbar { padding: 10px var(--e5); }
}
/* Mobile : plus de rail, navigation basse */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .appbar { flex-wrap: wrap; row-gap: var(--e2); padding: 8px 12px; min-height: 0; }
  .appbar .brand { display: inline-flex; order: 0; }
  .appbar .search { order: 3; flex-basis: 100%; max-width: none; }
  #view { padding: 12px 12px calc(76px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-rail);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-top: 1px solid var(--ligne-forte); backdrop-filter: blur(14px);
  }
  .bottomnav a, .bottomnav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 58px; font-size: var(--t-xs); color: var(--texte-dim);
    text-decoration: none; background: none; border: 0; font-family: var(--police);
    border-top: 2px solid transparent;
  }
  .bottomnav .bn-ico { font-size: 19px; line-height: 1; display: inline-flex; }
  .bottomnav a.active, .bottomnav button.active {
    color: #fff; border-top-color: var(--bleu);
    background: linear-gradient(180deg, rgba(59, 130, 246, .18), transparent);
  }
  .plus-sheet {
    position: fixed; z-index: calc(var(--z-rail) + 1); right: 10px; left: 10px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    display: flex; flex-direction: column; padding: 8px;
    background: var(--surface); border: 1px solid var(--ligne-forte);
    border-radius: var(--r-lg); box-shadow: var(--ombre-haute);
  }
  .plus-sheet .acc-item { min-height: 48px; display: flex; align-items: center; gap: var(--e3); border-radius: var(--r-sm); padding: 0 10px; }
  .plus-sheet .acc-item:hover { background: rgba(59, 130, 246, .12); }
}

/* Respect du mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
