/* Design repris de la version Nuxt, écrit à la main : plus de Tailwind, donc
   plus d'étape de build ni de serveur de développement à exposer. */

:root {
  --bg: #0a0a0a;
  --surface: #121214;
  --surface-2: #1a1a1f;
  --border: #26262d;
  --text: #f5f5f7;
  --muted: #8a8a93;
  --accent: #ff5a1f;
  --accent-soft: #ff5a1f1a;
  --cse: #7c3aed;
  --success: #22c55e;
  --danger: #ef4444;
  --bar: rgba(10, 10, 10, .85);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Semaines paires : ardoise bleutée, franchement plus claire que le noir des
   semaines impaires. L'écart joue à la fois sur la luminosité et sur la teinte,
   une différence de couleur se repérant plus vite qu'un simple éclaircissement.
   Le jeu complet est décalé d'un même pas — sinon les cartes perdraient leur
   contraste sur le fond ; --muted est relevé pour rester lisible dessus. */
html.week-even {
  --bg: #1a1f2b;
  --surface: #232936;
  --surface-2: #2d3444;
  --border: #3d4557;
  --muted: #9aa1ad;
  --bar: rgba(26, 31, 43, .85);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Pas de cadre de focus au clic ou au tap : il reste affiché après coup sur
   mobile. On le conserve pour la navigation au clavier (:focus-visible). */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

html, body {
  margin: 0;
  background: var(--bg);
  transition: background-color .25s ease;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { padding-top: env(safe-area-inset-top); }

input, select, textarea { font-family: inherit; font-size: 100%; }

/* Remise à zéro du rendu natif des boutons.
   `border: 0` ne suffit pas : sans `appearance: none`, Safari (iOS surtout)
   dessine son propre encadré clair, visible sur fond sombre. */
button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ------------------------------------------------------------- primitives */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1rem;
  border: 0;
  border-radius: .75rem;
  font-weight: 500;
  font-size: .875rem;
  cursor: pointer;
  transition: transform .1s, background .15s, filter .15s;
  background: var(--surface-2);
  color: var(--text);
}
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-icon { padding: .5rem .75rem; }
/* Lien textuel, pas un bouton : sans la classe .btn, il faut neutraliser
   explicitement la bordure et le fond que le navigateur applique à <button>. */
.btn-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
  transition: color .15s;
}

/* Outils de la semaine : photo à gauche si elle existe, marquage à droite. */
.week-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: -.25rem 0;
}
.week-tools .btn-link:only-child { margin-left: auto; }

/* Visionneuse : l'image occupe la largeur, on peut la parcourir au doigt. */
.photo-view {
  width: 100%;
  border-radius: .5rem;
  border: 1px solid var(--border);
  display: block;
}
.photo-scroll { overflow: auto; max-height: 60vh; }
.photo-scroll img { max-width: none; width: 200%; }
@media (min-width: 640px) { .photo-scroll img { width: 100%; } }

.card {
  background: var(--surface);
  transition: background-color .25s ease;
  border: 1px solid var(--border);
  border-radius: 1rem;
}

.input {
  width: 100%;
  padding: .625rem .75rem;
  border-radius: .75rem;
  font-size: 16px; /* évite le zoom automatique sur iOS */
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: .125rem .5rem;
  border-radius: .375rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ----------------------------------------------------------------- entête */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 42rem;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.week-switch {
  flex: 1;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: center;
}
.week-switch .label { font-size: .75rem; color: var(--muted); }
.week-switch .value { font-size: 1.125rem; font-weight: 700; line-height: 1.2; }
.week-switch .range { font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------------ corps */

main {
  flex: 1;
  max-width: 42rem;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 8rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  touch-action: pan-y;
}

.stats { padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.stats-row { display: flex; align-items: center; justify-content: space-between; }
.stats-label {
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.stats-total { font-size: 1.875rem; font-weight: 700; }
.stats-cse { font-size: 1.25rem; font-weight: 600; color: var(--cse); }
.stats-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .75rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}
.stats-codes {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}
.stats-code { display: flex; align-items: center; gap: .375rem; font-size: .75rem; }

.day {
  width: 100%;
  text-align: left;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  cursor: pointer;
  color: inherit;
  transition: transform .1s, border-color .15s;
}
.day:active { transform: scale(.99); }
.day.today { box-shadow: 0 0 0 2px var(--accent); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.day-name { font-size: 1rem; font-weight: 600; text-transform: capitalize; }
.day-date { font-size: .75rem; color: var(--muted); margin-left: .5rem; }
.day-total { font-size: .875rem; font-weight: 700; }
.day-pause { font-size: 10px; color: var(--muted); margin-left: .25rem; }
.day-status { font-size: .75rem; color: var(--muted); font-style: italic; }
.shift {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .75rem;
  border-radius: .5rem;
  background: var(--surface-2);
  transition: background-color .25s ease;
}
.shift-time { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875rem; }
.shift-len { font-size: .75rem; color: var(--muted); margin-left: .75rem; }

.footer-links { display: flex; justify-content: center; gap: 1rem; margin-top: .5rem; }

.bottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--bar);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottombar-inner {
  max-width: 42rem;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  gap: .5rem;
}
.bottombar .btn { flex: 1; }

/* --------------------------------------------------------------- modales */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  animation: fade .2s ease;
}
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } }

.sheet {
  position: relative;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem 1rem 0 0;
  animation: slide-up .25s cubic-bezier(.32, .72, 0, 1);
}
@media (min-width: 640px) { .sheet { max-width: 32rem; border-radius: 1rem; } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.sheet-close {
  background: none;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.sheet-body {
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sheet-actions { display: flex; gap: .5rem; padding-top: .5rem; }
.sheet-actions .btn { flex: 1; }

@keyframes fade { from { opacity: 0 } }
@keyframes slide-up { from { transform: translateY(100%) } }

/* ---------------------------------------------------------------- divers */

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field > span { font-size: .75rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.err { color: var(--danger); font-size: .875rem; white-space: pre-wrap; word-break: break-word; }
.ok { color: var(--success); font-size: .875rem; }

.hist-row {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-radius: .5rem;
  background: var(--surface-2);
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.hist-row.empty { opacity: .45; }
.hist-bar { height: .375rem; border-radius: 999px; background: var(--accent); min-width: 2px; }

.cal-month { margin-bottom: 1rem; }
.cal-title { font-size: .875rem; font-weight: 600; margin-bottom: .375rem; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: .25rem;
  font-size: 10px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-cell.out { opacity: .25; }
.cal-dow { font-size: 10px; color: var(--muted); text-align: center; }

.diag img {
  width: 100%;
  border-radius: .5rem;
  border: 1px solid var(--border);
}
.diag pre {
  max-height: 12rem;
  overflow: auto;
  padding: .5rem;
  border-radius: .5rem;
  background: rgba(0, 0, 0, .3);
  font-size: .75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card { width: 100%; max-width: 22rem; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.login-card h1 { margin: 0; font-size: 1.25rem; }

.spinner {
  display: inline-block;
  width: .875rem;
  height: .875rem;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* Effets de survol réservés aux pointeurs qui survolent réellement.
   Sur mobile, :hover reste appliqué après un tap : sans ce garde-fou, chaque
   jour touché conservait son contour orange, qui doit signaler le jour même. */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
  .btn-ghost:hover:not(:disabled) { background: var(--border); }
  .btn-link:hover { color: #fff; }
  .day:hover { border-color: var(--accent); }
  .sheet-close:hover { color: #fff; }
  .hist-row:hover { background: var(--border); }
}
