/* =========================================================================
   Emeric Dashboard — Module Calendrier & Agenda (Material Design 3 Expressive)
   Règles strictes : Zéro emoji, typographie M3 expressive, contrastes parfaits
   ========================================================================= */

.calendar-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-column: 1 / -1;
  box-sizing: border-box;
  container-type: inline-size;
  container-name: calroot;
}

/* --- Barre d'outils du Calendrier (M3 Top App Sub-Bar) --- */
.cal-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large-increased);
  box-shadow: var(--md-sys-elevation-level1);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cal-toolbar::-webkit-scrollbar {
  display: none;
}

/* --- 1. Groupe Navigation (Gauche) --- */
.cal-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 1;
  min-width: 0;
}

.cal-nav-arrows {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.cal-nav-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}
.cal-nav-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.cal-nav-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  height: 100%;
}
.cal-nav-btn:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
  transform: scale(1.05);
}
.cal-nav-btn:active {
  transform: scale(0.95);
}

.cal-today-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-secondary-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-secondary-container);
  font: var(--md-sys-typescale-label-medium-emphasized);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}
.cal-today-btn:hover {
  opacity: 0.92;
  box-shadow: var(--md-sys-elevation-level1);
}
.cal-today-label-short {
  display: none;
}

.cal-title-label {
  font: var(--md-sys-typescale-title-medium);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--md-sys-color-on-surface);
  margin-left: 2px;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 0;
  max-width: none;
  display: inline-flex;
  align-items: center;
}
.cal-title-short {
  display: none;
}
.cal-title-full {
  display: inline;
}

/* --- 2. Commutateur de Vues (Centre) --- */
.cal-view-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 2px;
  gap: 1px;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Sliding active indicator for lateral displacement */
.cal-view-indicator {
  position: absolute;
  top: 2px;
  left: 0;
  height: calc(100% - 4px);
  background: var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-corner-full);
  box-shadow: var(--md-sys-elevation-level1);
  pointer-events: none;
  z-index: 1;
  transition: transform 240ms cubic-bezier(0.2, 0, 0, 1),
              width 240ms cubic-bezier(0.2, 0, 0, 1),
              opacity var(--md-sys-motion-duration-short2) ease;
  will-change: transform, width;
  opacity: 0;
}

.cal-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 8px;
  font: var(--md-sys-typescale-label-medium);
  font-weight: 600;
  font-size: 12px;
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  position: relative;
  z-index: 2;
}
.cal-view-btn:hover:not(.active) {
  color: var(--md-sys-color-on-surface);
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}
.cal-view-btn.active {
  color: var(--md-sys-color-on-primary);
  font-weight: 600;
  background: transparent !important;
  box-shadow: none !important;
}
.cal-view-label-short {
  display: none;
}

/* --- 3. Groupe d'Actions (Droite) --- */
.cal-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.cal-btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-medium-emphasized);
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-level1);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}
.cal-btn-add svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.cal-btn-add:hover {
  opacity: 0.92;
  transform: scale(1.03);
  box-shadow: var(--md-sys-elevation-level2);
}
.cal-btn-add:active {
  transform: scale(0.97);
}

.cal-btn-sync {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-medium);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}
.cal-btn-sync svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.cal-btn-sync:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
}
.cal-btn-sync.syncing svg {
  animation: calSpin 1s linear infinite;
}
@keyframes calSpin {
  100% { transform: rotate(360deg); }
}

.cal-btn-settings {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}
.cal-btn-settings svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.cal-btn-settings:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
  transform: scale(1.05);
}
.cal-btn-settings:active {
  transform: scale(0.95);
}

/* =========================================================================
   Règles Responsives (Conteneur & Viewport)
   ========================================================================= */

/* Palier 1 : Largeur conteneur <= 880px / Ecran <= 900px
   -> Masquage du texte 'Synchroniser' pour transformer le bouton en icône circulaire 36px */
@container calroot (max-width: 880px) {
  .cal-btn-sync {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }
  .cal-btn-sync .cal-btn-text {
    display: none;
  }
}
@media (max-width: 900px) {
  .cal-btn-sync {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }
  .cal-btn-sync .cal-btn-text {
    display: none;
  }
}

/* Palier 2 : Largeur conteneur <= 740px / Ecran <= 768px
   -> Aujourd'hui devient 'Auj.', Ajouter devient icône circulaire +, typographie fluide */
@container calroot (max-width: 740px) {
  .cal-today-label-full {
    display: none;
  }
  .cal-today-label-short {
    display: inline;
  }
  .cal-today-btn {
    padding: 0 8px;
    font-size: 12px;
  }
  .cal-btn-add {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }
  .cal-btn-add .cal-btn-text {
    display: none;
  }
  .cal-title-label {
    font-size: 14px;
  }
  .cal-view-btn {
    padding: 0 8px;
    font-size: 12px;
  }
}
@media (max-width: 768px) {
  .cal-today-label-full {
    display: none;
  }
  .cal-today-label-short {
    display: inline;
  }
  .cal-today-btn {
    padding: 0 8px;
    font-size: 12px;
  }
  .cal-btn-add {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }
  .cal-btn-add .cal-btn-text {
    display: none;
  }
  .cal-title-label {
    font-size: 14px;
  }
  .cal-view-btn {
    padding: 0 8px;
    font-size: 12px;
  }
}

/* Palier 3 : Largeur conteneur <= 580px / Ecran mobile
   -> Titre compact (mois court + annee), sélecteur de vues compact M / S / J / P */
@container calroot (max-width: 580px) {
  .cal-toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 8px 10px;
  }
  .cal-nav-group {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }
  .cal-title-full {
    display: inline;
  }
  .cal-title-short {
    display: none;
  }
  .cal-title-label {
    flex: 1 1 auto;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
  }
  .cal-view-selector {
    flex: 0 0 auto;
  }
  .cal-view-label-full {
    display: none;
  }
  .cal-view-label-short {
    display: inline;
  }
  .cal-view-btn {
    padding: 0 8px;
    min-width: 28px;
    height: 32px;
  }
  .cal-actions-group {
    margin-left: auto;
    gap: 6px;
  }
  .cal-today-btn {
    padding: 0 8px;
    height: 32px;
    font-size: 12px;
  }
  .cal-nav-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }
}
@media (max-width: 580px) {
  .cal-toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 8px 10px;
  }
  .cal-nav-group {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }
  .cal-title-full {
    display: inline;
  }
  .cal-title-short {
    display: none;
  }
  .cal-title-label {
    flex: 1 1 auto;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
  }
  .cal-view-selector {
    flex: 0 0 auto;
  }
  .cal-view-label-full {
    display: none;
  }
  .cal-view-label-short {
    display: inline;
  }
  .cal-view-btn {
    padding: 0 8px;
    min-width: 28px;
    height: 32px;
  }
  .cal-actions-group {
    margin-left: auto;
    gap: 6px;
  }
  .cal-today-btn {
    padding: 0 8px;
    height: 32px;
    font-size: 12px;
  }
  .cal-nav-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }
}

/* Palier 4 : Ultra-compact <= 420px */
@container calroot (max-width: 420px) {
  .cal-toolbar {
    padding: 6px 8px;
    row-gap: 6px;
  }
  .cal-view-selector {
    padding: 2px;
  }
  .cal-view-btn {
    padding: 0 6px;
    min-width: 26px;
    font-size: 11px;
    height: 30px;
  }
  .cal-actions-group {
    gap: 4px;
  }
  .cal-btn-sync, .cal-btn-settings, .cal-btn-add {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }
}
@media (max-width: 420px) {
  .cal-toolbar {
    padding: 6px 8px;
    row-gap: 6px;
  }
  .cal-view-selector {
    padding: 2px;
  }
  .cal-view-btn {
    padding: 0 6px;
    min-width: 26px;
    font-size: 11px;
    height: 30px;
  }
  .cal-actions-group {
    gap: 4px;
  }
  .cal-btn-sync, .cal-btn-settings, .cal-btn-add {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }
}

/* =========================================================================
   Conteneur de Défilement du Calendrier & Dégradés Réactifs aux Limites
   ========================================================================= */
.cal-scroll-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cal-scroll-fade {
  position: absolute;
  left: 0;
  right: 0;
  height: 32px;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
}

.cal-scroll-fade-top {
  top: 0;
  background: linear-gradient(to bottom, var(--md-sys-color-surface) 0%, rgba(0, 0, 0, 0) 100%);
}

.cal-scroll-fade-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--md-sys-color-surface) 0%, rgba(0, 0, 0, 0) 100%);
}

.cal-scroll-wrap.can-scroll-up .cal-scroll-fade-top {
  opacity: 1;
}

.cal-scroll-wrap.can-scroll-down .cal-scroll-fade-bottom {
  opacity: 1;
}

@supports (container-type: scroll-state) {
  .cal-scroll-wrap {
    container-type: scroll-state;
  }
  @container scroll-state(scrollable: top) {
    .cal-scroll-fade-top {
      opacity: 1;
    }
  }
  @container scroll-state(scrollable: bottom) {
    .cal-scroll-fade-bottom {
      opacity: 1;
    }
  }
}

.cal-view-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px 24px 2px;
  box-sizing: border-box;
  transition: -webkit-mask-image var(--md-sys-motion-duration-short3) ease,
              mask-image var(--md-sys-motion-duration-short3) ease;
}

/* Dynamic soft-edge masks for calendar view content */
.cal-view-content.can-scroll-up.can-scroll-down {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 28px, black calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 28px, black calc(100% - 28px), transparent 100%);
}
.cal-view-content.can-scroll-down:not(.can-scroll-up) {
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 28px), transparent 100%);
}
.cal-view-content.can-scroll-up:not(.can-scroll-down) {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 28px, black 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 28px, black 100%);
}
.cal-view-content:not(.can-scroll-up):not(.can-scroll-down) {
  -webkit-mask-image: none;
  mask-image: none;
}


/* =========================================================================
   1. VUE MOIS (Grid 7 colonnes)
   ========================================================================= */
.cal-month-wrap {
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large-increased);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-level1);
  width: 100%;
  box-sizing: border-box;
}

.cal-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  width: 100%;
  box-sizing: border-box;
}

.cal-weekday-cell {
  padding: 10px 4px;
  text-align: center;
  font: var(--md-sys-typescale-label-small-emphasized);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-sys-color-on-surface-variant);
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  box-sizing: border-box;
}

.cal-month-day {
  min-height: 110px;
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background .12s ease;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}
.cal-month-day:nth-child(7n) {
  border-right: 0;
}
.cal-month-day:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}
.cal-month-day.other-month {
  background: rgba(0,0,0,0.15);
  opacity: 0.45;
}
.cal-month-day.today {
  background: var(--md-sys-color-surface-container);
  box-shadow: inset 0 0 0 1px var(--accent-subtle);
}

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.cal-day-number {
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--md-sys-shape-corner-full);
  transition: all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
}
.cal-month-day.today .cal-day-number {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font: var(--md-sys-typescale-label-medium-emphasized);
  box-shadow: 0 0 8px var(--accent-glow), var(--md-sys-elevation-level1);
  transform: scale(1.06);
}

.cal-day-events-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.cal-event-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-label-small-emphasized);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: transform var(--md-sys-motion-duration-short2) ease, box-shadow var(--md-sys-motion-duration-short2) ease;
  border-left: 3px solid var(--chip-color, var(--md-sys-color-primary));
  background: color-mix(in srgb, var(--chip-color, var(--md-sys-color-primary)) 16%, var(--md-sys-color-surface-container-high));
  color: var(--md-sys-color-on-surface);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.cal-event-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--md-sys-elevation-level1);
  background: color-mix(in srgb, var(--chip-color, var(--md-sys-color-primary)) 24%, var(--md-sys-color-surface-container-highest));
}

.cal-pill-time {
  font: var(--md-sys-typescale-label-small-emphasized);
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  opacity: 0.95;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.cal-pill-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  font-weight: 500;
  color: inherit;
}
.cal-pill-icons {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.85;
  color: var(--md-sys-color-on-surface-variant);
}

.cal-more-btn {
  font: var(--md-sys-typescale-label-small-emphasized);
  color: var(--md-sys-color-on-surface-variant);
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  cursor: pointer;
  text-align: left;
  background: transparent;
  border: 0;
}
.cal-more-btn:hover {
  color: var(--md-sys-color-primary);
}

/* =========================================================================
   2. VUE SEMAINE (Timeline 24h & Journées)
   ========================================================================= */
.cal-week-wrap {
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large-increased);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-level1);
}

.cal-week-header {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.cal-week-time-label-header {
  padding: 10px 4px;
  text-align: center;
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
  border-right: 1px solid var(--md-sys-color-outline-variant);
}

.cal-week-col-header {
  padding: 8px 4px;
  text-align: center;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cal-week-col-header:last-child {
  border-right: 0;
}

.cal-week-weekday-name {
  font: var(--md-sys-typescale-label-small-emphasized);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-sys-color-on-surface-variant);
}
.cal-week-day-badge {
  font: var(--md-sys-typescale-title-small-emphasized);
  width: 28px;
  height: 28px;
  border-radius: var(--md-sys-shape-corner-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface);
}
.cal-week-col-header.today .cal-week-day-badge {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level1);
}

/* Ligne des événements "Toute la journée" */
.cal-week-allday-row {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  min-height: 40px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
}
.cal-week-allday-label {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  text-align: center;
  padding: 4px;
}
.cal-week-allday-cell {
  border-right: 1px solid var(--md-sys-color-outline-variant);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Grille déroulante de la semaine */
.cal-week-body-scroll {
  height: 600px;
  overflow-y: auto;
  position: relative;
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  user-select: none;
}

.cal-week-hours-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
}

.cal-week-hour-slot {
  height: 52px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
  text-align: right;
  padding-right: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 2px;
  opacity: 0.85;
}

.cal-week-day-col {
  position: relative;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  height: calc(24 * 52px);
  box-sizing: border-box;
}
.cal-week-day-col:last-child {
  border-right: 0;
}
.cal-week-day-col.today {
  background: var(--md-sys-color-surface-container);
}

.cal-week-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 52px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  cursor: pointer;
  box-sizing: border-box;
  opacity: 0.5;
}
.cal-week-grid-line:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

/* Bloc d'événement positionné temporellement */
.cal-week-event-card {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: var(--md-sys-shape-corner-small);
  padding: 4px 8px;
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
  border-left: 3px solid var(--chip-color, var(--md-sys-color-primary));
  background: var(--chip-bg, var(--md-sys-color-secondary-container));
  color: var(--md-sys-color-on-secondary-container);
  font: var(--md-sys-typescale-label-small);
  line-height: 1.3;
  z-index: 5;
  box-shadow: var(--md-sys-elevation-level1);
  transition: transform var(--md-sys-motion-duration-short2) ease, box-shadow var(--md-sys-motion-duration-short2) ease;
}
.cal-week-event-card:hover {
  transform: scale(1.02);
  z-index: 10;
  box-shadow: var(--md-sys-elevation-level2);
}

.cal-week-event-title {
  font: var(--md-sys-typescale-label-small-emphasized);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-week-event-time {
  font: var(--md-sys-typescale-label-small);
  opacity: 0.85;
}
.cal-week-event-loc {
  font: var(--md-sys-typescale-body-small);
  color: inherit;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ligne rouge de l'heure courante */
.cal-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--md-sys-color-error);
  z-index: 20;
  pointer-events: none;
}
.cal-now-dot {
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--md-sys-color-error);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
  animation: calNowPulse 2s cubic-bezier(0.2, 0, 0, 1) infinite;
}
@keyframes calNowPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.3); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* =========================================================================
   3. VUE JOUR
   ========================================================================= */
.cal-day-wrap {
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large-increased);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-level1);
}

.cal-day-header-banner {
  padding: 14px 20px;
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-day-header-title {
  font: var(--md-sys-typescale-title-large);
  color: var(--md-sys-color-on-surface);
}
.cal-day-header-count {
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
}

.cal-day-body-scroll {
  height: 600px;
  overflow-y: auto;
  position: relative;
  display: grid;
  grid-template-columns: 70px 1fr;
}

/* =========================================================================
   4. VUE PLANNING / AGENDA (Liste chronologique M3)
   ========================================================================= */
.cal-agenda-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cal-agenda-group {
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large-increased);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-level1);
}

.cal-agenda-date-header {
  padding: 12px 18px;
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
}
.cal-agenda-date-header.is-today {
  color: var(--md-sys-color-primary);
}

.cal-agenda-items {
  display: flex;
  flex-direction: column;
}

.cal-agenda-row {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  gap: 14px;
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short2) ease;
}
.cal-agenda-row:last-child {
  border-bottom: 0;
}
.cal-agenda-row:hover {
  background: rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.cal-agenda-time {
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  width: 90px;
  flex-shrink: 0;
}
.cal-agenda-color-bar {
  width: 4px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--chip-color, var(--md-sys-color-primary));
  flex-shrink: 0;
}
.cal-agenda-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.cal-agenda-title {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
}
.cal-agenda-meta {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cal-agenda-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-small);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}
.cal-agenda-source-badge.google {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* =========================================================================
   5. Modale de synchronisation d'agenda (M3 Dialog Tabs)
   ========================================================================= */
.cal-sync-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cal-sync-tabs {
  display: flex;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  gap: 8px;
}
.cal-sync-tab-btn {
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-large);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--md-sys-motion-duration-short2) ease;
}
.cal-sync-tab-btn:hover {
  color: var(--md-sys-color-on-surface);
}
.cal-sync-tab-btn.active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
  font: var(--md-sys-typescale-label-large-emphasized);
}

.cal-sync-tab-pane {
  display: none;
  flex-direction: column;
  gap: 12px;
}
.cal-sync-tab-pane.active {
  display: flex;
}

.cal-sync-instruction-box {
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  font: var(--md-sys-typescale-body-small);
  line-height: 1.5;
  color: var(--md-sys-color-on-surface-variant);
}
.cal-sync-instruction-box ol {
  margin: 6px 0 0 16px;
  padding: 0;
}
.cal-sync-instruction-box li {
  margin-bottom: 4px;
}

.cal-feed-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  gap: 8px;
}
.cal-feed-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.cal-feed-item-name {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
}
.cal-feed-item-url {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   Menu Commande « / » pour Citer les Personnes des Infos dans l'Agenda (M3 Menu)
   ========================================================================= */
.cal-slash-menu {
  position: absolute;
  max-height: 250px;
  overflow-y: auto;
  background: var(--md-sys-color-surface-container-high);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-level3);
  z-index: 1000;
  padding: 8px;
  box-sizing: border-box;
  animation: calSlashFadeIn .12s var(--md-sys-motion-spring-fast);
}

@keyframes calSlashFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cal-slash-header {
  padding: 6px 10px 4px 10px;
  font: var(--md-sys-typescale-label-small-emphasized);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cal-slash-count {
  font: var(--md-sys-typescale-label-small);
  background: var(--md-sys-color-surface-container-highest);
  padding: 1px 6px;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface-variant);
}

.cal-slash-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-corner-medium);
  cursor: pointer;
  transition: background .12s ease;
  user-select: none;
  border: 1px solid transparent;
}

.cal-slash-item:hover,
.cal-slash-item.active {
  background: var(--md-sys-color-secondary-container);
}

.cal-slash-item.active .cal-slash-item-name {
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 700;
}
.cal-slash-item.active .cal-slash-item-meta {
  color: var(--md-sys-color-on-secondary-container);
  opacity: 0.85;
}

.cal-slash-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary-container);
  border: 1px solid var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary-container);
  font: var(--md-sys-typescale-label-small-emphasized);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cal-slash-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.cal-slash-item-name {
  font: var(--md-sys-typescale-title-small-emphasized);
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-slash-item-meta {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-slash-item-badge {
  font: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
}

.cal-slash-empty {
  padding: 14px 10px;
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
}

/* =========================================================================
   Éléments Enrichis Style Google Agenda (Palette, Visioconférence, Récurrence)
   ========================================================================= */

.cal-color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.cal-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--swatch-color);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
  padding: 0;
  transition: transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast),
              box-shadow var(--md-sys-motion-duration-short2) ease,
              border-color var(--md-sys-motion-duration-short2) ease;
}

.cal-color-swatch:hover {
  transform: scale(1.18);
}

.cal-color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--md-sys-color-primary);
  transform: scale(1.12);
}

.cal-color-swatch.active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--md-sys-shape-corner-full);
  background: #ffffff;
}

.cal-mini-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  color: inherit;
}

.cal-agenda-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cal-video-join-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font: var(--md-sys-typescale-label-small);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short2) ease;
  margin-left: auto;
}

.cal-video-join-chip:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.cal-video-join-chip svg {
  width: 12px;
  height: 12px;
}

.cal-recurrence-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-small);
}

.cal-multiday-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font: var(--md-sys-typescale-label-small);
  font-weight: 600;
}

.cal-sync-connected-card {
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-sync-connected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cal-sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 11px;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

/* =========================================================================
   M3 Expressive Calendar Responsive System (Mobile < 600px & Ultra-Compact)
   ========================================================================= */

@media (max-width: 599px) {
  .cal-weekday-cell {
    padding: 6px 2px;
    font-size: 11px;
    letter-spacing: 0;
  }
  .cal-month-day {
    min-height: 50px;
    padding: 3px 2px;
  }
  .cal-day-header {
    justify-content: center;
    margin-bottom: 2px;
  }
  .cal-day-number {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .cal-day-events-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 0 1px;
  }
  .cal-event-pill {
    width: 7px;
    height: 7px;
    min-width: 7px;
    max-width: 7px;
    padding: 0;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: var(--chip-color, var(--md-sys-color-primary));
    box-shadow: 0 0 3px rgba(var(--accent-rgb), 0.3);
  }
  .cal-pill-time,
  .cal-pill-title,
  .cal-pill-icons {
    display: none !important;
  }
  .cal-more-btn {
    font-size: 9px;
    padding: 0 2px;
    line-height: 1;
  }
}



