/* ========================================
   Mes Horaires — Styles Mobile-First
   Palette : blanc, gris clair, bleu #2563EB,
             vert #16A34A, orange #EA580C
   ======================================== */

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

:root {
  --bleu:    #2563EB;
  --bleu-cl: #DBEAFE;
  --vert:    #16A34A;
  --vert-cl: #DCFCE7;
  --orange:  #EA580C;
  --ora-cl:  #FFEDD5;
  --gris-f:  #6B7280;
  --gris-m:  #D1D5DB;
  --gris-cl: #F3F4F6;
  --blanc:   #FFFFFF;
  --texte:   #111827;
  --radius:  12px;
  --ombre:   0 2px 8px rgba(0,0,0,.06);

  /* Couleurs mode clair (défaut) */
  --bg-body: #fafbfc;
  --bg-card: #FFFFFF;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --border-color: #D1D5DB;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
}

body.dark-mode {
  --bg-body: #0f172a;
  --bg-card: #1a254e;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: #334155;
  --shadow: 0 4px 12px rgba(0,0,0,.30);
}

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  background: var(--bg-body);
  color: var(--text-primary);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-body);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  transition: background .3s, color .3s;
  overflow-x: hidden;
}

/* ========================================
   ÉCRANS (vues)
   ======================================== */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
  overflow-y: auto;
}
.screen.active {
  display: flex;
}

/* ========================================
   HEADER GLOBAL
   ======================================== */
.header {
  background: var(--bleu);
  color: var(--blanc);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,.20);
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  flex: 1;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--blanc);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s;
}
.btn-icon:hover, .btn-icon:focus {
  background: rgba(255,255,255,.20);
}

/* ========================================
   VUE CALENDRIER
   ======================================== */
#screen-calendar .header {
  justify-content: space-between;
}

/* Récapitulatif rapide calendrier */
.cal-recap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 6px;
  background: var(--bg-body);
  box-sizing: border-box;
  width: 100%;
}

.recap-stat {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  min-width: 0;
}

.recap-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.recap-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.recap-value.solde-pos {
  color: var(--vert);
}

.recap-value.solde-neg {
  color: var(--orange);
}

/* Navigation mois */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 8px;
  background: var(--bg-body);
}

.cal-nav button {
  background: var(--blanc);
  border: 1.5px solid var(--gris-m);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.cal-nav button:hover { background: var(--bleu); color: var(--blanc); border-color: var(--bleu); }

.cal-nav-title {
  flex: 1;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: capitalize;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .15s;
}
.cal-nav-title:hover { background: var(--gris-cl); }

/* Grille calendrier */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 6px 12px;
}

/* En-têtes jours de semaine */
.cal-dow {
  text-align: center;
  font-size: .70rem;
  font-weight: 700;
  color: var(--gris-f);
  padding: 4px 0 6px;
  text-transform: uppercase;
}
.cal-dow.weekend { color: var(--orange); }

/* Cellule jour */
.cal-day {
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  background: var(--bg-card);
  border: none;
  transition: background .15s, box-shadow .15s;
  height: 64px;
  position: relative;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  color: var(--text-primary);
}

.cal-day:hover { background: var(--gris-cl); }

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

.cal-day.today {
  border: 2.5px solid var(--bleu);
  background: var(--bleu-cl);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(37, 99, 235, .35);
}

.cal-day.weekend .day-num { color: var(--orange); }

.day-num {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

/* Indicateur coloré sous le numéro */
.day-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-green  { background: var(--vert); box-shadow: 0 0 8px rgba(22, 163, 74, .40); }
.dot-orange { background: var(--orange); box-shadow: 0 0 8px rgba(234, 88, 12, .40); }
.dot-grey   { background: var(--gris-m); }

/* Résumé solde calendrier */
.cal-summary {
  padding: 12px 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.solde-badge {
  padding: 14px 20px;
  border-radius: 20px;
  font-weight: 700;
  text-align: center;
  min-width: 160px;
  line-height: 1.4;
  font-size: 0.95rem;
}

.solde-badge.positif {
  background: #16A34A;
  color: white;
}

.solde-badge.negatif {
  background: #DC2626;
  color: white;
}

.solde-badge.neutre {
  background: var(--gris-m);
  color: var(--text-primary);
}

/* ========================================
   SÉLECTEUR D'ANNÉE (modale légère)
   ======================================== */
.year-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.40);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.year-picker-overlay.open {
  display: flex;
}

.year-picker-box {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 20px;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.year-picker-box h3 {
  text-align: center;
  margin-bottom: 14px;
  font-size: 1rem;
}

.year-picker-box input[type="number"] {
  width: 100%;
  padding: 10px;
  border: 1.5px solid var(--gris-m);
  border-radius: 8px;
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 14px;
}

.year-picker-actions {
  display: flex;
  gap: 10px;
}
.year-picker-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-size: .95rem;
  cursor: pointer;
  font-weight: 600;
}
#btn-year-cancel { background: var(--gris-cl); color: var(--texte); }
#btn-year-ok     { background: var(--bleu);    color: var(--blanc); }

/* ========================================
   VUE JOUR
   ======================================== */
#screen-day .content {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}

/* Boutons contextuels (arrivée/départ) */
.contextual-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-contextual {
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  color: white;
  text-align: center;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-contextual.arrival {
  background: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .4);
}

.btn-contextual.arrival:active {
  transform: scale(.98);
  box-shadow: 0 2px 6px rgba(239, 68, 68, .4);
}

.btn-contextual.departure {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(220, 38, 38, .4);
}

.btn-contextual.departure:active {
  transform: scale(.98);
  box-shadow: 0 2px 6px rgba(220, 38, 38, .4);
}

/* Section carte */
.card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius);
  padding: 16px 12px;
  box-shadow: var(--shadow);
  color: var(--text-primary);
}

.card-title {
  font-size: .80rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Inputs horaires */
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

input[type="time"],
input[type="text"],
input[type="number"] {
  background: var(--bg-body);
  color: var(--text-primary);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
}

input[type="time"]::placeholder,
input[type="text"]::placeholder,
input[type="number"]::placeholder {
  color: var(--text-secondary);
}
}
.field-row:last-child { margin-bottom: 0; }

.field-row label {
  font-size: .90rem;
  color: var(--gris-f);
  min-width: 90px;
}

.field-row input[type="time"] {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--gris-m);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--gris-cl);
  cursor: pointer;
  transition: border-color .15s;
}
.field-row input[type="time"]:focus {
  outline: none;
  border-color: var(--bleu);
  background: var(--blanc);
}

/* Liste de pauses / tâches */
.list-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.pause-item, .tache-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--gris-cl);
  border-radius: 8px;
  padding: 6px 8px;
  flex-wrap: wrap;
}

.pause-item input[type="number"],
.tache-item input[type="time"] {
  width: 60px;
  padding: 5px 6px;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-body);
  text-align: center;
}
.pause-item input[type="number"]:focus,
.tache-item input[type="time"]:focus {
  outline: none;
  border-color: var(--bleu);
}

.pause-item input[type="text"],
.pause-item select,
.tache-item input[type="text"] {
  flex: 1;
  min-width: 80px;
  padding: 5px 6px;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-body);
  color: var(--text-primary);
}
.pause-item input[type="text"]:focus,
.pause-item select:focus,
.tache-item input[type="text"]:focus {
  outline: none;
  border-color: var(--bleu);
}

.pause-item span, .tache-item span {
  font-size: .80rem;
  color: var(--gris-f);
  white-space: nowrap;
}

.btn-delete {
  background: none;
  border: none;
  color: var(--gris-f);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.btn-delete:hover { color: #DC2626; background: #FEE2E2; }

.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px dashed var(--gris-m);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: .90rem;
  color: var(--bleu);
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.btn-add:hover {
  background: var(--bleu-cl);
  border-color: var(--bleu);
}

/* ========================================
   RÉSUMÉ JOURNALIER
   ======================================== */
.summary-card {
  background: var(--gris-cl);
  border-radius: var(--radius);
  padding: 16px;
  border: 1.5px solid var(--gris-m);
}

.summary-title {
  font-size: .80rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gris-f);
  margin-bottom: 12px;
}

.summary-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .92rem;
}
.summary-row .label { color: var(--gris-f); }
.summary-row .value { font-weight: 700; }

.summary-row.total .value { color: var(--bleu); font-size: 1.05rem; }

/* Ligne d'info sur le quota de pause légale */
.summary-row.quota-row {
  display: block;
  padding-top: 0;
  margin-top: -4px;
}
.quota-info {
  font-size: .78rem;
  font-style: italic;
}
.quota-auto { color: var(--gris-f); }
.quota-full { color: var(--vert); }

/* Barre de progression */
.progress-bar-wrap {
  background: var(--gris-m);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--bleu);
  transition: width .4s ease;
}
.progress-bar-fill.done { background: var(--vert); }

.summary-message {
  text-align: center;
  font-size: .88rem;
  font-weight: 700;
  padding: 8px;
  border-radius: 8px;
}
.summary-message.ok    { color: var(--vert);   background: var(--vert-cl); }
.summary-message.nok   { color: var(--orange); background: var(--ora-cl); }
.summary-message.empty { color: var(--gris-f); background: var(--gris-cl); border: 1.5px solid var(--gris-m); }

/* ========================================
   VUE RÉCAPITULATIF
   ======================================== */
#screen-recap .content {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}

.recap-section-title {
  font-size: .80rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gris-f);
  margin-bottom: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-box {
  background: var(--gris-cl);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  border: 1.5px solid var(--gris-m);
}

.stat-box .stat-val {
  font-size: 1.40rem;
  font-weight: 800;
  color: var(--bleu);
  line-height: 1.1;
}
.stat-box .stat-lbl {
  font-size: .75rem;
  color: var(--gris-f);
  margin-top: 4px;
}

.stat-box.ok  .stat-val { color: var(--vert); }
.stat-box.nok .stat-val { color: var(--orange); }

/* Bouton copier */
.btn-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bleu);
  color: var(--blanc);
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}
.btn-copy:hover { background: #1d4ed8; }
.btn-copy.copied { background: var(--vert); }

/* ========================================
   PAUSE — Bouton Start / Stop & Chrono
   ======================================== */

/* Gros bouton "Démarrer une pause" — facile à tapper sur mobile */
.btn-pause-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bleu);
  color: var(--blanc);
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
  min-height: 52px;
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.btn-pause-start:hover { background: #1d4ed8; }
.btn-pause-start:active { transform: scale(.98); }

/* Zone affichée quand une pause est en cours */
.pause-active-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--ora-cl);
  border: 2px solid var(--orange);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

/* Chrono en temps réel */
.pause-chrono {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}

/* Bouton "Arrêter la pause" — rouge/orange */
.btn-pause-stop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--orange);
  color: var(--blanc);
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  min-height: 48px;
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(234,88,12,.25);
}
.btn-pause-stop:hover { background: #c2410c; }
.btn-pause-stop:active { transform: scale(.98); }

/* ========================================
   SOLDE HEURES SUPPLÉMENTAIRES — Vue Jour
   ======================================== */

.solde-jour {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--blanc);
  border-radius: 8px;
  border: 1.5px solid var(--gris-m);
  font-size: .92rem;
}

.solde-jour .solde-label {
  color: var(--gris-f);
  font-weight: 600;
}

.solde-jour .solde-value {
  font-weight: 800;
  font-size: 1rem;
}

/* ========================================
   SOLDE HEURES SUPPLÉMENTAIRES — Récapitulatif
   ======================================== */

.solde-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.solde-card {
  background: var(--gris-cl);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  border: 1.5px solid var(--gris-m);
}

.solde-card-total {
  border-color: var(--bleu);
  background: var(--bleu-cl);
}

.solde-card-lbl {
  font-size: .75rem;
  color: var(--gris-f);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.solde-card-val {
  font-size: 1.30rem;
  font-weight: 800;
  color: var(--bleu);
  line-height: 1.1;
}

/* Grande valeur pour le solde total */
.solde-total-big {
  font-size: 1.55rem;
}

/* Couleurs positif / négatif (partagées Vue Jour + Récap) */
.solde-pos { color: var(--vert); }
.solde-neg { color: var(--orange); }

/* ========================================
   TOAST NOTIFICATION
   ======================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1F2937;
  color: var(--blanc);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.30);
  transition: transform .25s ease;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ========================================
   RESPONSIVE — tablette / desktop
   ======================================== */
@media (min-width: 520px) {
  body {
    box-shadow: 0 0 30px rgba(0,0,0,.10);
    min-height: 100vh;
  }
}

/* Assure des tap targets confortables */
button, input, [role="button"] {
  min-height: 40px;
}
