:root {
  /* --- COULEURS EXCLUSIVES DES PARENTS --- */
  /* Parent A : Ardoise */
  --ant: #2C3E50;
  --ant-container: #E6EAEF;
  --ant-surface: #F0F4F8;
  --ant-text: #1A252F;

  /* Parent B : Terracotta */
  --fab: #C06C5C;
  --fab-container: #F8EBE9;
  --fab-surface: #FAF2F0;
  --fab-text: #733B31;

  /* --- STRUCTURE MONOCHROME PREMIUM (NEUTRE STRICT) --- */
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --surface-variant: #F1F3F5;

  /* Typographie & Contraste (Sans Parent) */
  --primary: #111111;
  --on-surface: #111111;
  --on-surface-variant: #495057;
  --on-surface-muted: #ADB5BD;

  /* Lignes et Séparateurs Épurés */
  --outline: #E9ECEF;
  --outline-variant: #DEE2E6;

  /* États et Utilitaires */
  --error: #E63946;
  --error-container: #FCE8E6;
  --on-error: #FFFFFF;

  /* Événements : Graphiques, Zéro Couleur Chromatique */
  --cat-school-bg: #F1F3F5;
  --cat-medical-bg: #E9ECEF;
  --cat-activity-bg: #DEE2E6;
}

/* --- BASICS & RESET --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Sora', sans-serif;
  background-color: var(--bg);
  color: var(--on-surface);
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* --- TOP APP BAR --- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
}

.app-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary);
}

.app-name span {
  color: var(--on-surface-muted);
}

.icon-btn {
  background: none;
  border: none;
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--on-surface-variant);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
}

/* --- SCREENS CONTAINER (SWIPE) --- */
.screens {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen-track {
  display: flex;
  width: 400%;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen {
  width: 25%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

/* --- HEADERS & SEGMENTED CONTROLS --- */
.cal-sticky-header {
  background: var(--bg);
  position: sticky;
  top: -20px;
  z-index: 10;
  padding-bottom: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
}

.title-large {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.title-medium {
  font-size: 16px;
  font-weight: 700;
}

.section-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.segmented {
  display: flex;
  background: var(--surface-variant);
  padding: 4px;
  border-radius: 8px;
  margin-top: 12px;
}

.seg-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.seg-btn.active {
  background: var(--primary);
  color: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* --- CUSTODY HERO HEADER --- */
.garde-today {
  display: flex;
  align-items: center;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  margin-top: 4px;
}

.garde-today.ant { background: var(--ant-container); border-color: rgba(44, 62, 80, 0.1); }
.garde-today.fab { background: var(--fab-container); border-color: rgba(192, 108, 92, 0.1); }

.garde-avatar {
  font-size: 24px;
  margin-right: 14px;
}

.garde-info {
  flex: 1;
}

.garde-label-top {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  font-weight: 600;
}

.garde-name-big {
  font-size: 16px;
  font-weight: 700;
}
.garde-today.ant .garde-name-big { color: var(--ant-text); }
.garde-today.fab .garde-name-big { color: var(--fab-text); }

.garde-period {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}


/* --- SELECTEUR UNIFIÉ (MOIS / SEMAINE / JOUR) --- */

.view-nav {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.view-nav.with-square {
  grid-template-columns: 32px 1fr 32px 32px;
}

.view-nav-label {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.nav-arrow-btn {
  background: var(--surface);
  border: 1px solid var(--outline);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--on-surface);
  flex-shrink: 0;
}

.nav-arrow-btn svg {
  width: 14px;
  height: 14px;
}

.day-garde-square {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-variant);
}
.day-garde-square.ant { background: var(--ant); }
.day-garde-square.fab { background: var(--fab); }
.day-garde-square.shared { background: linear-gradient(135deg, var(--ant) 50%, var(--fab) 50%); }


/* --- MONTH VIEW (CALENDAR GRID) --- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0;
}

.month-nav-btn {
  background: var(--surface);
  border: 1px solid var(--outline);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--on-surface);
}

.month-nav-btn svg {
  width: 14px;
  height: 14px;
}

.month-label {
  font-size: 15px;
  font-weight: 700;
}

.cal-grid {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--outline);
  padding: 12px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
}

.cal-wd {
  font-size: 11px;
  font-weight: 700;
  color: var(--on-surface-muted);
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-variant);
  color: var(--on-surface-variant);
  cursor: pointer;
}

.cal-day.empty {
  background: transparent;
  cursor: default;
}

/* Carrés de couleur exclusifs parents */
.cal-day.g-ant { background: var(--ant); color: var(--surface); }
.cal-day.g-fab { background: var(--fab); color: var(--surface); }
.cal-day.g-shared { background: linear-gradient(135deg, var(--ant) 50%, var(--fab) 50%); color: var(--surface); }

.cal-day.today {
  font-weight: 800;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.cal-day-dot {
  width: 4px;
  height: 4px;
  background: transparent;
  border-radius: 50%;
  position: absolute;
  bottom: 4px;
}

.cal-day.has-ev .cal-day-dot {
  background: currentColor;
  opacity: 0.9;
}

.month-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--on-surface-variant);
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.leg-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.leg-swatch.ant { background: var(--ant); }
.leg-swatch.fab { background: var(--fab); }
.leg-swatch.shared { background: linear-gradient(135deg, var(--ant) 50%, var(--fab) 50%); }

/* --- EVENTS LIST (MONTH / WEEK DETAILS) --- */
.month-events, #week-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ev-row, .event-card {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

/* Bandeau neutre et identique pour marquer la structure sans couleur parent */
.ev-stripe, .event-card-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--outline-variant);
}

.ev-body, .event-card-body {
  flex: 1;
  padding-left: 6px;
}

.ev-name, .event-card-name {
  font-size: 13px;
  font-weight: 700;
}

.ev-meta, .event-card-meta {
  font-size: 11px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

/* --- CHIPS & TAGS NEUTRES ET PARENTS --- */
.chip {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

/* Catégories sans couleur */
.chip-school { background: var(--cat-school-bg); color: var(--primary); }
.chip-medical { background: var(--cat-medical-bg); color: var(--primary); }
.chip-activity { background: var(--cat-activity-bg); color: var(--primary); }

/* Puces d'appartenance exclusives parents */
.chip-ant { background: var(--ant-container); color: var(--ant-text); }
.chip-fab { background: var(--fab-container); color: var(--fab-text); }
.chip-shared { background: var(--surface-variant); color: var(--primary); }

/* --- WEEK VIEW HORIZONTAL STRIP --- */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 8px 0;
}


.view-nav {
  display: grid;
  grid-template-columns: 32px 1fr 32px 32px;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.nav-label {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  touch-action: none;
  user-select: none;
}

.wk-day {
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  cursor: pointer;
  border: 1px solid transparent;
}

.wk-day.g-ant { background: var(--ant); border-color: var(--ant); }
.wk-day.g-fab { background: var(--fab); border-color: var(--fab); }
.wk-day.g-shared { background: var(--surface-variant); border-style: dashed; border-color: var(--outline); }

.wk-day-name {
  font-size: 9px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  font-weight: 700;
}

.wk-day-num {
  font-size: 14px;
  font-weight: 800;
  color: var(--surface);
  margin-top: 2px;
}

.wk-day.g-shared .wk-day-name { color: var(--on-surface-muted); }
.wk-day.g-shared .wk-day-num { color: var(--on-surface); }

.wk-day.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.wk-dots {
  display: flex;
  gap: 2px;
  margin-top: 3px;
  height: 4px;
}
.wk-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
}

.day-detail-section { width: 100%; }
.day-detail-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--on-surface-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* --- DAY VIEW & TIMELINE --- */
.day-view-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.day-view-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 8px;
}

.garde-mini-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 100px;
}
.garde-mini-pill.ant { background: var(--ant-container); color: var(--ant-text); }
.garde-mini-pill.ant .dot { width: 6px; height: 6px; background: var(--ant); border-radius: 50%; }
.garde-mini-pill.fab { background: var(--fab-container); color: var(--fab-text); }
.garde-mini-pill.fab .dot { width: 6px; height: 6px; background: var(--fab); border-radius: 50%; }

.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
}

.tl-row {
  display: flex;
  min-height: 52px;
}

.tl-time {
  width: 40px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--on-surface-muted);
  line-height: 1.2;
  padding-top: 2px;
}

.tl-body {
  flex: 1;
  border-left: 1px solid var(--outline);
  padding-left: 12px;
  position: relative;
}

.tl-event {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 6px;
  padding: 8px 10px;
}
.tl-event.school { border-left: 3px solid var(--primary); background: var(--cat-school-bg); }
.tl-event.activity { border-left: 3px solid var(--on-surface-variant); background: var(--cat-activity-bg); }

.tl-event-name { font-size: 12px; font-weight: 700; }
.tl-event-sub { font-size: 10px; color: var(--on-surface-variant); margin-top: 1px; }

.now-indicator {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
  margin-left: 40px;
}
.now-dot { width: 6px; height: 6px; background: var(--error); border-radius: 50%; position: absolute; left: -3px; }
.now-line { flex: 1; height: 1px; background: var(--error); opacity: 0.4; }

/* --- REQUESTS SCREEN --- */
.request-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.req-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--outline-variant);
  padding-bottom: 12px;
}

.req-avatar {
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.req-avatar.ant-av { background: var(--ant-container); color: var(--ant-text); }
.req-avatar.fab-av { background: var(--fab-container); color: var(--fab-text); }

.req-meta { flex: 1; }
.req-who { font-size: 13px; font-weight: 700; }
.req-when { font-size: 11px; color: var(--on-surface-muted); }

.status-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
}
.status-pending { background: var(--surface-variant); color: var(--primary); }
.status-accepted { background: #E6F4EA; color: #137333; }
.status-rejected { background: var(--error-container); color: var(--error); }

.req-body { margin-top: 12px; }

.req-swap {
  display: flex;
  align-items: center;
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
  gap: 8px;
  border: 1px solid var(--outline);
}

.swap-side { flex: 1; text-align: center; }
.swap-date { font-size: 12px; font-weight: 700; }
.swap-who { font-size: 10px; font-weight: 600; margin-top: 1px; }
.swap-fab { color: var(--fab); }
.swap-ant { color: var(--ant); }
.swap-icon { color: var(--on-surface-muted); font-weight: 700; }

.req-note {
  font-size: 12px;
  font-style: italic;
  color: var(--on-surface-variant);
  margin-top: 10px;
  line-height: 1.4;
}

.req-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.action-btn {
  flex: 1;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}
.btn-reject { background: var(--surface-variant); color: var(--primary); }
.btn-accept { background: var(--primary); color: var(--surface); }
.btn-done { background: var(--surface-variant); color: var(--on-surface-muted); cursor: default; }

/* --- APPOINTMENTS (RDV) SCREEN --- */
.rdv-group { margin-bottom: 16px; }
.rdv-period-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 800;
  color: var(--on-surface-muted);
  margin-bottom: 8px;
}

.rdv-card {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  align-items: center;
}

.rdv-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-right: 12px;
  background: var(--surface-variant);
}

.rdv-content { flex: 1; }
.rdv-name { font-size: 13px; font-weight: 700; }
.rdv-where {
  font-size: 11px;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.rdv-where svg { width: 12px; height: 12px; color: var(--on-surface-muted); }

.rdv-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.rdv-time-col {
  text-align: right;
  padding-left: 8px;
}
.rdv-time { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 700; }
.rdv-duration { font-size: 10px; color: var(--on-surface-muted); }

/* --- RULES SCREEN --- */
.rules-hero {
  display: flex;
  align-items: center;
  background: var(--surface-variant);
  padding: 16px;
  border-radius: 12px;
  gap: 14px;
}
.rules-hero-icon { font-size: 24px; }
.rules-hero-title { font-size: 15px; font-weight: 700; }
.rules-hero-sub { font-size: 12px; color: var(--on-surface-variant); }

.rules-group { margin-top: 16px; }
.rules-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 800;
  color: var(--on-surface-muted);
  margin-bottom: 8px;
}

.rules-list {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 10px;
  overflow: hidden;
}

.rule-row {
  display: flex;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--outline-variant);
  cursor: pointer;
}
.rule-row:last-child { border-bottom: none; }

.rule-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-right: 12px;
  background: var(--surface-variant);
}

.rule-text { flex: 1; }
.rule-name { font-size: 13px; font-weight: 700; }
.rule-desc { font-size: 11px; color: var(--on-surface-variant); margin-top: 1px; }

.rule-value { font-size: 12px; font-weight: 600; color: var(--on-surface-muted); margin-right: 4px; }
.rule-chevron svg { width: 14px; height: 14px; color: var(--outline-variant); display: block; }

/* --- FLOATING ACTION BUTTON (FAB) --- */
.rdv-add-btn {
  position: fixed;
  bottom: 84px;
  right: 20px;
  background: var(--primary);
  color: var(--surface);
  border: none;
  padding: 12px 18px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 10;
}
.rdv-add-btn svg { width: 16px; height: 16px; stroke-width: 2.5; }

/* --- BOTTOM NAVIGATION BAR --- */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--outline);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
  font-family: inherit;
  color: var(--on-surface-variant);
}

.nav-indicator {
  padding: 4px 16px;
  border-radius: 100px;
  transition: all 0.2s ease;
}
.nav-indicator svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  display: block;
}




/* Sélection neutre : fond gris technique et icône noire, pas de couleur parent */
.nav-item.active .nav-indicator {
  background: var(--surface-variant);
  color: var(--primary);
}
.nav-item.active .nav-label {
  color: var(--primary);
  font-weight: 700;
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 22%;
  background: var(--error);
  color: var(--on-error);
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* --- MATERIAL RIPPLE EFFECT --- */
.ripple-host {
  position: relative;
  overflow: hidden;
}
.ripple {
  position: absolute;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-animation 0.35s linear;
  pointer-events: none;
}
@keyframes ripple-animation {
  to {
    transform: scale(1);
    opacity: 0;
  }
}
