/* ============================================
   GÉNÉRALES - Layout principal
   ============================================ */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  width: 100%;
  max-width: 100%;
  margin-bottom: 3rem;
}

main h1 {
  text-align: center;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--bleu-principal), var(--violet-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2rem;
}



/* ============================================
   CALENDRIER - Conteneur
   ============================================ */
#calendar-container {
  display: none;
}

#calendar-container.visible {
  display: block;
}


/* ============================================
   CALENDRIER - Contrôles de navigation
   ============================================ */
.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

#weekLabel {
  font-weight: 700;
  font-size: 1rem;
  color: var(--bleu-principal);
  min-width: 160px;
  text-align: center;
}

.download-planning {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}


/* ============================================
   CALENDRIER - Tableau de planning
   ============================================ */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 20px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.table-wrapper::-webkit-scrollbar {
  height: 12px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
  background-clip: content-box;
}

/* Scrollbar pour Firefox */
.table-wrapper {
  scrollbar-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.02);
  scrollbar-width: thin;
}

.planning-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  table-layout: fixed;
  border-radius: 0;
  overflow: visible;
}


.planning-table th {
  background: linear-gradient(135deg, var(--bleu-principal), var(--violet-accent));
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.7rem 0.4rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: sticky;
  top: 0;
  z-index: 10;
}

.planning-table th:first-child {
  width: 60px;
  min-width: 60px;
  left: 0;
  z-index: 20;
}

.planning-table td {
  border: 1px solid rgba(0, 0, 0, 0.08);
  height: 22px;
  padding: 0;
  vertical-align: top;
  transition: background 0.15s;
  position: relative;
}

.planning-table td:first-child {
  background: var(--fond-cartes);
  text-align: center;
  font-size: 0.75rem;
  color: var(--texte-secondaire);
  font-weight: 600;
  padding: 2px 4px;
  white-space: nowrap;
}

/* Jour actuel : cadre néon + fond violet */
.planning-table th.today-header {
  position: relative;
  z-index: 4;
  background: linear-gradient(135deg, #7c3aed, #a855f7) !important;
  color: #fff !important;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  border: 2px solid #d8b4fe;
  border-bottom: none;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.9), inset 0 0 10px rgba(255, 255, 255, 0.25);
  clip-path: inset(-16px -16px 0 -16px);
}



.planning-table td.today-column {
  position: relative;
  z-index: 3;
  background-color: rgba(168, 85, 247, 0.12);
  border-left: 2px solid #d8b4fe;
  border-right: 2px solid #d8b4fe;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.85);
  clip-path: inset(0 -16px 0 -16px);
}

.planning-table tbody tr:last-child td.today-column {
  border-bottom: 2px solid #d8b4fe;
  clip-path: inset(0 -16px -16px -16px);
}

body.dark-theme .planning-table td.today-column {
  background-color: rgba(168, 85, 247, 0.2);
}


.planning-table td.calendar-empty:hover {
  background: rgba(109, 40, 217, 0.04);
}


/* ============================================
   CALENDRIER - Cellules de tâches
   ============================================ */
.task-cell {
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.12), rgba(109, 40, 217, 0.08));
  border-left: 3px solid var(--violet-accent) !important;
  cursor: grab;
}

.cell-tache.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.task-cell .cell-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--violet-accent);
  padding: 3px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.creneau-cell {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.15), rgba(30, 58, 138, 0.1));
  border-left: 3px solid var(--bleu-principal) !important;
}

.creneau-cell .cell-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--bleu-principal);
  padding: 3px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.calendar-empty.drag-over {
  background: rgba(109, 40, 217, 0.12);
  outline: 2px dashed var(--violet-accent);
  outline-offset: -2px;
}


/* ============================================
   MESSAGE - Pas de planning généré
   ============================================ */
.no-planning {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--texte-secondaire);
  margin: 3rem auto;
}

.no-planning p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}


/* ============================================
   PERSONNALISATION COULEURS - Modale
   ============================================ */
.couleurs-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.preset-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s;
  padding: 0;
}

.preset-btn:hover {
  transform: scale(1.15);
  border-color: rgba(0, 0, 0, 0.25);
}

.btn-couleurs {
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}


/* ---------- Export PDF ---------- */
.planning-table.export-table {
  display: table !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: none !important;
  table-layout: fixed !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  overflow: visible !important;
  box-shadow: none !important;
}

.planning-table.export-table th,
.planning-table.export-table td {
  position: static !important;
  left: auto !important;
  right: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
  background: #ffffff !important;
  background-clip: border-box !important;
}

.planning-table.export-table th:first-child,
.planning-table.export-table td:first-child {
  width: 72px !important;
  min-width: 72px !important;
  background: #f8fafc !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 628px) {

  .table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 4px;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrapper::-webkit-scrollbar {
    height: 14px;
  }

  .table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    margin: 2px;
  }

  .table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
    min-width: 40px;
  }

  .table-wrapper::-webkit-scrollbar-thumb:active {
    background: rgba(0, 0, 0, 0.4);
    background-clip: content-box;
  }

  .planning-table {
    display: table;
    width: max-content;
    min-width: 100%;
    overflow: visible;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .planning-table th,
  .planning-table td {
    font-size: 0.7rem;
    padding: 2px;
  }

  .planning-table th:first-child,
  .planning-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 30;
    background: var(--fond-cartes) !important;
    background-clip: border-box;
    box-shadow: none;
  }

  .planning-table th:first-child {
    background: linear-gradient(135deg, var(--bleu-principal), var(--violet-accent)) !important;
    z-index: 40;
  }
}

/* FIX MOBILE — colonne heures opaque sans dépasser */
@media (max-width: 768px) {
  .planning-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  /* Contrôles de navigation : empilés */
  .calendar-controls {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .calendar-controls .btn {
    width: 100%;
    justify-content: center;
  }


  .planning-table th:first-child,
  .planning-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 30;
    background: var(--fond-cartes) !important;
    background-clip: border-box;
    box-shadow: none !important;
  }

  .planning-table th:first-child {
    background: linear-gradient(135deg, var(--bleu-principal), var(--violet-accent)) !important;
    z-index: 40;
  }

  .planning-table td:first-child::after,
  .planning-table th:first-child::after {
    content: "";
    position: absolute;
    top: 0;
    right: -1px;
    width: 1px;
    height: 100%;
    background: rgba(0, 0, 0, 0.08);
    z-index: 50;
  }
}

@media (min-width: 629px) {
  .table-wrapper {
    border-radius: 12px;
    overflow: hidden;
    background: var(--fond-clair);
    box-shadow: none;
    padding-left: 0.6rem;
  }

  .planning-table {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  }
}

/* ---------- Modale couleurs : même style que les autres modales ---------- */
#modal-couleurs .modal-contenu {
  border-radius: 20px !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#modal-couleurs .modal-contenu::-webkit-scrollbar { display: none; }

.preset-btn:hover { border-color: var(--violet-accent); }

/* ---------- Thème sombre ---------- */
body.dark-theme #modal-couleurs h2 { color: #c4b5fd !important; }

body.dark-theme #modal-couleurs div:has(> #presets-creneau) > h3 { color: #93b4ff !important; }
body.dark-theme #modal-couleurs div:has(> #presets-tache) > h3 { color: #c4b5fd !important; }

body.dark-theme #modal-couleurs input[type="text"] {
  background: #2a2a3e !important;
  border-color: #3a3a5e !important;
  color: var(--texte-principal) !important;
}
body.dark-theme #modal-couleurs input[type="text"]::placeholder { color: #858da0; }
body.dark-theme #modal-couleurs input[type="text"]:focus {
  outline: none;
  border-color: #a78bfa !important;
}

body.dark-theme #modal-couleurs input[type="color"] {
  background: #2a2a3e !important;
  border-color: #3a3a5e !important;
}

body.dark-theme #modal-couleurs [style*="border-top"] { border-top-color: #3a3a5e !important; }

body.dark-theme .preset-btn:hover { border-color: #c4b5fd; }

body.dark-theme .btn-outline {
  color: #c4b5fd;
  border-color: #a78bfa;
}
body.dark-theme .btn-outline:hover {
  background: var(--violet-accent);
  border-color: var(--violet-accent);
  color: #fff;
}

/* ---------- Titre de la page et semaine, en thème sombre ---------- */
body.dark-theme main h1 {
  background-image: linear-gradient(135deg, #93b4ff, #c4b5fd);
}
body.dark-theme #weekLabel { color: #c4b5fd; }


/* ===== Aperçus semaines voisines (carrousel) ===== */
.semaine-carousel {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.semaine-carousel .table-wrapper {
  flex: 1 1 auto;
  min-width: 0;
}

.semaine-peek {
  position: relative;
  flex: 0 0 clamp(60px, 11%, 160px);
  margin-top: 20px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  color: var(--bleu-principal);
}

.semaine-peek-prev {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 75%);
  mask-image: linear-gradient(to right, transparent, #000 75%);
}
.semaine-peek-next {
  -webkit-mask-image: linear-gradient(to left, transparent, #000 75%);
  mask-image: linear-gradient(to left, transparent, #000 75%);
}

.peek-apercu {
  position: absolute;
  top: 0;
  pointer-events: none;
  filter: blur(2.5px);
  opacity: 0.55;
  transition: opacity 0.2s;
}
.semaine-peek-prev .peek-apercu { right: 0; }
.semaine-peek-next .peek-apercu { left: 0; }
.peek-apercu .planning-table { width: 100%; margin: 0; }

.semaine-peek:hover .peek-apercu,
.semaine-peek.drag-survol .peek-apercu { opacity: 0.9; }
.semaine-peek.drag-survol { box-shadow: inset 0 0 0 3px rgba(109, 40, 217, 0.55); }

.peek-fleche {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  font-size: 26px;
  line-height: 34px;
  font-weight: bold;
  text-align: center;
  pointer-events: none;
}

.peek-date {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

body.dark-theme .semaine-peek { color: #e8e8f0; }
body.dark-theme .peek-fleche,
body.dark-theme .peek-date { background: rgba(26, 26, 46, 0.92); }

@keyframes semaineSlideNext { from { opacity: 0.35; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes semaineSlidePrev { from { opacity: 0.35; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
.semaine-carousel.anim-next .table-wrapper { animation: semaineSlideNext 0.3s ease; }
.semaine-carousel.anim-prev .table-wrapper { animation: semaineSlidePrev 0.3s ease; }

@media (max-width: 900px) {
  .peek-date { display: none; }
}
@media (max-width: 700px) {
  .semaine-peek { flex-basis: 30px; }
  .peek-apercu { display: none; }
  .semaine-peek { background: rgba(109, 40, 217, 0.1); }
  .peek-fleche { width: 26px; height: 26px; line-height: 24px; font-size: 20px; }
}


/* ===== Vue mois ===== */
.titre-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.vue-switch {
  display: inline-flex;
  border: 1px solid rgba(109, 40, 217, 0.35);
  border-radius: 999px;
  overflow: hidden;
}

.vue-btn {
  border: none;
  background: transparent;
  color: var(--violet-accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.vue-btn.actif {
  background: var(--violet-accent);
  color: #fff;
}

.mois-nav {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(109, 40, 217, 0.35);
  background: transparent;
  color: var(--bleu-principal);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.mois-nav:hover { background: rgba(109, 40, 217, 0.1); }

.mois-zone { margin: 20px 0 2rem; }

.mois-grille {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.mois-entete {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--violet-accent);
  padding: 0.3rem 0;
}

.mois-jour {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  min-height: 112px;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: var(--fond-cartes);
  color: var(--texte-principal);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.mois-jour:hover { background: rgba(109, 40, 217, 0.08); }
.mois-jour.hors-mois { opacity: 0.45; }

.mois-num { font-size: 0.85rem; font-weight: 700; }

.mois-tache {
  display: block;
  margin-top: 3px;
  padding: 2px 6px;
  border-left: 3px solid var(--c);
  border-radius: 6px;
  background: rgba(109, 40, 217, 0.1);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mois-tache.fait { text-decoration: line-through; opacity: 0.55; }
.mois-plus { display: block; margin-top: 3px; font-size: 0.72rem; font-weight: 700; color: var(--violet-accent); }

.mois-points { display: none; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.mois-points i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* Jour actuel : néon */
.mois-jour.today-month {
  position: relative;
  z-index: 2;
  background: rgba(168, 85, 247, 0.12);
  border: 2px solid #d8b4fe;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.85), inset 0 0 10px rgba(168, 85, 247, 0.2);
}

body.dark-theme .mois-nav { color: #c4b5fd; }
body.dark-theme .vue-btn { color: #c4b5fd; }
body.dark-theme .vue-btn.actif { background: #a78bfa; color: #1a1a2e; }
body.dark-theme .mois-entete { color: #c4b5fd; }
body.dark-theme .mois-jour { border-color: rgba(255, 255, 255, 0.1); }
body.dark-theme .mois-jour.today-month { background: rgba(168, 85, 247, 0.2); }

@media (max-width: 768px) {
  .vue-switch { align-self: center; }
}

@media (max-width: 700px) {
  .mois-grille { gap: 3px; }
  .mois-jour { min-height: 56px; padding: 4px; }
  .mois-taches { display: none; }
  .mois-points { display: flex; }
}

/* Détail d'un jour (vue mois) */
.jour-tache {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.5rem;
  padding: 0.55rem 0.8rem;
  border-left: 4px solid var(--c);
  border-radius: 8px;
  background: rgba(109, 40, 217, 0.08);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  color: var(--texte-principal);
}

.jour-heure { font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.jour-nom { font-size: 0.9rem; font-weight: 600; }
.jour-tache.fait .jour-nom { text-decoration: line-through; opacity: 0.55; }
.jour-vide { text-align: center; padding: 1rem 0; color: var(--texte-secondaire); }

/* ---------- Modale couleurs : version mobile ---------- */
@media (max-width: 600px) {
  #modal-couleurs .modal-contenu {
    width: 94%;
    padding: 1.3rem 1rem 1.2rem;
    max-height: 90vh;
    max-height: 90dvh;
  }

  #modal-couleurs .fermer {
    top: 0.7rem;
    right: 0.7rem;
  }

  /* titre : ne passe plus sous la croix */
  #modal-couleurs h2 {
    font-size: 1.1rem !important;
    padding-right: 2rem;
  }

  /* pastilles : 4 par ligne, bien alignées */
  #modal-couleurs .couleurs-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem !important;
    justify-items: center;
  }

  #modal-couleurs .preset-btn {
    width: 100%;
    max-width: 44px;
    height: auto;
    aspect-ratio: 1;
  }

  /* ligne « sélecteur + hex + Appliquer » : le bouton passe dessous */
  #modal-couleurs div:has(> input[type="color"]) {
    flex-wrap: wrap;
  }

  #modal-couleurs input[type="text"] {
    flex: 1 1 100px;
    min-width: 0;
    width: auto;
  }

  #modal-couleurs div:has(> input[type="color"]) > .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  /* aperçus : même taille côte à côte */
  #modal-couleurs div:has(> div > #apercu-creneau) {
    gap: 0.6rem !important;
  }

  #modal-couleurs #apercu-creneau,
  #modal-couleurs #apercu-tache {
    padding: 0.6rem !important;
  }

  /* boutons Annuler / Enregistrer : même largeur */
  #modal-couleurs div:has(> button.btn-outline) {
    gap: 0.6rem !important;
  }

  #modal-couleurs div:has(> button.btn-outline) > button {
    flex: 1;
    justify-content: center;
  }
}
/* Retour au jour actuel : fondu + pulsation néon */
@keyframes semaineFondu {
  from { opacity: 0.2; transform: scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.semaine-carousel.anim-fondu .table-wrapper,
.mois-zone.anim-fondu { animation: semaineFondu 0.45s ease; }

@keyframes pulseJourTh {
  0%, 100% { box-shadow: 0 0 16px rgba(168, 85, 247, 0.9), inset 0 0 10px rgba(255, 255, 255, 0.25); }
  50%      { box-shadow: 0 0 30px 3px rgba(216, 180, 254, 1), inset 0 0 14px rgba(255, 255, 255, 0.5); }
}
@keyframes pulseJourTd {
  0%, 100% { box-shadow: 0 0 16px rgba(168, 85, 247, 0.85); }
  50%      { box-shadow: 0 0 30px 3px rgba(216, 180, 254, 1); }
}
@keyframes pulseJourMois {
  0%, 100% { box-shadow: 0 0 14px rgba(168, 85, 247, 0.85), inset 0 0 10px rgba(168, 85, 247, 0.2); }
  50%      { box-shadow: 0 0 32px 4px rgba(216, 180, 254, 1), inset 0 0 14px rgba(168, 85, 247, 0.35); }
}

.pulse-jour th.today-header { animation: pulseJourTh 0.8s ease-in-out 0.3s 2; }
.pulse-jour td.today-column { animation: pulseJourTd 0.8s ease-in-out 0.3s 2; }
.pulse-jour .mois-jour.today-month { animation: pulseJourMois 0.8s ease-in-out 0.3s 2; }

@media (prefers-reduced-motion: reduce) {
  .semaine-carousel.anim-fondu .table-wrapper,
  .mois-zone.anim-fondu,
  .pulse-jour th.today-header,
  .pulse-jour td.today-column,
  .pulse-jour .mois-jour.today-month { animation: none; }
}