/* ── Variables, reset et composants partagés viennent de global.css ── */

body {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 40px;
  min-height: 100vh;
}

/* ── HEADER ── */
.header {
  background: linear-gradient(135deg, var(--orange), var(--orange2), var(--yellow));
  padding: 40px 20px 60px;
  position: relative; overflow: hidden;
}
.header::before {
  content:''; position:absolute; top:-60px; right:-60px;
  width:200px; height:200px; background:rgba(255,255,255,0.09); border-radius:50%;
}
.header::after {
  content:''; position:absolute; bottom:-40px; left:-30px;
  width:150px; height:150px; background:rgba(255,255,255,0.06); border-radius:50%;
}
.header-top {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; position: relative; z-index: 1;
}
.header-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 900; color: white;
}
.header-sub { color: rgba(255,255,255,0.8); font-size: 13px; margin-top: 2px; }

/* Résumé du mois dans le header */
.month-summary {
  display: flex; gap: 10px;
  position: relative; z-index: 1;
}
.summary-chip {
  flex: 1;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  border-radius: 14px; padding: 12px;
  text-align: center;
}
.summary-chip-label { color: rgba(255,255,255,0.8); font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.summary-chip-value { font-family: var(--font-display); font-size: 18px; font-weight: 900; color: white; }

/* ── FORM CARD ── */
.form-wrap {
  position: relative; z-index: 10;
}
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.form-card-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 800;
  padding: 18px 20px 0;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.form-card-title span { font-size: 18px; }
.form-body { padding: 16px 20px 20px; }

/* ── TYPE TOGGLE ── */
.type-toggle {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.type-btn {
  flex: 1; padding: 10px 6px; /* mobile-first ; ≥381px → 12px */
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px; font-weight: 700; /* ≥381px → 14px */
  color: var(--muted);
  transition: all 0.2s;
  display: flex; align-items: center;
  justify-content: center; gap: 6px;
}
.type-btn.active-income {
  border-color: var(--green);
  background: var(--green-light);
  color: #15803d;
}
.type-btn.active-expense {
  border-color: var(--orange);
  background: #FFF0E8;
  color: #c2410c;
}
.type-btn.active-recurring {
  border-color: var(--blue);
  background: var(--blue-light);
  color: #1d4ed8;
}

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 16px; }
.form-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin-bottom: 7px; display: block;
}
.form-input {
  width: 100%; padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 15px; color: var(--text);
  outline: none; transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--orange); background: var(--white); }
.form-input::placeholder { color: #C4A882; }

/* Champ montant avec symbole */
.amount-wrap { position: relative; }
.amount-symbol {
  position: absolute; left: 16px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-display);
  font-size: 18px; font-weight: 800;
  color: var(--orange);
}
.form-input.amount { padding-left: 36px; font-family: var(--font-display); font-size: 22px; font-weight: 800; }

/* ── CATEGORIES ── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* mobile-first ; ≥381px → 4 cols */
  gap: 8px;
}
.cat-item {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  cursor: pointer; background: none;
  text-align: center;
  transition: all 0.2s;
  font-family: var(--font-body);
}
.cat-item:active { transform: scale(0.95); }
.cat-item.selected {
  border-color: var(--orange);
  background: #FFF0E8;
}
.cat-emoji { font-size: 22px; display: block; margin-bottom: 4px; }
.cat-label { font-size: 10px; font-weight: 700; color: var(--text); }
.cat-item.selected .cat-label { color: var(--orange); }

/* ── RÉCURRENT OPTIONS ── */
.recurring-box {
  display: none;
  background: var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  border: 2px solid #BFDBFE;
}
.recurring-box.visible { display: block; }
.recurring-title {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 800;
  color: #1d4ed8; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.freq-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.freq-btn {
  padding: 7px 14px;
  border: 2px solid #BFDBFE;
  border-radius: 20px; background: var(--white);
  font-size: 12px; font-weight: 700;
  color: var(--blue); cursor: pointer;
  transition: all 0.2s;
}
.freq-btn.selected { background: var(--blue); border-color: var(--blue); color: white; }

/* ── DURÉE RÉCURRENT ── */
.duree-wrap  { display: flex; align-items: center; gap: 8px; }
.duree-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.duree-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.duree-input { font-size: 13px !important; padding: 8px 10px !important; }
.duree-sep   { color: var(--muted); font-size: 16px; flex-shrink: 0; margin-top: 16px; }
.duree-info  { margin-top: 8px; font-size: 12px; color: var(--muted); font-style: italic; min-height: 16px; }

/* ── SENS RÉCURRENT ── */
.type-toggle-recurrent { display: flex; gap: 8px; }
.type-recur-btn {
  flex: 1; padding: 10px;
  border: 2px solid var(--border);
  border-radius: 10px; background: var(--white);
  font-family: var(--font-body); font-size: 13px; font-weight: 700;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all 0.2s;
}
.type-recur-btn.active-dep { border-color: var(--orange); background: #FFF0E8; color: var(--orange); }
.type-recur-btn.active-rev { border-color: var(--green);  background: var(--green-light); color: #15803d; }

/* ── STATUT PAIEMENT ── */
.status-box {
  background: #FFFBEB;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 12px;
  border: 1px solid #FCD34D;
}
.status-toggle { display: flex; gap: 8px; }
.status-btn {
  flex: 1; padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px; font-weight: 700;
  color: var(--muted); transition: all 0.2s;
  display: flex; align-items: center;
  justify-content: center; gap: 5px;
}
.status-btn.paid { border-color: var(--green); background: var(--green-light); color: #15803d; }
.status-btn.pending { border-color: var(--yellow); background: #FEF9C3; color: #854d0e; }

/* ── BOUTON SUBMIT ── */
.submit-btn {
  width: 100%; padding: 18px;
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  color: white; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 17px; font-weight: 900;
  box-shadow: 0 6px 20px rgba(255,107,44,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex; align-items: center;
  justify-content: center; gap: 8px;
}
.submit-btn:active { transform: scale(0.98); }
.submit-btn:hover { box-shadow: 0 10px 28px rgba(255,107,44,0.45); }

/* ── LISTE TRANSACTIONS ── */
.tx-section { margin: 0 16px; }
.tx-section-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
}
.tx-section-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 800;
}
.tx-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px;
  font-size: 12px; font-weight: 700;
  color: var(--muted);
}
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border);
  animation: fadeIn 0.3s ease;
}
.tx-card.pending { background: #FFFBEB; border-color: #FCD34D; }
.tx-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center;
  justify-content: center; font-size: 20px;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tx-badge {
  padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 700;
}
.tx-badge.paid { background: var(--green-light); color: #15803d; }
.tx-badge.pending { background: #FEF9C3; color: #854d0e; }
.tx-badge.recurring { background: var(--blue-light); color: #1d4ed8; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.tx-amount { font-family: var(--font-display); font-size: 16px; font-weight: 900; }
.tx-amount.income { color: var(--green); }
.tx-amount.expense { color: var(--orange); }
.tx-actions { display: flex; gap: 4px; }
.tx-edit {
  background: none; border: none; cursor: pointer;
  color: #DDD; font-size: 15px;
  transition: color 0.2s; padding: 2px;
}
.tx-edit:hover { color: var(--orange); }
.tx-delete {
  background: none; border: none; cursor: pointer;
  color: #DDD; font-size: 16px;
  transition: color 0.2s; padding: 2px;
}
.tx-delete:hover { color: var(--red); }

/* ── BANDEAU MODE PLANIFICATION ──────────────────────────── */
.bandeau-planif {
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border-bottom: 2px solid #c7d2fe;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 10px 16px;
  letter-spacing: 0.1px;
}

/* ── PANNEAU MODIFICATION ────────────────────────────────── */
.edit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
}
.edit-overlay.open { display: block; }

/* Mobile-first : bottom-sheet sur petits écrans, modal centré ≥ 769px */
.edit-panneau {
  display: none;
  position: fixed;
  z-index: 201;
  background: #FFFDF5;
  overflow-y: auto;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  animation: editSlideUp 0.28s ease;
}
.edit-panneau.open { display: block; }
.edit-panneau::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: #FFE4B5;
  border-radius: 2px;
  margin: 12px auto 0;
}

/* Desktop : modal centré */
@media (min-width: 769px) {
  .edit-panneau {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(480px, 95vw);
    max-height: 90vh;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: editFadeIn 0.22s ease;
  }
  .edit-panneau::before { display: none; }
}

@keyframes editFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes editSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.edit-header {
  background: linear-gradient(135deg, #FF6B2C, #FFD93D);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.edit-titre {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 44px);
}
.edit-close {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.edit-close:hover { background: rgba(255,255,255,0.4); }

.edit-body { padding: 20px; }

.edit-recurring-box {
  background: #DBEAFE;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid #BFDBFE;
}

.edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.btn-annuler {
  flex: 1;
  padding: 12px;
  background: none;
  border: 2px solid #FFE4B5;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #8A7050;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-annuler:hover { border-color: #8A7050; color: #1A1200; }
.btn-sauvegarder {
  flex: 2;
  padding: 12px;
  background: linear-gradient(135deg, #FF6B2C, #FFD93D);
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255,107,44,0.30);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-sauvegarder:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255,107,44,0.40);
}

/* ── VIDE ── */
.empty-state {
  text-align: center; padding: 32px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-text { font-size: 14px; }

/* ── SOLDE TOTAL ── */
.balance-bar {
  margin: 0 16px 16px;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.balance-bar-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.balance-bar-value { font-family: var(--font-display); font-size: 22px; font-weight: 900; }
.balance-bar-value.positive { color: var(--green); }
.balance-bar-value.negative { color: var(--red); }

/* ── SÉLECTEUR DE PROJET ── */
.projet-selector-wrap {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.projet-selector-wrap:not(:empty) {
  max-height: 600px;
}
.projet-selector {
  background: #FEF9C3;
  border: 2px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 10px;
}
.ps-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: #854d0e; margin-bottom: 10px;
}
.projet-selected-banner {
  background: rgba(255,255,255,0.7);
  border: 1px solid #FDE68A;
  border-radius: 10px;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
  color: #1a1200; margin-bottom: 10px;
}
.ps-section-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin: 8px 0 5px;
}
.ps-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.projet-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 2px solid #FDE68A;
  border-radius: 20px;
  background: var(--white);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  transition: all 0.2s;
}
.projet-item:active { transform: scale(0.96); }
.projet-item.selected {
  border-color: #f59e0b;
  background: #fffbeb;
  font-weight: 700;
}
.pi-emoji { font-size: 16px; }
.pi-nom   { font-size: 13px; color: var(--text); }
.pi-pct {
  font-size: 10px; font-weight: 700;
  color: #92400e;
  background: #FDE68A;
  border-radius: 8px; padding: 1px 5px;
}
.projet-create-btn {
  width: 100%; margin-top: 8px;
  padding: 9px 14px;
  border: 2px dashed #FDE68A;
  border-radius: var(--radius-sm);
  background: none;
  font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  color: #92400e; cursor: pointer;
  text-align: center; transition: all 0.2s;
}
.projet-create-btn:hover { background: rgba(255,255,255,0.5); }
.nouveau-projet-form {
  display: none;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid #FDE68A;
}
.nouveau-projet-form.open { display: block; }
.emoji-picker-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.projet-icon-btn {
  width: 36px; height: 36px;
  border: 2px solid #FDE68A;
  border-radius: 10px;
  background: var(--white);
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.projet-icon-btn.selected {
  border-color: #f59e0b;
  background: #fffbeb;
  transform: scale(1.1);
}
.tx-badge.projet {
  background: #FEF9C3;
  color: #854d0e;
}

/* ≥ 381px : grille à 4 colonnes et boutons-types confortables */
@media (min-width: 381px) {
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .type-btn { font-size: 14px; padding: 12px; }
}
