/*
 * Theme Name:  Calendrier Vacances
 * Description: Calendrier de disponibilités estivales (juin–septembre).
 * Version:     1.1.0
 * Author:      Stacky Antigravity
 * Text Domain: calendrier-vacances
 */

/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
:root {
  --bg:            #0d1117;
  --surface:       #161b22;
  --surface-2:     #21262d;
  --border:        #30363d;
  --text:          #e6edf3;
  --text-muted:    #8b949e;
  --accent:        #58a6ff;
  --accent-glow:   rgba(88, 166, 255, 0.18);

  --dispo:         #3fb950;
  --dispo-bg:      rgba(63, 185, 80, 0.14);
  --dispo-border:  rgba(63, 185, 80, 0.45);

  --indispo:       #f85149;
  --indispo-bg:    rgba(248, 81, 73, 0.14);
  --indispo-border:rgba(248, 81, 73, 0.45);

  /* Coloration cases */
  --warn-orange:   #f0883e;
  --warn-orange-bg:rgba(240, 136, 62, 0.13);
  --warn-orange-border: rgba(240, 136, 62, 0.35);
  --full-red:      #f85149;
  --full-red-bg:   rgba(248, 81, 73, 0.20);
  --full-red-border: rgba(248, 81, 73, 0.50);

  --radius:        12px;
  --radius-sm:     8px;
  --radius-xs:     5px;
  --transition:    0.22s cubic-bezier(.4,0,.2,1);
  --shadow:        0 8px 32px rgba(0,0,0,.45);
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════
   LAYOUT PRINCIPAL
═══════════════════════════════════════════ */
.cal-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ═══════════════════════════════════════════
   HERO HEADER
═══════════════════════════════════════════ */
.cal-hero {
  position: relative;
  padding: 2rem 1rem 1.5rem;
}

.cal-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 0%, rgba(88,166,255,.10) 0%, transparent 70%);
  pointer-events: none;
}

/* Layout 3 colonnes */
.cal-hero-layout {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 1.5rem;
  align-items: center;
  position: relative;
}

/* Centre */
.cal-hero-center {
  text-align: center;
}

.cal-hero h1 {
  font-size: clamp(1.5rem, 3.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e6edf3 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cal-hero p {
  color: var(--text-muted);
  margin-top: .4rem;
  font-size: .9rem;
}

/* ═══════════════════════════════════════════
   NOM INPUT
═══════════════════════════════════════════ */
.cal-name-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  margin: 1.5rem auto 0;
  max-width: 380px;
}

.cal-name-label {
  color: var(--text-muted);
  font-size: .88rem;
  white-space: nowrap;
}

.cal-name-input {
  flex: 1;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  padding: .55rem .9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 0;
}

.cal-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.cal-name-input--shake { animation: shake .4s ease; }

.cal-name-badge {
  background: linear-gradient(135deg, var(--accent), #a371f7);
  color: #fff;
  border-radius: 999px;
  padding: .3rem .85rem;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  display: none;
}

.cal-no-name-hint {
  text-align: center;
  color: var(--warn-orange);
  font-size: .85rem;
  margin-top: .6rem;
  min-height: 1.2em;
}

/* ═══════════════════════════════════════════
   CARROUSEL GAUCHE
═══════════════════════════════════════════ */
.cal-carousel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
}

.cal-carousel-stage {
  width: 200px;
  height: 200px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  position: relative;
}

.cal-carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.cal-carousel-img.visible {
  opacity: 1;
}

.cal-carousel-title {
  font-size: .72rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  max-width: 200px;
  line-height: 1.3;
  min-height: 2.6em;
  padding: 0 .25rem;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.cal-carousel-title.visible {
  opacity: 1;
}

/* ═══════════════════════════════════════════
   PHOTO PERSONNE DROITE
═══════════════════════════════════════════ */
.cal-person-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.cal-person-photo.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.cal-person-img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  object-position: top center;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  box-shadow: 0 0 24px rgba(88,166,255,.25), var(--shadow);
  display: block;
}

.cal-person-caption {
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  max-width: 200px;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════
   ONGLETS MOIS
═══════════════════════════════════════════ */
.cal-tabs {
  display: flex;
  gap: .5rem;
  margin: 2rem auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem;
  width: fit-content;
  max-width: 100%;
}

.cal-tab {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  padding: .5rem 1.15rem;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.cal-tab:hover { background: var(--surface-2); color: var(--text); }

.cal-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(88,166,255,.35);
}

/* ═══════════════════════════════════════════
   NAVIGATION
═══════════════════════════════════════════ */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.75rem 0 1.25rem;
}

.cal-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  padding: .45rem .9rem;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 600;
}

.cal-nav-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.cal-nav-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none;
}

.cal-month-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ═══════════════════════════════════════════
   GRILLE CALENDRIER
═══════════════════════════════════════════ */
.cal-grid-wrapper {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: fadein .28s ease;
}

/* ═══════════════════════════════════════════
   BOUTON MODE SÉLECTION MULTIPLE
═══════════════════════════════════════════ */
.cal-mode-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .6rem;
}

.cal-btn-mode {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  padding: .4rem .9rem;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.cal-btn-mode:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}
.cal-btn-mode.active {
  background: rgba(88,166,255,.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.cal-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.cal-day-name {
  text-align: center;
  padding: .6rem .25rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.cal-day-name.weekend { color: var(--accent); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 660px; /* 6 rows × 110px — évite le collapse au chargement */
}

/* ═══════════════════════════════════════════
   CASE JOUR
═══════════════════════════════════════════ */
.cal-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 110px;
  padding: .55rem .5rem .5rem;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface-2); }

/* Mode sélection multiple : curseur + état sélectionné */
.cal-selection-mode .cal-cell:not(.empty) {
  cursor: crosshair;
}
.cal-selection-mode .cal-cell:not(.empty):hover {
  background: rgba(88,166,255,.08);
}

.cal-cell.selected {
  background: rgba(88,166,255,.18) !important;
  box-shadow: inset 0 0 0 2px var(--accent) !important;
}
.cal-cell.selected:hover {
  background: rgba(88,166,255,.25) !important;
}
/* Coche dans le coin supérieur droit de la case sélectionnée */
.cal-cell.selected::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: .72rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.cal-cell.empty {
  background: rgba(0,0,0,.18);
  cursor: default;
}
.cal-cell.empty:hover { background: rgba(0,0,0,.18); }

.cal-cell.today .cal-day-number { color: var(--accent); }
.cal-cell.today::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.cal-cell.weekend-day .cal-day-number { opacity: .7; }

/* ─── Coloration selon indisponibilités ─── */
.cal-cell--warn {
  background: var(--warn-orange-bg) !important;
  box-shadow: inset 0 0 0 1px var(--warn-orange-border);
}
.cal-cell--warn:hover {
  background: rgba(240,136,62,.20) !important;
}

.cal-cell--full {
  background: var(--full-red-bg) !important;
  box-shadow: inset 0 0 0 1px var(--full-red-border);
}
.cal-cell--full:hover {
  background: rgba(248,81,73,.28) !important;
}

.cal-day-number {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: .4rem;
  display: inline-block;
  min-width: 22px;
  min-height: 22px;
  text-align: center;
  border-radius: 50%;
  padding: 2px;
}

/* ═══════════════════════════════════════════
   PASTILLES NOMS (jusqu'à 8)
═══════════════════════════════════════════ */
.cal-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Scroll si trop de noms */
  max-height: 82px;
  overflow: hidden;
}

.cal-entry {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .68rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  padding: 1px 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.cal-entry.disponible {
  background: var(--dispo-bg);
  border: 1px solid var(--dispo-border);
  color: var(--dispo);
}

.cal-entry.indisponible {
  background: var(--indispo-bg);
  border: 1px solid var(--indispo-border);
  color: var(--indispo);
}

.cal-entry-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-entry.disponible  .cal-entry-dot { background: var(--dispo); }
.cal-entry.indisponible .cal-entry-dot { background: var(--indispo); }

/* Compteur "+N autres" */
.cal-entry-more {
  font-size: .65rem;
  color: var(--text-muted);
  padding: 1px 3px;
  font-style: italic;
}

/* ═══════════════════════════════════════════
   MODALE
═══════════════════════════════════════════ */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.cal-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cal-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 440px;
  width: calc(100% - 2rem);
  padding: 1.75rem;
  transform: translateY(16px) scale(.97);
  transition: transform var(--transition);
  position: relative;
}

.cal-modal-overlay.open .cal-modal {
  transform: translateY(0) scale(1);
}

.cal-modal-date {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--accent);
}

.cal-modal-user {
  font-size: .88rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.cal-modal-user span { color: var(--text); font-weight: 600; }

.cal-modal-actions {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.cal-btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  padding: .65rem;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}

.cal-btn:hover { opacity: .88; transform: translateY(-2px); }
.cal-btn:active { transform: translateY(0); }

.cal-btn-dispo {
  background: linear-gradient(135deg, #3fb950, #2ea043);
  color: #fff;
  box-shadow: 0 4px 14px rgba(63,185,80,.35);
}

.cal-btn-indispo {
  background: linear-gradient(135deg, #f85149, #cf222e);
  color: #fff;
  box-shadow: 0 4px 14px rgba(248,81,73,.35);
}

.cal-btn-delete {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex: none;
  padding: .65rem .9rem;
  font-size: .8rem;
  font-weight: 600;
}

.cal-modal-list {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.cal-modal-list-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: .6rem;
}

.cal-modal-list-empty {
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
}

.cal-modal-entry {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  padding: .25rem 0;
}

.cal-modal-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.cal-modal-close:hover { background: var(--border); color: var(--text); }

/* ═══════════════════════════════════════════
   LÉGENDE
═══════════════════════════════════════════ */
.cal-legend {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.cal-legend-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .8rem;
  color: var(--text-muted);
}

.cal-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════ */
.cal-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  padding: .7rem 1.1rem;
  z-index: 2000;
  transform: translateY(10px);
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  max-width: 280px;
}
.cal-toast.show { opacity: 1; transform: translateY(0); }
.cal-toast.success { border-color: var(--dispo-border); }
.cal-toast.error   { border-color: var(--indispo-border); }

/* ═══════════════════════════════════════════
   BARRE DE SÉLECTION MULTIPLE (fixe en bas)
═══════════════════════════════════════════ */
.cal-selection-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 2000;
  background: var(--surface-2);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -4px 24px rgba(0,0,0,.45);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.34,1.26,.64,1);
  pointer-events: none;
}
.cal-selection-bar.visible {
  transform: translateY(0);
  pointer-events: all;
}
.cal-selection-count {
  font-weight: 700;
  color: var(--accent);
  font-size: .95rem;
  min-width: 8rem;
}
.cal-selection-actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}
.cal-sel-annuler {
  background: transparent !important;
  border-color: var(--text-muted) !important;
  color: var(--text-muted) !important;
}
.cal-sel-annuler:hover {
  border-color: var(--text) !important;
  color: var(--text) !important;
}

/* ═══════════════════════════════════════════
   CHARGEMENT
═══════════════════════════════════════════ */
.cal-loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: .95rem;
}

.cal-spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: .5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   ANIMATION TRANSITION MOIS
═══════════════════════════════════════════ */
@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */

/* Tablette : 2 colonnes (carrousel masqué, photo perso maintenue) */
@media (max-width: 900px) {
  .cal-hero-layout {
    grid-template-columns: 1fr 160px;
    grid-template-areas:
      "center person"
      "carousel carousel";
  }
  .cal-hero-center  { grid-area: center; }
  .cal-person-photo { grid-area: person; }
  .cal-carousel     { grid-area: carousel; flex-direction: row; justify-content: center; }
  .cal-carousel-stage { width: 120px; height: 120px; }
  .cal-carousel-title { max-width: 120px; font-size: .65rem; }
  .cal-person-img   { width: 140px; height: 140px; }
}

/* Mobile : 1 colonne, photo perso masquée, carrousel compact */
@media (max-width: 600px) {
  .cal-hero-layout {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "center center"
      "carousel person";
    gap: 1rem;
    align-items: start;
  }
  .cal-hero-center { grid-area: center; }

  /* Carrousel — image en haut, titre en dessous */
  .cal-carousel {
    grid-area: carousel;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
  .cal-carousel-stage {
    width: 140px;
    height: 140px;
  }
  .cal-carousel-title {
    display: block;
    text-align: center;
    font-size: .64rem;
    max-width: 140px;
    margin-top: .4rem;
  }

  /* Photo personne — image en haut, caption en dessous */
  .cal-person-photo {
    grid-area: person;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
  .cal-person-img     { width: 140px; height: 140px; }
  .cal-person-caption {
    font-size: .64rem;
    max-width: 140px;
    text-align: center;
    margin-top: .4rem;
  }

  .cal-tabs { flex-wrap: wrap; justify-content: center; }
  .cal-tab  { padding: .45rem .75rem; font-size: .82rem; }
  .cal-cell { min-height: 70px; padding: .35rem .25rem; }
  .cal-day-number { font-size: .78rem; }
  .cal-entry { font-size: .64rem; padding: 1px 3px; }
  .cal-modal-actions { flex-direction: column; }
  .cal-btn-delete { flex: 1; }
}

@media (max-width: 430px) {
  .cal-cell { min-height: 56px; }
  .cal-entries { gap: 1px; }
}
