/* === Thème bleu clair modernisé (disposition d'origine, responsive final) === */
:root {
  --bg: #eaf1fb;
  --panel: #ffffff;
  --border: #dbeafe;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-lighter: #eff6ff;
  --accent-200: #bfdbfe;
  --accent-400: #60a5fa;
  --accent-700: #1d4ed8;
  --radius: 12px;
  --shadow: 0 6px 16px rgba(37, 99, 235, 0.10);
  --field-width: 200px;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

body {
  background: linear-gradient(135deg, var(--accent-lighter) 0%, var(--bg) 100%);
  background-attachment: fixed;
}

/* === Structure === */
.container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ✅ Disposition : calendrier à gauche | sidebar à droite */
.row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  padding: 16px;
}
@media (max-width: 980px) {
  .row { grid-template-columns: 1fr; }
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-light);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--accent-700);
}
.muted { color: var(--muted); }

/* Boutons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.3);
}
.btn:hover { background: var(--accent-700); transform: translateY(-1px); }
.btn:focus { outline: 3px solid rgba(37,99,235,.4); outline-offset: 2px; }
.btn.secondary {
  background: #fff;
  color: var(--accent-700);
  border: 1px solid var(--accent-200);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--accent-light); }

/* Formulaires généraux */
select, input[type="number"], input[type="password"] {
  border: 1px solid var(--accent-200);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  transition: .2s;
  box-sizing: border-box;
}
select:focus, input:focus {
  outline: 2px solid var(--accent-400);
  background: var(--accent-lighter);
}

/* Login */
.login {
  max-width: 420px;
  margin: 100px auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--accent-200);
}
.login h1 { margin: 0 0 12px; color: var(--accent-700); }

/* === Calendrier (2 mois, légèrement agrandi) === */
.calendar {
  display: grid;
  grid-template-columns: repeat(2, minmax(380px, 1fr));
  gap: 16px;
}
.cal {
  padding: 16px;
  background: var(--accent-lighter);
  border-radius: var(--radius);
}
.cal .cal-head {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: var(--accent-700);
  margin-bottom: 8px;
}

.weekdays, .days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.weekdays span {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

.day {
  aspect-ratio: 1/1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
  transition: .2s;
  position: relative;
  border: 1px solid var(--border);
  font-size: 15px;
}
.day:hover { background: var(--accent-light); }
.day.disabled { opacity: .35; cursor: default; background: #f0f4f8; }
.day.selected { outline: 2px solid var(--accent-700); background: var(--accent-light); }

.badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

/* Couleurs selon dispo (1–2 / 3–4 / 5+) */
.av-1-2 { background-color: #dbeafe; }
.av-3-4 { background-color: #bfdbfe; }
.av-5-plus { background-color: #93c5fd; }

/* Panneau latéral */
.sidebar { padding: 16px; }
.section {
  padding: 16px;
  border: 1px solid var(--accent-200);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
  overflow: hidden;
}
.section h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--accent-700);
}

/* Tableaux */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 6px;
  border-bottom: 1px solid var(--accent-light);
  text-align: left;
}
.table th {
  background: var(--accent-lighter);
  color: var(--accent-700);
}

/* Footer */
.footer {
  padding: 12px 16px;
  border-top: 1px solid var(--accent-200);
  background: var(--accent-lighter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

/* Helpers */
.notice {
  padding: 12px;
  border-radius: 8px;
  background: var(--accent-lighter);
  border: 1px solid var(--accent-200);
  color: var(--accent-700);
}
.total-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

/* === Section Ajouter / Retirer — alignement précis, sans dépassement === */
.section form {
  padding: 0 16px 12px 16px;
}

.section form label {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--field-width));
  align-items: center;
  gap: 8px;
}

.section form label select,
.section form label input[type="number"] {
  width: 100%;
  max-width: var(--field-width);
  justify-self: end;
  box-sizing: border-box;
  margin-right: 0;
}

/* Focus propre (halo interne) */
.section form label select:focus,
.section form label input[type="number"]:focus {
  outline: none;
  box-shadow: inset 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* Boutons alignés à droite du bloc */
.section .form-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-right: 16px;
}

/* ===== Responsive mobile ===== */
@media (max-width: 980px) {
  /* 1) Grille principale : une seule colonne */
  .row { grid-template-columns: 1fr; }

  /* 2) Deux mois du calendrier superposés */
  .calendar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* 3) Menu/contrôles adaptatifs */
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .header .controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header select { min-width: 140px; }

  /* 4) Sidebar en dessous, avec espacement */
  .sidebar { padding-top: 0; }

  /* 5) Jours plus petits */
  .weekdays, .days { gap: 4px; }
  .day { border-radius: 10px; font-size: 14px; }
  .badge { font-size: 11px; }
}

/* Très petits écrans */
@media (max-width: 440px) {
  .weekdays span { font-size: 12px; }
  .day { font-size: 13px; }
  .section form label { grid-template-columns: 1fr; }
  .section .form-row {
    flex-direction: column;
    justify-content: stretch;
    padding-right: 0;
  }
}
