/* ==========================================================================
   AGENDO · Componentes de interfaz (app de reservas y panel)
   ========================================================================== */

.muted { color: var(--text-2); }
.eyebrow {
  font: 700 0.72rem/1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2);
}
.stack > * + * { margin-top: var(--stack, 12px); }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ico { flex: none; }

/* ---------- Botones ---------- */
.btn {
  --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-line: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-line);
  font-weight: 650; font-size: 0.95rem; letter-spacing: -0.005em; white-space: nowrap; text-decoration: none;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn.is-loading { opacity: 0.55; pointer-events: none; }
.btn--primary { --btn-bg: var(--mandarina); --btn-fg: var(--tinta); --btn-line: transparent; box-shadow: 0 1px 0 rgb(255 255 255 / 0.35) inset, 0 8px 20px -10px rgb(255 90 31 / 0.8); }
.btn--primary:hover { --btn-bg: var(--mandarina-2); border-color: transparent; }
.btn--ink { --btn-bg: var(--text); --btn-fg: var(--bg); --btn-line: transparent; }
.btn--ink:hover { border-color: transparent; opacity: 0.92; }
.btn--ghost { --btn-bg: transparent; --btn-line: transparent; }
.btn--ghost:hover { --btn-bg: var(--sunken); border-color: transparent; }
.btn--danger { --btn-bg: var(--granada); --btn-fg: #fff; --btn-line: transparent; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 0.86rem; }
.btn--lg { min-height: 56px; padding: 0 26px; font-size: 1.02rem; }
.btn--block { width: 100%; }
.btn .btn__orb {
  display: grid; place-items: center; width: 30px; height: 30px; margin-right: -10px; border-radius: 50%;
  background: rgb(23 20 15 / 0.1); transition: transform var(--dur-2) var(--ease-spring);
}
.btn:hover .btn__orb { transform: translate(2px, -1px) scale(1.06); }
.is-loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--text);
  transition: background-color var(--dur-1), transform var(--dur-1) var(--ease-out);
}
.icon-btn:hover { background: var(--sunken); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 0.84rem; font-weight: 600; color: var(--text); }
.field .hint { font-size: 0.8rem; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  transition: border-color var(--dur-1), box-shadow var(--dur-2) var(--ease-out);
  font-size: 1rem; /* evita el zoom de iOS */
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236E665B' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--mandarina); box-shadow: 0 0 0 4px rgb(255 90 31 / 0.18); }
.input::placeholder, .textarea::placeholder { color: var(--text-2); opacity: 1; }
.input[aria-invalid="true"] { border-color: var(--granada); }
.form-grid { display: grid; gap: 14px; }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-error { color: var(--granada); font-size: 0.88rem; font-weight: 550; }
.input-prefix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; }
.input-prefix:focus-within { border-color: var(--mandarina); box-shadow: 0 0 0 4px rgb(255 90 31 / 0.18); }
.input-prefix span { display: grid; place-items: center; padding: 0 4px 0 14px; color: var(--text-2); font-size: 0.92rem; white-space: nowrap; }
.input-prefix .input { border: 0; box-shadow: none !important; background: transparent; padding-left: 2px; }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 46px; height: 28px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background-color var(--dur-2) var(--ease-out); flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur-2) var(--ease-spring); }
.switch input:checked + .switch__track { background: var(--salvia); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2.5px solid var(--focus); outline-offset: 2px; }

/* Casillas */
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 0.92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--mandarina); margin-top: 1px; flex: none; }

/* Control segmentado */
.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-pill); background: var(--sunken); }
.segmented button { min-height: 34px; padding: 0 14px; border-radius: var(--r-pill); font-weight: 600; font-size: 0.86rem; color: var(--text-2); transition: background-color var(--dur-2), color var(--dur-2); }
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2), color var(--dur-2), transform var(--dur-1);
}
.chip:hover { border-color: var(--line-strong); }
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--confirmed { background: var(--salvia-tint); color: var(--salvia); }
.pill--pending { background: var(--miel-tint); color: #8A5A00; }
:root[data-theme="dark"] .pill--pending { color: var(--miel); }
.pill--completed { background: var(--sunken); color: var(--text-2); }
.pill--cancelled { background: var(--granada-tint); color: var(--granada); }
.pill--no_show { background: var(--granada-tint); color: var(--granada); }
.pill--plain::before { display: none; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.card--flat { background: var(--surface); }
.bezel { padding: 6px; border-radius: var(--r-xl); background: color-mix(in srgb, var(--text) 4%, transparent); border: 1px solid color-mix(in srgb, var(--text) 6%, transparent); }
.bezel > .card { border-radius: calc(var(--r-xl) - 6px); border-color: transparent; box-shadow: var(--shadow-1); }

.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 700; font-family: var(--font-display); font-size: 0.95rem; color: #fff; background: var(--c, var(--tinta)); flex: none; letter-spacing: 0; }
.avatar--sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar--lg { width: 64px; height: 64px; font-size: 1.3rem; }

.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 40px 20px; color: var(--text-2); }
.empty .ico { width: 40px; height: 40px; color: var(--line-strong); }
.empty h3 { color: var(--text); font-size: 1.15rem; }

.skeleton { position: relative; overflow: hidden; background: var(--sunken); border-radius: var(--r-sm); }

.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* ---------- Hojas (dialog) ---------- */
.sheet {
  padding: 0; border: 0; background: transparent; color: var(--text); max-width: none; max-height: none;
  width: 100%; height: 100%; margin: 0; inset: 0; display: grid; align-items: end; justify-items: center;
}
.sheet::backdrop { background: rgb(23 20 15 / 0.42); backdrop-filter: blur(3px); animation: fade-in var(--dur-2) var(--ease-out); }
.sheet__inner {
  width: min(560px, 100%); max-height: min(92dvh, 860px); display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-3);
  animation: sheet-up var(--dur-3) var(--ease-swift);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet--wide .sheet__inner { width: min(760px, 100%); }
.sheet__head { display: flex; align-items: center; gap: 12px; padding: 18px 16px 10px 24px; }
.sheet__title { font-size: 1.35rem; flex: 1; }
.sheet__body { padding: 6px 24px 20px; overflow-y: auto; overscroll-behavior: contain; }
.sheet__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 24px 18px; border-top: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; }
.sheet.is-closing .sheet__inner { animation: sheet-down 200ms var(--ease-out) forwards; }
.sheet.is-closing::backdrop { opacity: 0; transition: opacity 200ms; }
.sheet--confirm .sheet__inner { width: min(440px, 100%); }
@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet__inner { border-radius: var(--r-xl); animation-name: sheet-pop; }
  .sheet.is-closing .sheet__inner { animation-name: sheet-fade; }
  .sheet--side { justify-items: end; align-items: stretch; }
  .sheet--side .sheet__inner { height: 100dvh; max-height: none; border-radius: var(--r-xl) 0 0 var(--r-xl); animation-name: sheet-left; width: min(480px, 100%); }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes sheet-pop { from { transform: translateY(16px) scale(0.98); opacity: 0; } }
@keyframes sheet-fade { to { transform: translateY(8px) scale(0.98); opacity: 0; } }
@keyframes sheet-left { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- Avisos ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 13px 18px; border-radius: var(--r-md); background: var(--tinta); color: var(--papel); font-weight: 550; font-size: 0.93rem; box-shadow: var(--shadow-3); transform: translateY(16px) scale(0.98); opacity: 0; transition: transform var(--dur-3) var(--ease-spring), opacity var(--dur-2); }
.toast.is-in { transform: none; opacity: 1; }
.toast--success { background: var(--salvia); color: #fff; }
.toast--error { background: var(--granada); color: #fff; }

/* Distintivo demo */
.demo-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--miel-tint); color: #7A4F00; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
:root[data-theme="dark"] .demo-badge { color: var(--miel); }

/* Revelado suave al cargar vistas */
.enter { animation: enter var(--dur-3) var(--ease-out) both; }
.enter-stagger > * { animation: enter var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }
