/* ============================================================
   Módulo de Reserva · Diseño estilo Apple
   Foundation: system font, translucent materials, springs,
   negative tracking on display text, reduced-motion support.
   ============================================================ */

:root {
  --bg: #f5f5f7;
  --bg-elevated: rgba(255,255,255,0.72);
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: rgba(0,0,0,0.08);
  --accent: #007AFF;
  --accent-press: #0066d6;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9500;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-2: 0 2px 8px rgba(0,0,0,0.06), 0 24px 60px rgba(0,0,0,0.12);
  --radius: 20px;
  --radius-sm: 14px;
  --sans: system-ui, -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: rgba(28,28,30,0.66);
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #6e6e73;
    --sep: rgba(255,255,255,0.12);
    --accent: #0a84ff;
    --accent-press: #409cff;
    --shadow-1: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.5);
    --shadow-2: 0 2px 8px rgba(0,0,0,0.5), 0 24px 60px rgba(0,0,0,0.6);
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 20px env(safe-area-inset-bottom);
  position: relative;
}

/* ---------- Typography (tracking by size) ---------- */
h1, h2, h3 { letter-spacing: -0.02em; margin: 0; }
.display { font-size: clamp(1.9rem, 6vw, 2.6rem); line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; }
.title { font-size: 1.35rem; line-height: 1.15; font-weight: 600; }
.sub { font-size: 1.05rem; line-height: 1.3; font-weight: 600; }
.body { font-size: 1rem; color: var(--text-2); }
.caption { font-size: 0.78rem; color: var(--text-3); letter-spacing: 0.01em; }

/* ---------- Buttons (feedback on press, instant) ---------- */
.btn {
  --btn-bg: var(--accent);
  --btn-fg: #fff;
  appearance: none;
  border: none;
  border-radius: 980px;
  padding: 15px 24px;
  font-size: 1.02rem;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--btn-fg);
  background: var(--btn-bg);
  cursor: pointer;
  width: 100%;
  transition: transform 100ms ease-out, opacity 180ms ease, background 180ms ease;
  will-change: transform;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn--secondary { background: transparent; color: var(--accent); }
.btn--danger { background: var(--danger); }
.btn--ghost {
  background: var(--bg-elevated);
  color: var(--accent);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--sep);
}

/* ---------- Cards (bigger surfaces read thicker) ---------- */
.card {
  background: var(--bg-elevated);
  backdrop-filter: blur(24px) saturate(180%);
  border-radius: var(--radius);
  border: 1px solid var(--sep);
  box-shadow: var(--shadow-1);
  padding: 20px;
  margin-bottom: 16px;
}

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sep);
  transition: width 200ms ease, background 200ms ease;
}
.step-dot.active { width: 22px; border-radius: 4px; background: var(--accent); }

.step { display: none; will-change: transform, opacity; }
.step.active { display: block; }

/* ---------- Options grid (barbero / servicio) ---------- */
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  appearance: none; border: none; text-align: left;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--sep);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--sans); color: var(--text);
  cursor: pointer;
  transition: transform 100ms ease-out, border-color 180ms ease, background 180ms ease;
}
.opt:active { transform: scale(0.97); }
.opt.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.opt .price { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.opt .dur { font-size: 0.82rem; color: var(--text-2); }

/* ---------- Avatar circular de barbero (con borde delgado) ---------- */
.opt--barbero { display: flex; align-items: center; gap: 12px; }
.avatar-circ {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--sep);           /* borde delgado por defecto */
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 700; font-size: 1.15rem;
  overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sep) 60%, transparent);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.avatar-circ img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.opt.selected .avatar-circ {
  border-color: var(--accent);           /* borde de la marca al seleccionar */
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
.opt--barbero .barbero-info { min-width: 0; }
.opt--barbero .barbero-nombre { font-weight: 600; font-size: 0.98rem; }
.opt--barbero .barbero-desc { font-size: 0.78rem; color: var(--text-3); }

/* ---------- Time slots ---------- */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.slot {
  appearance: none; border: none;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--sep);
  border-radius: 14px;
  padding: 12px 8px;
  font-size: 0.95rem; font-weight: 600; font-family: var(--sans); color: var(--text);
  cursor: pointer;
  transition: transform 100ms ease-out, border-color 180ms ease, background 180ms ease;
}
.slot:active { transform: scale(0.96); }
.slot.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.slot:disabled { opacity: 0.3; cursor: not-allowed; text-decoration: line-through; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.input {
  width: 100%;
  appearance: none; border: none; outline: none;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--sep);
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 1.05rem; font-family: var(--sans); color: var(--text);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.input::placeholder { color: var(--text-3); }

/* ---------- Payment proof upload (1 of 2) ---------- */
.pay-upload {
  border: 2px dashed var(--sep);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease;
}
.pay-upload:hover, .pay-upload.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.pay-upload img { max-width: 100%; border-radius: 12px; margin-top: 12px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: calc(env(safe-area-inset-top) + 16px); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast {
  background: var(--bg-elevated);
  backdrop-filter: blur(24px) saturate(180%);
  color: var(--text);
  border: 1px solid var(--sep);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  padding: 14px 18px;
  font-size: 0.92rem; font-weight: 500;
  display: flex; gap: 10px; align-items: center;
  will-change: transform, opacity;
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.toast.success { border-color: color-mix(in srgb, var(--success) 50%, transparent); }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(8px); z-index: 300;
}
.loader.show { display: flex; }
.loader-ring { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sheets (iOS-style bottom sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
  background: var(--bg-elevated);
  backdrop-filter: blur(40px) saturate(180%);
  border-radius: 24px 24px 0 0;
  padding: 24px 24px calc(env(safe-area-inset-bottom) + 24px);
  box-shadow: var(--shadow-2);
  transform: translateY(100%);
  will-change: transform;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 20px; }

/* ---------- Brand header ---------- */
.brand-header { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-avatar {
  width: 52px; height: 52px; border-radius: 15px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.4rem;
  overflow: hidden; flex-shrink: 0;
}
.brand-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Summary ---------- */
.summary-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--sep); }
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--text-2); font-size: 0.95rem; }
.summary-value { font-weight: 600; text-align: right; }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; padding: 5px 10px; border-radius: 980px; }
.badge.pending { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge.paid { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.confirmed { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.expired { background: color-mix(in srgb, var(--text-3) 18%, transparent); color: var(--text-3); }

/* ---------- Countdown timer ---------- */
.timer { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.timer.warning { color: var(--danger); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
  .sheet { transform: none; opacity: 0; }
  .sheet.open { opacity: 1; }
  .toast, .step { transition: opacity 200ms ease; }
}

/* ---------- Utility ---------- */
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.hidden { display: none !important; }
