/* ── Variables & Reset ──────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --c-primary:      #5B8DEF;
  --c-primary-dark: #3A6FD8;
  --c-accent:       #FF6B35;
  --c-accent-dark:  #E55A28;
  --c-bg:           #EEF2FF;
  --c-surface:      #FFFFFF;
  --c-text:         #111827;
  --c-muted:        #6B7280;
  --c-border:       #E5E7EB;
  --c-danger:       #EF4444;

  --radius:    18px;
  --radius-sm: 10px;
  --gap:       16px;

  --shadow:    0 2px 12px rgba(91,141,239,.10);
  --shadow-lg: 0 8px 32px rgba(91,141,239,.18);

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Screens ────────────────────────────────────────────────────────────── */

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ── Welcome ────────────────────────────────────────────────────────────── */

.welcome-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 24px 32px;
  gap: 16px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}

.welcome-logo {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.12));
}

.welcome-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--c-primary);
  letter-spacing: -.02em;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--c-muted);
  margin-top: -8px;
}

/* ── Card ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  width: 100%;
}

label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  padding: 13px 16px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-family: var(--font);
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-bg);
  outline: none;
  transition: border-color .2s;
  text-transform: uppercase;
  letter-spacing: .12em;
  min-width: 0;
}

input[type="text"]::placeholder {
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--c-border);
}

input[type="text"]:focus {
  border-color: var(--c-primary);
  background: #fff;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity .15s, transform .1s, background .15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(.96);
  opacity: .88;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover { background: var(--c-primary-dark); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-primary);
  border: 2px solid var(--c-primary);
  width: 100%;
}

.btn-secondary:hover { background: var(--c-bg); }

.btn-start {
  background: var(--c-accent);
  color: #fff;
  width: 100%;
  padding: 22px 20px;
  font-size: 1.15rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.btn-start:hover  { background: var(--c-accent-dark); }
.btn-start:active { transform: scale(.97); }

.btn-finish {
  background: var(--c-primary);
  color: #fff;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
}

.btn-finish:hover { background: var(--c-primary-dark); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
  background: var(--c-border);
  color: var(--c-text);
}

/* ── Divider ────────────────────────────────────────────────────────────── */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--c-muted);
  font-size: .85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ── App Header ─────────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  flex-shrink: 0;
}

.session-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--c-bg);
  border: none;
  border-radius: 20px;
  font-size: .95rem;
  font-weight: 800;
  color: var(--c-primary);
  cursor: pointer;
  letter-spacing: .18em;
  font-family: var(--font);
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.session-code-btn:hover { background: var(--c-border); }

.header-spacer { flex: 1; }

/* ── Main Content ───────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ── Active Bottle Card ─────────────────────────────────────────────────── */

.bottle-active {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
}

.timer-started {
  font-size: .85rem;
  color: var(--c-muted);
}

.timer-started strong {
  color: var(--c-text);
}

.timer-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.timer-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.timer-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -.02em;
}

/* ── Quantity Selector ──────────────────────────────────────────────────── */

.quantity-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.btn-qty {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid var(--c-primary);
  background: var(--c-surface);
  color: var(--c-primary);
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  font-family: var(--font);
}

.btn-qty:active {
  background: var(--c-primary);
  color: #fff;
  transform: scale(.9);
}

.qty-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 90px;
  justify-content: center;
}

.qty-value {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.qty-unit {
  font-size: 1rem;
  color: var(--c-muted);
  font-weight: 600;
}

/* ── Idle State ─────────────────────────────────────────────────────────── */

.bottle-idle {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ── Bottles Section ────────────────────────────────────────────────────── */

.bottles-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 24px;
}

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

.section-title {
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 0 2px;
}

.btn-section-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-surface);
  color: var(--c-muted);
  font-size: .72rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-section-action:hover {
  color: var(--c-primary);
  border-color: var(--c-primary);
  background: var(--c-bg);
}

.bottles-empty {
  text-align: center;
  color: var(--c-muted);
  padding: 28px 16px;
  font-size: .9rem;
}

.bottles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}

/* ── Bottle Item ────────────────────────────────────────────────────────── */

.bottle-item {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 14px 12px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.bottle-item-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.bottle-item-info {
  flex: 1;
  min-width: 0;
}

.bottle-item-time {
  font-size: .95rem;
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottle-item-meta {
  font-size: .78rem;
  color: var(--c-muted);
  margin-top: 2px;
}

.bottle-item-qty {
  font-size: .95rem;
  font-weight: 800;
  color: var(--c-primary);
  flex-shrink: 0;
  white-space: nowrap;
}

.bottle-item-qty.pending {
  color: var(--c-muted);
  font-weight: 500;
  font-size: .82rem;
}

.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-delete:hover {
  color: var(--c-danger);
  background: #FEF2F2;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--c-text);
  color: #fff;
  padding: 11px 22px;
  border-radius: 24px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .25s, transform .25s;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

.error-msg {
  margin-top: 10px;
  font-size: .85rem;
  color: var(--c-danger);
  font-weight: 500;
}

/* ── Récap journalier ───────────────────────────────────────────────────── */

.daily-recap {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.recap-stats {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.recap-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.recap-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1;
  white-space: nowrap;
}

.recap-label {
  font-size: .6rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.recap-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--c-border);
  flex-shrink: 0;
}

.btn-stats {
  flex-shrink: 0;
  border: none;
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 9px;
  cursor: pointer;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-stats:hover { background: var(--c-border); }

/* ── Modale ─────────────────────────────────────────────────────────────── */

@keyframes fadeOverlay {
  from { background: rgba(0,0,0,0); }
  to   { background: rgba(0,0,0,.48); }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeOverlay .2s ease;
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp .25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  position: sticky;
  top: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  z-index: 1;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Graphique ──────────────────────────────────────────────────────────── */

.chart-container {
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 12px 8px 4px;
  overflow: hidden;
}

/* ── Résumé stats ───────────────────────────────────────────────────────── */

.stats-dl {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stats-dl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--c-border);
}

.stats-dl-row:last-child { border-bottom: none; }

.stats-dl-row dt {
  font-size: .85rem;
  color: var(--c-muted);
  font-weight: 500;
}

.stats-dl-row dd {
  font-size: .9rem;
  font-weight: 700;
  color: var(--c-text);
  text-align: right;
}

.stats-sub {
  font-size: .78rem;
  color: var(--c-muted);
  font-weight: 400;
}
