/* ═══════════════════════════════════════════════════════════════
   style.css — design system de Budget Famille
   Identité : chaleureuse et rassurante (crème + vert sapin).
   On garde LES RÔLES des variables ; on peut changer les couleurs.
   Contrastes vérifiés (WCAG AA) : texte ≥ 4,5 ; contours de champs ≥ 3.
   ═══════════════════════════════════════════════════════════════ */
:root {
  color-scheme: light dark;  /* calendrier, listes et barres de défilement suivent le thème */
  --bg: #f7f3ec;            /* fond page (crème) */
  --surface: #ffffff;       /* cartes */
  --surface2: #f1ece3;      /* éléments posés sur une carte */
  --border: #e4dccf;        /* séparations discrètes (décoratives) */
  --border-champ: #9a8e80;  /* contour des champs de saisie (3,2:1) */
  --text: #2b2620;          /* texte principal */
  --text-muted: #675d52;    /* texte secondaire (5,5:1) */
  --accent: #2f6b4f;        /* vert sapin — LA couleur d'action */
  --accent-text: #ffffff;
  --accent-soft: rgba(47, 107, 79, 0.12);
  --danger: #b23e33;        /* dépenses, dépassements */
  --success: #27784e;       /* revenus */
  --warning: #a36b0a;       /* budget presque atteint */
  --radius: 14px;
  --shadow: 0 1px 3px rgba(43, 38, 32, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a17; --surface: #1e2420; --surface2: #262d28; --border: #313a33;
    --border-champ: #6e7a71; --text: #ecebe6; --text-muted: #9ea69f;
    --accent: #6fbf94; --accent-text: #0f1a14; --accent-soft: rgba(111, 191, 148, 0.15);
    --danger: #e0766b; --success: #6fbf94; --warning: #e0b04f; --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* sinon .btn { display:flex } l'emporte sur l'attribut hidden */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; line-height: 1.5;
  /* Encoches des téléphones (utile une fois empaqueté pour Android/iOS) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Masqué à l'écran mais toujours lu et atteignable au clavier */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; opacity: 0;
}

/* ── Composants ─────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-champ); background: var(--surface2); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 44px; /* cible tactile */
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-icon { min-width: 44px; min-height: 44px; padding: 6px 10px; background: transparent; border-color: transparent; }

label { display: block; font-size: .85rem; color: var(--text-muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-champ); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input[aria-invalid="true"] { border-color: var(--danger); }

.muted { color: var(--text-muted); }
.montant-depense, .texte-danger { color: var(--danger); }
.montant-revenu { color: var(--success); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* ── Modale (<dialog> natif) ────────────────────────────────── */
dialog.modale {
  border: 0; padding: 0; background: transparent; color: var(--text);
  width: calc(100% - 32px); max-width: 420px; max-height: 90vh; overflow: auto;
}
dialog.modale::backdrop { background: rgba(0, 0, 0, .45); }
dialog.modale .card { margin: 0; }

/* ── Notifications ──────────────────────────────────────────── */
.zone-toasts {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column;
  gap: 8px; align-items: center; width: max-content; max-width: calc(100% - 32px);
  pointer-events: none;
}
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--accent);
  border-radius: 10px; padding: 10px 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}
.toast.erreur { border-color: var(--danger); }
.toast.alerte { border: 2px solid var(--warning); font-weight: 600; }

/* ── Bandeau « version de test » ────────────────────────────── */
.bandeau-beta {
  background: var(--accent-soft); color: var(--text); text-align: center;
  font-size: .85rem; padding: 6px 16px;
}
