/* modules/gift-list/gift-list.css */

/* --- 1. VARIABLES & BASE --- */
:root {
  --primary: #2563eb;
  --bg-page: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-light: #e2e8f0;

  --radius-card: 12px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pf-gift-list {
  background-color: var(--bg-page);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  color: var(--text-main);
  font-size: 13px;
}

.pf-gift-list h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.cl-legend {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

/* --- 2. HEADER & SWITCH --- */
.cl-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.cl-view-switch {
  display: flex;
  background: white;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.cl-view-btn {
  padding: 6px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cl-view-btn.is-active {
  background: #334155;
  color: white;
}

/* --- 3. BLOCS OCCASIONS & GRILLE --- */
.cl-occasion-block {
  margin-bottom: 40px;
}

.cl-occasion-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
}

.cl-occasion-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* --- GRILLE INTELLIGENTE (Le cœur de la mise en page) --- */

.cl-occasion-children-tables {
  display: grid;
  gap: 20px;
  align-items: start;
}

/* VUE STANDARD (Nadal) : 3 par ligne */
.cl-view-nadal .cl-occasion-children-tables {
  grid-template-columns: repeat(3, 1fr);
}

/* VUE ANNIVERSARY : Layout spécifique demandé */
.cl-view-anniversary .cl-occasion-children-tables {
  grid-template-columns: repeat(6, 1fr); /* Grille de 6 colonnes */
}

/* Pol et Pep : Prennent 3 colonnes sur 6 (donc 50% de largeur => 2 par ligne) */
.cl-view-anniversary .child-pol,
.cl-view-anniversary .child-pep {
  grid-column: span 3;
}

/* Les autres : Prennent 2 colonnes sur 6 (donc 33% de largeur => 3 par ligne) */
.cl-view-anniversary .child-elna,
.cl-view-anniversary .child-bru,
.cl-view-anniversary .child-guim {
  grid-column: span 2;
}

/* Responsive Mobile (tous sur 1 colonne) */
@media (max-width: 1000px) {
  .cl-view-nadal .cl-occasion-children-tables,
  .cl-view-anniversary .cl-occasion-children-tables {
    grid-template-columns: 1fr;
  }
  .cl-view-anniversary .cl-child-table {
    grid-column: span 1;
  }
}

/* --- 4. TABLEAU PAR ENFANT (Card Unifiée) --- */

.cl-child-table {
  background: white;

  /* L'ombre est sur le tableau global */
  box-shadow: var(--shadow-card);

  /* Arrondi uniquement en BAS (le caption gère le haut) */
  border-radius: 0 0 var(--radius-card) var(--radius-card);

  /* La bordure du tableau ne fait que gauche/droite/bas */
  border: 1px solid var(--border-light);
  border-top: none;

  /* Structure tableau stricte pour garder le caption en haut */
  display: table;
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* CAPTION (Nom de l'enfant - Haut de la carte) */
.cl-child-table caption {
  /* Force l'affichage en haut */
  caption-side: top;
  display: table-caption;

  padding: 10px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 1.1rem;

  /* Arrondi uniquement en HAUT */
  border-radius: var(--radius-card) var(--radius-card) 0 0;

  /* Bordure complète pour le caption */
  border: 1px solid var(--border-light);
  border-bottom: 2px solid; /* Le trait de séparation coloré */

  /* Colle le caption au tableau */
  margin-bottom: 0;

  position: relative;
}

/* Bouton Ajout (+) Rotatif */
.cl-child-add-btn {
  /* Position absolue par rapport au caption */
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);

  background: rgba(255, 255, 255, 0.6);
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.1);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2;
}

.cl-child-add-btn:hover {
  background: white;
  /* La rotation que tu aimais */
  transform: translateY(-50%) rotate(90deg) scale(1.1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  border-color: currentColor;
}

/* --- 5. COULEURS PAR ENFANT (Appliquées au Caption ET au Tableau) --- */

/* POL (Bleu) */
.child-pol {
  border-color: #bcd3ff;
} /* Bordure du tableau (bas/cotés) */
.child-pol caption {
  background: #eaf2ff;
  color: #1e3a8a;
  border-color: #bcd3ff; /* Bordure du caption (haut/cotés) */
  border-bottom-color: #93c5fd; /* Trait de séparation un peu plus foncé */
}
.child-pol thead th {
  background: #f5f9ff;
}

/* PEP (Vert) */
.child-pep {
  border-color: #b9e3b9;
}
.child-pep caption {
  background: #eaf7ea;
  color: #14532d;
  border-color: #b9e3b9;
  border-bottom-color: #86efac;
}
.child-pep thead th {
  background: #f6fdf6;
}

/* ELNA (Rose) */
.child-elna {
  border-color: #f3bfd7;
}
.child-elna caption {
  background: #fdeaf3;
  color: #831843;
  border-color: #f3bfd7;
  border-bottom-color: #f9a8d4;
}
.child-elna thead th {
  background: #fff5f9;
}

/* BRU (Orange) */
.child-bru {
  border-color: #ffd0a8;
}
.child-bru caption {
  background: #fff3e6;
  color: #7c2d12;
  border-color: #ffd0a8;
  border-bottom-color: #fdba74;
}
.child-bru thead th {
  background: #fffaf5;
}

/* GUIM (Violet) */
.child-guim {
  border-color: #d3c6ff;
}
.child-guim caption {
  background: #f0eaff;
  color: #4c1d95;
  border-color: #d3c6ff;
  border-bottom-color: #c4b5fd;
}
.child-guim thead th {
  background: #fbf9ff;
}

/* --- 6. CONTENU DU TABLEAU --- */

/* En-têtes Adultes */
.cl-child-table thead th {
  padding: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);

  /* Pas de largeur fixe, table-layout: fixed gère le partage équitable */
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cl-child-table thead th:last-child {
  border-right: none;
}

.cl-th-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.cl-summary-adult-total {
  font-size: 0.7rem;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
}

/* Corps du tableau */
.cl-child-table tbody td {
  padding: 8px;
  vertical-align: top;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  font-size: 0.85rem;
}
.cl-child-table tbody td:last-child {
  border-right: none;
}
.cl-child-table tr:last-child td {
  border-bottom: none;
}

/* Cellule vide */
.cl-empty {
  color: #e2e8f0;
  text-align: center;
  display: block;
  font-size: 1.2rem;
  line-height: 1;
}

/* --- 7. CADEAUX & INTERACTION (Overlay) --- */
.cl-gift-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cl-gift-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
  position: relative; /* Pour l'overlay */
  min-height: 20px; /* Hauteur min pour éviter le saut si vide */
}

/* Texte du cadeau */
.cl-gift-desc,
.cl-gift-link {
  font-weight: 500;
  color: #0f172a;
  line-height: 1.2;
  font-size: 0.85rem;

  /* Césure forcée pour éviter le scroll */
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;

  flex: 1; /* Prend toute la place dispo à gauche */
}

.cl-gift-link {
  color: var(--primary);
  text-decoration: none;
}
.cl-gift-link:hover {
  text-decoration: underline;
}

/* Zone Droite (Prix OU Actions) */
.cl-gift-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  /* Largeur fixe pour que le switch ne décale pas le texte de gauche */
  width: 50px;
  flex-shrink: 0;
}

/* Le Prix (Visible par défaut) */
.cl-gift-amount {
  font-size: 0.75rem;
  font-weight: 700;
  color: #059669;
  background: #ecfdf5;
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;

  transition:
    opacity 0.2s,
    transform 0.2s;
  opacity: 1;
  transform: scale(1);
}

/* Les Actions (Masquées par défaut, Absolute pour superposition) */
.cl-gift-actions {
  display: flex;
  gap: 4px;
  position: absolute;
  right: 0;
  top: 0;

  opacity: 0;
  transform: scale(0.8);
  pointer-events: none; /* Empêche le clic quand invisible */
  transition:
    opacity 0.2s,
    transform 0.2s;
}

/* === L'EFFET SWAP === */
/* Au survol de la ligne cadeau... */
.cl-gift-line:hover .cl-gift-amount {
  opacity: 0;
  transform: scale(0.8);
}
.cl-gift-line:hover .cl-gift-actions {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Boutons d'action */
.cl-gift-action-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
  font-size: 14px;
  padding: 0;
}
.cl-gift-action-btn:hover {
  background: white;
  border-color: var(--text-main);
}
.cl-gift-delete:hover {
  color: #dc2626;
  border-color: #dc2626;
  background: #fef2f2;
}

/* --- 8. BUDGET & TRICOUNT --- */
.pf-section--panel {
  margin-bottom: 32px;
}
.pf-section--panel h2 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  border-left: 5px solid var(--primary);
  padding-left: 12px;
  color: var(--text-main);
  background: white;
  padding: 12px;
  border-radius: 0 8px 8px 0;
}

.cl-budget-wrapper {
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

.pf-table {
  width: 100%;
  border-collapse: collapse;
}

.pf-table th,
.pf-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}
.pf-table th {
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
  color: var(--text-muted);
}
.cl-debt-matrix td {
  text-align: right;
}

.cl-mtx-owe {
  color: #dc2626;
  background: #fef2f2;
  font-weight: 700;
}

/* --- 9. MODALES --- */
.cl-modal {
  display: none;
}
.cl-modal.cl-open {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.cl-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.cl-modal-dialog {
  position: relative;
  background: white;
  width: min(450px, 90vw);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 10;
  padding: 0;
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.cl-modal-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cl-modal-form h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: var(--text-main);
}

.clm-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #475569;
}

.clm-label input,
.clm-label select {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #f8fafc;
}
.clm-label input:focus,
.clm-label select:focus {
  background: white;
  border-color: var(--primary);
  outline: 2px solid rgba(37, 99, 235, 0.2);
}

.cl-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.clm-cancel {
  background: white;
  border: 1px solid #cbd5e1;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
}
.clm-ok {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* --- 10. MOBILE --- */
@media (max-width: 768px) {
  .cl-view-nadal .cl-occasion-children-tables,
  .cl-view-anniversary .cl-occasion-children-tables {
    grid-template-columns: 1fr;
  }
  .cl-view-anniversary .child-pol,
  .cl-view-anniversary .child-pep,
  .cl-view-anniversary .child-elna,
  .cl-view-anniversary .child-bru,
  .cl-view-anniversary .child-guim {
    grid-column: span 1;
  }

  /* Force le scroll horizontal sur mobile uniquement */
  .cl-child-table {
    display: block;
    overflow-x: auto;
  }
  /* On redonne de la largeur aux colonnes sur mobile */
  .cl-child-table th,
  .cl-child-table td {
    min-width: 120px;
  }
}
