/* ── Reset & variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #94cef5;
  --orange:     #f6c84a;
  --red:        #e74c3c;
  --header-bg:  #4a4a4a;
  --border:     #cccccc;
  --other-bg:   #efefef;
  --other-text: #aaaaaa;
  --sidebar-bg: #f5f6f8;
  --sidebar-w:  255px;
  --mobile-modebar-h: 64px;
  --mobile-header-h:  52px;
}

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: #dde1e7;
  min-height: 100vh;
}

/* ── App shell ─────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (desktop only) ────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  margin-bottom: 4px;
}
.sidebar-header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
}

.section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin-top: 6px;
}

/* Month nav (shared styles) */
.nav-month {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}

.nav-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #555;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  line-height: 1;
  flex-shrink: 0;
}
.nav-btn:hover { background: #f0f0f0; }

.month-label {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
}

/* Modes (sidebar) */
.modes { display: flex; flex-direction: column; gap: 5px; }

.mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.87rem;
  color: #333;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.mode-btn:hover { background: #ebebeb; }
.mode-btn.active[data-mode="pauline"] { border-color: var(--blue);   background: #e8f4fa; }
.mode-btn.active[data-mode="alex"]   { border-color: var(--orange); background: #fdf3e3; }
.mode-btn.active[data-mode="alain"]  { border-color: var(--red);    background: #fdecea; }
.mode-btn.active[data-mode="sylvie"] { border-color: var(--red);    background: #fdecea; }
.mode-btn.active[data-mode="ferie"]  { border-color: var(--red);    background: #fdecea; }
.mode-btn.active[data-mode="erase"]  { border-color: #999;          background: #f0f0f0; }

/* Color dots (shared) */
.color-dot, .mmode-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
.dot-pauline { background: var(--blue); }
.dot-alex    { background: var(--orange); }
.dot-gp      { background: #fff; border: 2px solid var(--red); }
.dot-ferie   { background: #fff; border: 2px solid var(--red); color: var(--red); font-size: 9px; font-weight: 700; }
.dot-erase   { background: #fff; border: 2px solid #bbb; color: #999; }

/* Action buttons (sidebar) */
.action-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.87rem;
  text-align: left;
  color: #333;
  transition: background 0.12s;
}
.action-btn:hover { background: #ebebeb; }
.action-btn.danger { color: var(--red); }
.action-btn.danger:hover { background: #fdecea; }

/* Legend */
.legend {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.legend-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin-bottom: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 4px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-dot-gp { background: #fff; border: 2px solid var(--red); border-radius: 50%; }
.red { color: var(--red); }

/* ── Main column ───────────────────────────────────────── */
.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Mobile elements hidden on desktop */
.mobile-header,
.mobile-modebar { display: none; }

/* ── Calendar wrap ─────────────────────────────────────── */
.calendar-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 20px;
}

.calendar {
  background: #fff;
  width: 100%;
  max-width: 960px;
  box-shadow: 0 3px 24px rgba(0,0,0,0.13);
  border-radius: 4px;
  padding: 22px 26px 26px;
}

#calendar-title {
  font-size: 1.9rem;
  font-weight: 400;
  color: #222;
  margin-bottom: 14px;
}

/* Grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.day-header {
  background: var(--header-bg);
  color: #fff;
  text-align: center;
  padding: 8px 4px;
  font-size: 0.8rem;
  font-weight: 500;
  border-right: 1px solid #666;
  border-bottom: 1px solid #666;
  letter-spacing: 0.01em;
}

/* Day cells */
.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 100px;
  padding: 7px 9px 6px;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: filter 0.1s;
}
.day-cell:hover:not(.other-month) { filter: brightness(0.93); }

.day-cell.other-month {
  background: var(--other-bg);
  cursor: default;
}
.day-num {
  font-size: 0.87rem;
  color: #333;
  line-height: 1;
}
.other-month .day-num { color: var(--other-text); }

/* Background modes */
.day-cell.bg-pauline { background: var(--blue); }
.day-cell.bg-alex    { background: var(--orange); }

/* Férié label */
.ferie-label {
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  width: 100%;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Grandparent label */
.gp-label {
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  width: 100%;
}
/* Friday evening → push to bottom */
.gp-label.gp-evening {
  margin-top: auto;
}
/* Saturday / Sunday → center vertically */
.gp-label.gp-day {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
}

/* ── Mobile header ─────────────────────────────────────── */
.mobile-header {
  height: var(--mobile-header-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
}
.mobile-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #e8e8e8; }
.icon-btn.danger { color: var(--red); }

/* ── Mobile mode bar ───────────────────────────────────── */
.mobile-modebar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.mobile-modebar::-webkit-scrollbar { display: none; }

.mmode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 14px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 0.72rem;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.mmode-btn:hover { background: #f5f5f5; }

.mmode-btn.active[data-mode="pauline"] { border-color: var(--blue);   color: #1a7fa8; background: #eef7fb; }
.mmode-btn.active[data-mode="alex"]   { border-color: var(--orange); color: #b07010; background: #fdf5e6; }
.mmode-btn.active[data-mode="alain"]  { border-color: var(--red);    color: var(--red); background: #fdecea; }
.mmode-btn.active[data-mode="sylvie"] { border-color: var(--red);    color: var(--red); background: #fdecea; }
.mmode-btn.active[data-mode="ferie"]  { border-color: var(--red);    color: var(--red); background: #fdecea; }
.mmode-btn.active[data-mode="erase"]  { border-color: #999;          color: #555; background: #f0f0f0; }

.mmode-dot {
  width: 18px;
  height: 18px;
}

/* ── Responsive: mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }

  .mobile-header,
  .mobile-modebar { display: flex; }

  .calendar-wrap {
    padding: 10px 6px 20px;
  }

  .calendar {
    box-shadow: none;
    border-radius: 0;
    padding: 12px 8px 16px;
  }

  #calendar-title {
    font-size: 1.3rem;
    margin-bottom: 10px;
  }

  .day-header {
    font-size: 0.65rem;
    padding: 6px 2px;
  }

  .day-cell {
    min-height: 70px;
    padding: 5px 4px 4px;
  }

  .day-num { font-size: 0.8rem; }

  .gp-label { font-size: 0.65rem; }
}

/* ── Print ─────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }

  body { background: #fff; }
  #app { display: block; }

  .calendar-wrap { padding: 0; }

  .calendar {
    box-shadow: none;
    border-radius: 0;
    padding: 8px 10px 10px;
    max-width: 100%;
  }

  #calendar-title { font-size: 1.6rem; margin-bottom: 8px; }

  .day-cell {
    min-height: 80px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .day-cell.bg-pauline { background: var(--blue) !important; }
  .day-cell.bg-alex    { background: var(--orange) !important; }

  .calendar-grid { page-break-inside: avoid; break-inside: avoid; }
}
