/* ═══════════════════════════════════════════════════════════════
   calendrier.css — Styles de la page Calendrier
   Chargé après global.css
═══════════════════════════════════════════════════════════════ */

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

/* ── HEADER ── */
.header {
  padding: 40px 20px 28px;
}
.header-top {
  display: flex;
  align-items: center;
  gap: 14px;
  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;
}

/* ── CONTENU PRINCIPAL ── */
.cal-wrap {
  padding: 12px 12px 0;
}

/* ── NAVIGATION MOIS ── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--orange);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.cal-nav-btn:hover { background: #FFF0E8; transform: scale(1.05); }
.cal-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.cal-nav-centre { text-align: center; }

.cal-titre {
  font-family: var(--font-display);
  font-size: 15px; /* mobile-first ; ≥321px → 18px */
  font-weight: 900;
  color: var(--text);
}

.mois-badge {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  margin: 4px auto 0;
  width: fit-content;
}
.mois-badge.futur  { background: var(--blue-light);  color: #1d4ed8; }
.mois-badge.actuel { background: var(--green-light); color: #15803d; }

.btn-aujourdhui {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--orange);
  cursor: pointer;
  margin-top: 5px;
  transition: all 0.2s;
}
.btn-aujourdhui:hover { background: #FFF0E8; }

/* ── RÉSUMÉ RAPIDE ── */
.cal-resume {
  display: flex;
  flex-wrap: wrap; /* mobile-first ; ≥401px → nowrap */
  gap: 8px;
  margin-bottom: 10px;
}
.cal-resume-chip {
  flex: 1;
  min-width: calc(33% - 6px); /* mobile-first ; ≥401px → auto */
  background: var(--white);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.cal-resume-label {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.cal-resume-val {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
}
.cal-resume-val.rev { color: #15803d; }
.cal-resume-val.dep { color: var(--orange); }

/* ── LÉGENDE ── */
.cal-legende {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--white);
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
}
.legende-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legende-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legende-dot-today {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--orange);
  flex-shrink: 0;
}

/* ── EN-TÊTES JOURS DE SEMAINE ── */
.cal-entetes {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 3px;
}
.cal-entete {
  text-align: center;
  font-size: 9px; /* mobile-first ; ≥321px → 11px */
  font-weight: 700;
  color: var(--muted);
  padding: 5px 2px;
}
.cal-entete.weekend { color: var(--orange); }

/* ── GRILLE CALENDRIER ── */
.cal-grille {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

/* ── CASE JOUR ── (mobile-first ; cf. @media min-width plus bas) */
.cal-case {
  background: var(--white);
  border-radius: 8px;
  padding: 4px 3px;   /* ≥401px → 5px 4px */
  min-height: 54px;   /* ≥321px → 64px ; ≥401px → 82px */
  border: 1px solid var(--border);
  transition: all 0.18s;
  position: relative;
  overflow: hidden;
}
.cal-case.cal-vide {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}
.cal-case.cal-weekend {
  background: #FFFDF5;
}
.cal-case.cal-today {
  border: 2px solid var(--orange);
  background: #FFF8EC;
}
.cal-case.cal-a-des-evts {
  cursor: pointer;
}
.cal-case.cal-a-des-evts:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255, 107, 44, 0.14);
  border-color: var(--orange);
  z-index: 2;
}

/* ── NUMÉRO DU JOUR ── */
.cal-num {
  font-family: var(--font-display);
  font-size: 11px; /* mobile-first ; ≥401px → 12px */
  font-weight: 800;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1;
}
.cal-today .cal-num {
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
}
.cal-weekend .cal-num { color: var(--orange); }

/* ── PILLS D'ÉVÉNEMENTS ── */
.cal-indicateurs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* Mobile-first : sur très petits écrans, on ne montre que des points colorés.
   Le bg/border est forcé transparent pour neutraliser les styles inline JS.
   Le label texte revient ≥361px (cf. @media plus bas). */
.cal-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 2px;
  border-radius: 5px;
  border: 1px solid;
  border-color: transparent !important;
  background: transparent !important;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-texte { display: none; }   /* ≥361px → inline */
.pill-dot {
  display: inline-block;          /* ≥361px → none */
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-plus {
  font-size: 8px;
  color: var(--muted);
  padding: 1px 2px;
}

/* ── SOLDE NET DU JOUR ── (caché par défaut sur mobile, visible ≥401px) */
.cal-solde-jour {
  display: none;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 800;
  margin-top: 3px;
  text-align: right;
  letter-spacing: -0.2px;
}

/* ── OVERLAY ── */
.overlay-detail {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.40);
  z-index: 100;
}
.overlay-detail.open { display: block; }

/* ── PANNEAU DÉTAIL DU JOUR ── */
.panneau-detail {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 100%);
  max-height: 72vh;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
  z-index: 101;
  flex-direction: column;
}
.panneau-detail.open {
  display: flex;
  animation: slideUpPanel 0.3s ease;
}
@keyframes slideUpPanel {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0);    }
}

/* Poignée */
.panneau-detail::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.panneau-detail-inner {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-date {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 900;
  color: var(--text);
}
.detail-totaux {
  display: flex;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}
.detail-rev { color: #15803d; }
.detail-dep { color: var(--orange); }

.btn-fermer-detail {
  width: 30px;
  height: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-fermer-detail:hover { background: #FFF0E8; color: var(--orange); }

.detail-liste {
  overflow-y: auto;
  padding: 12px 16px;
  flex: 1;
}

/* ── CARTE ÉVÉNEMENT (panneau détail) ── */
.detail-evt {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  animation: fadeIn 0.2s ease;
}
.detail-evt-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-evt-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.detail-evt-info {
  flex: 1;
  min-width: 0;
}
.detail-evt-desc {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.detail-evt-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.detail-evt-montant {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}
.detail-evt-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.detail-btn-valider {
  flex: 1;
  padding: 8px;
  background: var(--green-light);
  color: #15803d;
  border: 1px solid #86efac;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.detail-btn-valider:hover { background: #bbf7d0; }
.detail-btn-payer {
  flex: 1; padding: 8px;
  background: #FEF9C3; color: #854d0e;
  border: 1px solid #FCD34D; border-radius: 8px;
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: background 0.2s;
}
.detail-btn-payer:hover { background: #fef08a; }

/* ── JOUR VIDE ── */
.detail-jour-vide { text-align: center; padding: 20px 0; }
.djv-text { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.djv-btn {
  display: inline-block; padding: 10px 20px;
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  color: white; border-radius: 10px; text-decoration: none;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
}

/* ── FAB PLANIFIER ── */
.btn-ajouter-plan {
  position: fixed;
  bottom: 24px;
  right: max(20px, calc(50vw - 240px));
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 20px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 107, 44, 0.40);
  display: none;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  z-index: 50;
}
.btn-ajouter-plan:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(255, 107, 44, 0.50);
}
.fab-plus {
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
}

/* ── Mobile-first : montée progressive vers grands écrans ── */

/* ≥ 321px : on annule les contraintes des écrans ≤320 */
@media (min-width: 321px) {
  .cal-entete  { font-size: 11px; }
  .cal-titre   { font-size: 18px; }
  .cal-case    { min-height: 64px; }
}

/* ≥ 361px : on réaffiche le label des pills (au lieu des points seuls) */
@media (min-width: 361px) {
  .pill-texte { display: inline; }
  .pill-dot   { display: none; }
  .cal-pill   {
    padding: 2px 4px;
    display: block;
    background: transparent;
    border-color: currentColor;
  }
}

/* ≥ 401px : on revient à la mise en page calendrier classique */
@media (min-width: 401px) {
  .cal-case        { min-height: 82px; padding: 5px 4px; }
  .cal-num         { font-size: 12px; }
  .cal-resume      { flex-wrap: nowrap; }
  .cal-resume-chip { min-width: auto; }
  .cal-solde-jour  { display: block; }
}
