/* ============================================================
   assets/calendrier.css — Viziball Python v1.3
   Style inspiré de l'app R : grille douce, events lisibles
   ============================================================ */

/* ── Page ── */
.cal-page { padding: 0 0 40px; }

/* ── Toolbar ── */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.cal-toolbar-left  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-toolbar-right { display: flex; align-items: center; gap: 8px;  flex-wrap: wrap; }

.cal-title {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  min-width: 240px;
}

/* ── Boutons nav ‹ › ── */
.btn-cal-nav {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 13px;
  cursor: pointer;
  font-size: 15px;
  color: #475569;
  transition: all .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.btn-cal-nav:hover { border-color: #002395; color: #002395; background: #f0f4ff; }

/* ── Boutons vue Jour/Semaine/Mois ── */
.btn-cal-view {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  transition: all .15s;
}
.btn-cal-view.active,
.btn-cal-view:hover {
  background: #002395;
  color: white;
  border-color: #002395;
  box-shadow: 0 2px 6px rgba(0,35,149,.25);
}

/* ── Bouton + Événement ── */
.btn-cal-add {
  background: #002395;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
  box-shadow: 0 2px 8px rgba(0,35,149,.3);
  transition: background .15s;
}
.btn-cal-add:hover { background: #001a6e; }

/* ── Bouton PDF ── */
.btn-cal-pdf {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  transition: all .15s;
}
.btn-cal-pdf:hover { border-color: #3b82f6; color: #3b82f6; }

/* ═══════════════════════════════════════
   ZONE FULLCALENDAR
   ═══════════════════════════════════════ */
#cal-calendar {
  background: white;
  border-radius: 14px;
  padding: 12px 12px 0;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  min-height: 720px;
}

/* FIX CRITIQUE — PC Chrome :
   Ne pas toucher à la hauteur du .fc-scroller.
   FullCalendar injecte height:XXXpx via inline style.
   height:auto !important l'écrasait → timegrid collapsait à 0px sur Chrome.
   On garde uniquement overflow-y pour activer le scroll. */
#cal-calendar .fc-scroller {
  overflow-y: auto !important;
}

/* Sécurité hauteur — gardées comme filet de sécurité */
#cal-calendar .fc-view-harness {
  min-height: 600px !important;
}
#cal-calendar .fc-timegrid-body {
  min-height: 500px !important;
}

/* FIX MOBILE — Sur téléphone (< 600px) on utilise #cal-mobile-view.
   FC n'est pas initialisé → inutile d'afficher le conteneur. */
@media (max-width: 600px) {
  #cal-calendar { display: none !important; }
  .cal-fc-desktop { display: none !important; }
}

/* Masquer toolbar native FC */
#cal-calendar .fc .fc-toolbar { display: none !important; }

/* ── Header colonnes jours ── */
#cal-calendar .fc .fc-col-header { border-bottom: 1px solid #e2e8f0; }
#cal-calendar .fc .fc-col-header-cell {
  background: white;
  padding: 0;
}
#cal-calendar .fc .fc-col-header-cell-cushion {
  display: block;
  padding: 10px 6px 8px;
  color: #64748b !important;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .2px;
  cursor: default;
}

/* Aujourd'hui — colonne bleue */
#cal-calendar .fc-day-today {
  background: rgba(219,234,254,.18) !important;
}
#cal-calendar .fc-day-today .fc-col-header-cell {
  background: transparent;
}
#cal-calendar .fc-day-today .fc-col-header-cell-cushion {
  color: #002395 !important;
  text-decoration: none !important;
  font-weight: 600;
  cursor: default;
}

/* ── Grille temporelle ── */
#cal-calendar .fc .fc-timegrid-slot {
  height: 36px;
  border-color: #f1f5f9 !important;
}
#cal-calendar .fc .fc-timegrid-slot-minor {
  border-top-style: dashed !important;
  border-color: #f8fafc !important;
}
#cal-calendar .fc .fc-timegrid-slot-label {
  color: #b0bec5;
  font-size: 11px;
  font-weight: 400;
  padding-right: 10px;
  vertical-align: top;
}

/* Lignes verticales entre colonnes */
#cal-calendar .fc-theme-standard .fc-scrollgrid { border: none; }
#cal-calendar .fc-theme-standard td { border-color: #f1f5f9; }
#cal-calendar .fc-theme-standard th { border-color: #e2e8f0; }

/* ── Events ── */
#cal-calendar .fc .fc-event {
  border-radius: 6px;
  border: none !important;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  transition: opacity .12s, box-shadow .12s;
}
#cal-calendar .fc .fc-event:hover {
  opacity: .88;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
}

/* Barre gauche colorée sur les events timegrid */
#cal-calendar .fc .fc-timegrid-event {
  border-left: 3px solid rgba(0,0,0,.15) !important;
  border-radius: 0 6px 6px 0 !important;
}

/* Contenu custom de l'event */
.fc-ev-inner {
  padding: 3px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  height: 100%;
}
.fc-ev-time {
  font-size: 10px;
  font-weight: 700;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-ev-title {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ── Events COURTS (≤ 45min) — affichage compact sur 1 ligne ── */
.fc-ev-compact {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 5px;
  height: 100%;
  overflow: hidden;
  white-space: nowrap;
}
.fc-ev-compact-time {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
  flex-shrink: 0;
}
.fc-ev-compact-title {
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hauteur minimale pour que le texte soit toujours visible */
#cal-calendar .fc-timegrid-event {
  min-height: 22px !important;
}
#cal-calendar .fc-timegrid-event .fc-event-main {
  overflow: hidden;
}

/* Events sur vue mois (dayGrid) */
#cal-calendar .fc .fc-daygrid-event {
  border-radius: 4px !important;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 1px;
}
#cal-calendar .fc .fc-daygrid-dot-event .fc-event-title {
  font-weight: 600;
}
#cal-calendar .fc .fc-daygrid-day-number {
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  padding: 6px 8px;
}
#cal-calendar .fc-day-today .fc-daygrid-day-number {
  background: #002395;
  color: white !important;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
}

/* Indicateur heure actuelle */
#cal-calendar .fc .fc-timegrid-now-indicator-line {
  border-color: #ED2939;
  border-width: 2px;
}
#cal-calendar .fc .fc-timegrid-now-indicator-arrow {
  border-top-color: #ED2939;
  border-bottom-color: #ED2939;
}

/* Allday row */
#cal-calendar .fc .fc-daygrid-body { border-bottom: 1px solid #e2e8f0; }

/* ── Légende ── */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 18px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 10px;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}
.cal-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════
   POPUP
   ═══════════════════════════════════════ */
.cal-popup {
  position: fixed;
  z-index: 10000;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
  padding: 14px 16px;
  min-width: 230px;
  max-width: 300px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.cal-popup-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.cal-popup-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}
.cal-popup-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.cal-popup-close:hover { color: #475569; }
.cal-popup-field {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 3px;
  line-height: 1.4;
}
.cal-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}
.cal-popup-edit {
  background: #002395;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: background .12s;
}
.cal-popup-edit:hover { background: #001a6e; }
.cal-popup-delete {
  background: #fff0f0;
  border: 1px solid #fecaca;
  color: #ef4444;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: background .12s;
}
.cal-popup-delete:hover { background: #fee2e2; }

/* ═══════════════════════════════════════
   MODAL CRÉATION / ÉDITION
   ═══════════════════════════════════════ */
.cal-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.cal-modal-box {
  background: white;
  border-radius: 16px;
  padding: 28px;
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.cal-modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}
.cal-modal-hdr h3 {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}
.cal-modal-close-x {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: all .12s;
}
.cal-modal-close-x:hover { background: #f1f5f9; color: #475569; }

/* Grille des 12 types (4 colonnes) */
.cal-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 18px;
}
.cal-type-btn {
  padding: 8px 4px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  background: white;
  cursor: pointer;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  line-height: 1.4;
  transition: all .12s;
}
.cal-type-btn:hover { border-color: #cbd5e1; background: #f8fafc; }

/* Champs du formulaire */
.cal-field { margin-bottom: 16px; }
.cal-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

.cal-day-checks { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.cal-day-checks label { font-size: 12px; }

/* Footer modal */
.cal-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  align-items: center;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .cal-toolbar { flex-direction: column; align-items: flex-start; }
  .cal-type-grid { grid-template-columns: repeat(3, 1fr); }
  .cal-row-2 { grid-template-columns: 1fr; }
  .cal-title { font-size: 16px; min-width: unset; }
}
