/* ============================================
   COMPONENTS — briques réutilisables
   ============================================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100vw; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--espresso);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
@media (min-width: 480px) {
  input, select, textarea { font-size: var(--text-base); }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---------- Boutons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm); font-weight: 600; transition: transform 0.15s var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--terracotta); color: white; width: 100%; }
.btn-ghost { background: transparent; color: var(--espresso-soft); border: 1px solid var(--cream-deep); }
.btn-chip {
  background: var(--cream-deep); border: none; border-radius: var(--radius-full);
  padding: 10px 18px; font-size: var(--text-base); font-weight: 700; color: var(--espresso);
}
.btn-chip.selected { background: var(--terracotta); color: white; }

/* ---------- Carte-photo — signature de l'app ---------- */
.photo-card {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  background: linear-gradient(160deg, var(--card-color, var(--terracotta)),
    color-mix(in srgb, var(--card-color, var(--terracotta)) 55%, #201509));
  flex-shrink: 0; cursor: pointer;
  transition: transform 0.2s var(--ease-spring);
}
.photo-card:active { transform: scale(0.97); }
.photo-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 38%, rgba(0,0,0,0.58) 100%);
}
.photo-card.carousel { width: 172px; height: 220px; }
.photo-card.grid { width: 100%; height: 190px; }
.photo-card.hero { width: 100%; height: 280px; }

.photo-card .halo {
  position: absolute; top: 12px; left: 12px; width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--pct,0) * 1%), rgba(255,255,255,0.35) 0);
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.photo-card .halo-inner {
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--card-color, var(--terracotta)) 55%, #201509);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.photo-card .card-body {
  position: absolute; left: 14px; right: 14px; bottom: 12px; color: white; z-index: 2;
}
.photo-card .card-title { font-size: var(--text-base); font-weight: 700; }
.photo-card .card-amounts { font-family: var(--font-display); font-size: var(--text-sm); opacity: 0.92; margin-top: 3px; font-variant-numeric: tabular-nums; }
.photo-card .card-amounts .cible { opacity: 0.72; font-family: var(--font-body); }
.photo-card .card-badge {
  position: absolute; top: 12px; right: 12px; z-index: 2; font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: var(--radius-full); background: rgba(255,255,255,0.92); color: var(--espresso);
}

/* ---------- Donut signature — progression globale ---------- */
.donut-signature {
  width: 140px; height: 140px; border-radius: 50%; margin: 0 auto;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.donut-signature::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--terracotta) calc(var(--pct, 0) * 1%), var(--cream-deep) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 16px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 16px));
}
.donut-signature .donut-center { position: relative; text-align: center; }
.donut-signature .donut-pct { font-family: var(--font-display); font-size: var(--text-2xl); line-height: 1; }
.donut-wrap { text-align: center; padding: var(--space-4) 0 var(--space-2); }
.donut-wrap .donut-message { font-size: var(--text-xs); color: var(--espresso-soft); margin-top: var(--space-2); }

/* ---------- Historique repliable (détail objectif) ---------- */
.collapsible-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.collapsible-header .chevron { font-size: 16px; color: var(--espresso-soft); transition: transform 0.2s var(--ease); }
.collapsible-header.open .chevron { transform: rotate(180deg); }
.collapsible-content { display: none; margin-top: var(--space-2); }
.collapsible-content.open { display: block; }

/* ---------- Checklist "Étapes pour atteindre l'objectif" ---------- */
.etape-item {
  display: flex; align-items: center; gap: 10px; background: white; border-radius: var(--radius-sm);
  padding: var(--space-3); margin-bottom: var(--space-2); box-shadow: var(--shadow-card);
}
.etape-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--terracotta); flex-shrink: 0; }
.etape-item span { font-size: var(--text-sm); flex: 1; }
.etape-item.fait span { text-decoration: line-through; color: var(--espresso-soft); }
.etape-item .etape-delete { background: none; border: none; color: var(--espresso-soft); font-size: 16px; padding: 0 4px; }
.etape-add-row { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.etape-add-row input {
  flex: 1; padding: var(--space-3); border-radius: var(--radius-sm); border: 1px solid var(--cream-deep);
  background: white; font-size: var(--text-sm);
}
.etape-add-row button { flex-shrink: 0; }

/* ---------- Carte-liste horizontale (accueil) ---------- */
.list-card {
  display: flex; gap: var(--space-3); background: white; border-radius: var(--radius-md);
  padding: var(--space-3); margin-bottom: var(--space-3); box-shadow: var(--shadow-card); cursor: pointer;
}
.list-card-thumb {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--card-color, var(--terracotta)),
    color-mix(in srgb, var(--card-color, var(--terracotta)) 55%, #201509));
}
.list-card-info { flex: 1; min-width: 0; }
.list-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.list-card-title { font-weight: 700; font-size: var(--text-sm); }
.list-card-category { font-size: 10px; color: var(--gold); font-weight: 700; text-transform: uppercase; }
.list-card-amount { text-align: right; font-family: var(--font-display); font-size: var(--text-sm); white-space: nowrap; }
.list-card-amount span { font-family: var(--font-body); font-size: 10px; color: var(--espresso-soft); display: block; }
.list-card-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: var(--space-2); }
.list-card-meta { font-size: 10px; color: var(--espresso-soft); text-align: right; }

/* ---------- Légende sous une carte-photo (grille Mes objectifs) ---------- */
.grid-card-caption { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 0; gap: 6px; }
.grid-card-caption .list-card-meta { font-size: 9px; }

/* ---------- Sélecteurs rapides (emoji / couleur) ---------- */
.emoji-picker, .color-picker { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.emoji-option {
  width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--cream-deep);
  background: white; font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.emoji-option.selected { border-color: var(--terracotta); background: var(--cream-deep); }
.color-option { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; }
.color-option.selected { border-color: var(--espresso); }

/* ---------- Stat mini-bar ---------- */
.mini-stats { display: flex; gap: var(--space-3); padding: var(--space-2) 0; overflow-x: auto; }
.mini-stat { flex-shrink: 0; background: white; border-radius: var(--radius-sm); padding: 10px 16px; box-shadow: var(--shadow-card); }
.mini-stat .mini-label { font-size: 10px; color: var(--espresso-soft); font-weight: 600; text-transform: uppercase; }
.mini-stat .mini-value { font-family: var(--font-display); font-size: var(--text-lg); margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ---------- Ligne d'activité récente ---------- */
.activity-row {
  display: flex; justify-content: space-between; align-items: center;
  background: white; border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2); box-shadow: var(--shadow-card);
}
.activity-row .a-left { display: flex; align-items: center; gap: 10px; }
.activity-row .a-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.activity-row .a-name { font-size: var(--text-sm); font-weight: 700; }
.activity-row .a-date { font-size: var(--text-xs); color: var(--espresso-soft); }
.activity-row .a-montant { font-family: var(--font-display); font-size: var(--text-lg); color: var(--sage); }

/* ---------- Badge statut ---------- */
.badge { font-size: var(--text-xs); padding: 3px 10px; border-radius: var(--radius-full); font-weight: 700; }
.badge-atteint { background: var(--sage-soft); color: var(--sage); }
.badge-encours { background: var(--cream-deep); color: var(--terracotta-dark); }
.badge-retard { background: var(--rose-soft); color: var(--rose); }

/* ---------- Champ de formulaire ---------- */
.form-field { margin-bottom: var(--space-4); }
.form-field label { display: block; font-size: var(--text-sm); font-weight: 700; margin-bottom: var(--space-2); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: var(--space-3); border-radius: var(--radius-sm);
  border: 1px solid var(--cream-deep); background: white; font-size: var(--text-base);
}
.amount-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.amount-chip {
  background: white; border: 1.5px solid var(--cream-deep); border-radius: var(--radius-full);
  padding: 10px 20px; font-size: var(--text-base); font-weight: 700; color: var(--espresso);
}
.amount-chip.selected { background: var(--terracotta); border-color: var(--terracotta); color: white; }

/* ---------- Modale (feuille du bas) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(44, 31, 14, 0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-sheet {
  background: var(--cream); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  padding: var(--space-5); transform: translateY(24px); transition: transform 0.28s var(--ease-spring);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-5); }
.modal-header h2 { font-family: var(--font-display); font-size: var(--text-xl); margin: 0; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--espresso-soft); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--espresso); color: white; padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full); font-size: var(--text-sm); z-index: 200;
  opacity: 0; pointer-events: none; transition: all 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Navigation flottante en pilule ---------- */
.pill-nav {
  position: fixed; left: var(--space-4); right: var(--space-4); bottom: var(--space-4);
  background: white; border-radius: var(--radius-full); padding: 10px 8px;
  display: flex; justify-content: space-around; box-shadow: var(--shadow-float); z-index: 40;
}
.pill-nav button { background: none; border: none; padding: 6px; color: var(--gold); font-size: 20px; display: flex; }
.pill-nav button.active { color: var(--terracotta); }

/* ---------- Bouton flottant d'ajout ---------- */
.fab {
  position: fixed; right: var(--space-4); bottom: 84px; z-index: 45;
  width: 52px; height: 52px; border-radius: 50%; background: var(--terracotta); color: white;
  border: none; font-size: 24px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(201,123,99,0.5); transition: transform 0.15s var(--ease-spring);
}
.fab:active { transform: scale(0.92); }

/* ---------- Écran détail objectif ---------- */
.detail-hero {
  position: relative; height: 320px;
  background: linear-gradient(160deg, var(--card-color, var(--terracotta)),
    color-mix(in srgb, var(--card-color, var(--terracotta)) 55%, #201509));
}
.detail-hero::after { content:''; position:absolute; inset:0; background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.6) 100%); }
.detail-back {
  position: absolute; top: 20px; left: 16px; z-index: 3; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.25); backdrop-filter: blur(6px); border: none; color: white; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.detail-hero-content { position: absolute; left: 20px; right: 20px; bottom: 24px; z-index: 3; color: white; }
.detail-hero-content .d-category { font-size: var(--text-xs); font-weight: 700; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.4px; }
.detail-hero-content .d-title { font-family: var(--font-display); font-size: var(--text-2xl); margin-top: 2px; }
.detail-body { padding: var(--space-5) var(--space-4) 100px; }
.detail-progress-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--space-2); }
.detail-progress-row .saved { font-family: var(--font-display); font-size: var(--text-2xl); font-variant-numeric: tabular-nums; }
.detail-progress-row .target { font-size: var(--text-sm); color: var(--espresso-soft); }
.progress-bar-bg { background: var(--cream-deep); border-radius: var(--radius-full); height: 10px; overflow: hidden; }
.progress-bar-fill { background: linear-gradient(90deg, var(--gold), var(--terracotta)); height: 100%; border-radius: var(--radius-full); transition: width 0.4s var(--ease-spring); }
