/* ===========================================================================
   japp-pages.css — extensions au CSS de /overview (refonte validée)
   Les tokens :root sont ceux de la maquette /overview : ne pas les redéfinir,
   ce fichier suppose qu'ils sont déjà chargés (base.html).
   =========================================================================== */

/* --- Couleur par catégorie : classe unique appliquée partout ---------------
   Le backend rend  class="cat cat--{{ tx.category_slug }}"  et le CSS fait
   le reste. Slugs attendus : transport, alimentation, abonnements, sante,
   loisirs, logement, uncategorized.                                        */
.cat { --c: var(--cat-uncategorized); }
.cat--transport      { --c: var(--cat-transport); }
.cat--alimentation   { --c: var(--cat-alimentation); }
.cat--abonnements    { --c: var(--cat-abonnements); }
.cat--sante          { --c: var(--cat-sante); }
.cat--loisirs        { --c: var(--cat-loisirs); }
.cat--logement       { --c: var(--cat-logement); }
.cat--uncategorized  { --c: var(--cat-uncategorized); }

.cat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }

.cat-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}

/* Select de catégorie : même pilule, en contrôle de formulaire */
.cat-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 26px 5px 11px;
  border-radius: 100px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.cat-select-wrap { position: relative; display: inline-flex; align-items: center; }
.cat-select-wrap::after {
  content: "▾";
  position: absolute;
  right: 10px;
  font-size: 8px;
  pointer-events: none;
  opacity: 0.75;
  color: var(--c);
}
.cat-select option { background: var(--surface); color: var(--text); }

/* --- Tableaux (grille CSS, pas de <table>) ---------------------------------
   Chaque page définit --cols ; .t-scroll gère le débordement mobile.        */
.t-scroll { overflow-x: auto; }
.t-scroll > * { min-width: var(--t-min, 640px); }

.t-head, .t-row, .t-foot {
  display: grid;
  grid-template-columns: var(--cols);
  align-items: center;
  gap: 16px;
}
.t-head {
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
}
.t-head > * {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.t-row {
  padding: 12px 4px;
  border-bottom: 1px solid rgba(35, 39, 45, 0.75);
  transition: background 0.15s;
}
.t-row:hover { background: var(--surface-raised); }
.t-foot { padding: 14px 4px 0; }
.t-foot .label { font-size: 12px; color: var(--text-faint); }

.num {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.num--muted { font-size: 12.5px; font-weight: 400; color: var(--text-muted); }
.num--positive { color: var(--positive); }
.num--negative { color: var(--negative); }
.date { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }
.desc {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Formulaires ---------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}
.input:focus { border-color: var(--accent); outline: none; }
input.input[type="date"] { color-scheme: dark; padding: 7px 10px; }

/* Édition en ligne (/rules) : champ invisible jusqu'au survol */
.input--inline {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
}
.input--inline:hover { border-color: var(--border); background: var(--bg); }
.input--inline:focus { border-color: var(--accent); background: var(--bg); }

.btn {
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, filter 0.15s;
}
.btn:hover { color: var(--text); border-color: #3a4048; }
.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--bg);
  font-weight: 700;
}
.btn--primary:hover { filter: brightness(1.1); color: var(--bg); }
.btn--danger:hover { color: var(--negative); border-color: rgba(242, 102, 91, 0.5); }
.btn--sm { padding: 5px 12px; font-size: 12.5px; }

/* Pilule de filtre (/categories) — même langage que .nav-link */
.pill {
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 100px;
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pill:hover { border-color: #3a4048; }
.pill.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(91, 124, 250, 0.4);
}

/* --- Bandeaux d'action (candidats abonnement, aperçu de règle) ------------ */
.callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c, var(--accent)) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 22%, transparent);
}
.callout .spacer { margin-left: auto; }
.count-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-raised);
  padding: 1px 6px;
  border-radius: 100px;
}

/* --- Barre de part (/categories) ----------------------------------------- */
.share { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.share-track {
  flex: 1;
  height: 4px;
  border-radius: 100px;
  background: var(--surface-raised);
  overflow: hidden;
}
.share-fill { display: block; height: 100%; border-radius: 100px; background: var(--c); }
.share-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Select "catégorie" en contrôle de formulaire (/rules) -----------------
   Pas une pilule comme .cat-select : fond --surface-raised, bordure
   --border, mais le texte (et le caret) prennent la couleur de la
   catégorie choisie, via la même mécanique --c que .cat--<slug>. */
.category-picker {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 26px 8px 11px;
  border-radius: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--c);
  width: 100%;
}
.category-picker-wrap { position: relative; display: inline-flex; align-items: center; width: 100%; }
.category-picker-wrap::after {
  content: "▾";
  position: absolute;
  right: 10px;
  font-size: 8px;
  pointer-events: none;
  opacity: 0.75;
  color: var(--c);
}
.category-picker option { background: var(--surface); color: var(--text); }

/* --- Carte de filtres (/transactions, /categories) -------------------------
   Nommée .filter-card plutôt que .card : .card existe déjà dans theme.css
   avec un autre padding/radius pour /account/password (hors scope de ce
   lot), pas de raison de le changer ici. */
.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}
.filter-card .spacer { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }

/* --- Responsive ----------------------------------------------------------
   La maquette masquait .nav-links sous 760px ; on préfère le retour à la
   ligne pour garder la navigation accessible sur mobile.                   */
@media (max-width: 760px) {
  nav { padding: 8px 16px; height: auto; min-height: 56px; flex-wrap: wrap; }
  .nav-links { display: flex; flex-wrap: wrap; }
  main { padding: 28px 16px 60px; }
}
