/* =========================================================================
   Clari's Cake Shop · Sistema de diseño compartido (clientes + admin)
   Colores tomados del logo: turquesa #30A29A, dorado #D3AA2E, crema #EFE1BE.
   Fuentes: Pacifico (marca), Fredoka (títulos/botones), Nunito (texto).
   ========================================================================= */

:root {
  color-scheme: light;

  /* Turquesa */
  --teal-50: #ecf7f5;
  --teal-100: #d3eeea;
  --teal-200: #a9ddd6;
  --teal-300: #6fc4b9;
  --teal-400: #30a29a;   /* turquesa del logo (decorativo / textos grandes) */
  --teal-500: #22897f;
  --teal-600: #1f7d76;   /* botones primarios: contraste AA con blanco */
  --teal-700: #19665f;
  --teal-800: #144f4a;

  /* Dorado */
  --gold-50: #fbf5e2;
  --gold-100: #f6e9c0;
  --gold-200: #ecd58c;
  --gold-400: #d3aa2e;   /* dorado del logo */
  --gold-500: #c49a22;
  --gold-600: #a07c14;
  --gold-700: #7c600f;   /* texto dorado sobre crema */

  /* Crema */
  --cream-0: #fffdf7;    /* superficies (tarjetas) */
  --cream-50: #fcf7ea;   /* fondo de página */
  --cream-100: #f7eed6;
  --cream-200: #efe1be;  /* crema del logo */
  --cream-300: #e4d1a3;

  /* Tinta */
  --ink-900: #1d3431;
  --ink-700: #3b524f;
  --ink-500: #677a77;
  --ink-300: #a3b0ad;

  /* Semánticos */
  --primary: var(--teal-600);
  --primary-hover: var(--teal-700);
  --accent: var(--gold-400);
  --bg: var(--cream-50);
  --surface: var(--cream-0);
  --surface-2: var(--cream-100);
  --line: #e8dcbc;
  --line-strong: #d9c79a;
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --danger: #b42318;
  --danger-bg: #fdecea;
  --success: var(--teal-600);
  --success-bg: var(--teal-50);
  --warning: var(--gold-700);
  --warning-bg: var(--gold-50);

  /* Estados de pedido */
  --st-pendiente: #a07c14;  --st-pendiente-bg: #fbf1d3;
  --st-listo: #1f7d76;      --st-listo-bg: #dcf2ee;
  --st-entregado: #3b6b4f;  --st-entregado-bg: #e3f0e7;
  --st-cancelado: #b42318;  --st-cancelado-bg: #fdecea;

  /* Tipografía */
  --font-brand: "Pacifico", "Brush Script MT", cursive;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Forma */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(29, 52, 49, .06), 0 1px 3px rgba(29, 52, 49, .08);
  --shadow-md: 0 4px 14px rgba(29, 52, 49, .10);
  --shadow-lg: 0 14px 40px rgba(29, 52, 49, .18);
  --shadow-gold: 0 0 0 3px var(--gold-100);

  /* Espaciado */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  --header-h: 64px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0 0 var(--s-3); color: var(--ink-900); }
h1 { font-size: clamp(1.6rem, 4vw + .6rem, 2.2rem); }
h2 { font-size: clamp(1.3rem, 2vw + .7rem, 1.6rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 var(--s-3); }
a { color: var(--teal-600); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-400); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--gold-100); }
.brand-script { font-family: var(--font-brand); font-weight: 400; color: var(--teal-400); letter-spacing: .3px; }
.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.money { font-family: var(--font-head); font-weight: 600; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 var(--s-4); }
.container--narrow { max-width: 560px; }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack--lg { gap: var(--s-5); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-4) 0; }
.divider--dashed { background: none; border-top: 2px dashed var(--line-strong); height: 0; }

/* ---------- Encabezado ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4);
  background: rgba(252, 247, 234, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header__logo { height: 46px; width: auto; }
.app-header__title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; line-height: 1.1; }
.app-header__title small { display: block; font-family: var(--font-body); font-weight: 600; font-size: .75rem; color: var(--text-muted); }

/* ---------- Botones ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink-900); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 46px; padding: 10px 20px;
  border-radius: var(--r-pill); border: 1.5px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-family: var(--font-head); font-weight: 600; font-size: 1rem; line-height: 1;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: transform .15s var(--ease-out), background-color .2s, box-shadow .2s, border-color .2s, opacity .2s;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { --btn-bg: var(--teal-600); --btn-fg: #fff; --btn-bd: var(--teal-600); }
.btn--primary:hover { --btn-bg: var(--teal-700); --btn-bd: var(--teal-700); }
.btn--gold { --btn-bg: var(--gold-400); --btn-fg: var(--ink-900); --btn-bd: var(--gold-400); }
.btn--gold:hover { --btn-bg: var(--gold-500); --btn-bd: var(--gold-500); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--teal-700); }
.btn--ghost:hover { --btn-bg: var(--teal-50); box-shadow: none; }
.btn--danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-bd: #f0b8b2; }
.btn--danger:hover { --btn-bg: var(--danger-bg); }
.btn--whatsapp { --btn-bg: #1f9e55; --btn-fg: #fff; --btn-bd: #1f9e55; }
.btn--whatsapp:hover { --btn-bg: #18864a; --btn-bd: #18864a; }
.btn--block { width: 100%; }
.btn--lg { min-height: 56px; font-size: 1.1rem; padding: 14px 26px; }
.btn--sm { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.btn--icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn .spinner { width: 18px; height: 18px; border-width: 2.5px; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s-5);
}
.card--flat { box-shadow: none; }
.card--teal { background: linear-gradient(160deg, var(--teal-400), var(--teal-600)); color: #fff; border-color: transparent; }
.card--teal h1, .card--teal h2, .card--teal h3 { color: #fff; }
.card--gold { background: linear-gradient(160deg, var(--gold-50), var(--gold-100)); border-color: var(--gold-200); }
.card--interactive { cursor: pointer; transition: transform .2s var(--ease-out), box-shadow .2s, border-color .2s; }
.card--interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--teal-200); }
.card--interactive:active { transform: translateY(0) scale(.99); }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-family: var(--font-head); font-weight: 600; font-size: .95rem; color: var(--ink-700); }
.field__hint { font-size: .82rem; color: var(--text-muted); }
.field__error { font-size: .85rem; color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 50px;
  padding: 12px 16px;
  background: #fff; border: 1.5px solid var(--line-strong); border-radius: var(--r-md);
  font-size: 1.05rem;
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal-400); box-shadow: 0 0 0 4px var(--teal-100); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.input--lg { font-size: 1.35rem; font-family: var(--font-head); letter-spacing: 1px; text-align: center; }
.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--teal-600); }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 48px; height: 28px; border-radius: 99px; background: var(--ink-300); position: relative; transition: background .2s; 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-sm); transition: transform .25s var(--ease-spring); }
.switch input:checked + .switch__track { background: var(--teal-600); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--gold-400); outline-offset: 2px; }

/* ---------- Chips (selección de fecha, filtros) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--r-pill); border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink-700);
  font-family: var(--font-head); font-weight: 500; cursor: pointer;
  transition: all .2s var(--ease-out);
}
.chip:hover { border-color: var(--teal-300); }
.chip.is-selected, .chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--teal-600); border-color: var(--teal-600); color: #fff; box-shadow: var(--shadow-sm); }
.chip[disabled], .chip.is-disabled { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.chip__count { background: rgba(0,0,0,.08); border-radius: 99px; padding: 0 8px; font-size: .8rem; }
.chip.is-selected .chip__count { background: rgba(255,255,255,.25); }

/* ---------- Insignias de estado ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-family: var(--font-head); font-weight: 600; font-size: .8rem; letter-spacing: .2px;
  background: var(--surface-2); color: var(--ink-700); white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge--plain::before { display: none; }
.badge--pendiente { background: var(--st-pendiente-bg); color: var(--st-pendiente); }
.badge--listo { background: var(--st-listo-bg); color: var(--st-listo); }
.badge--entregado { background: var(--st-entregado-bg); color: var(--st-entregado); }
.badge--cancelado { background: var(--st-cancelado-bg); color: var(--st-cancelado); }
.badge--gold { background: var(--gold-400); color: var(--ink-900); }
.badge--pendiente::before { animation: pulso 1.6s ease-in-out infinite; }

/* ---------- Selector de cantidad ---------- */
.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.stepper__btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: #fff; color: var(--teal-700); font-size: 1.3rem; font-weight: 700; line-height: 1;
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease-spring), background .2s;
}
.stepper__btn:hover { background: var(--teal-50); }
.stepper__btn:active { transform: scale(.88); }
.stepper__btn[disabled] { opacity: .4; cursor: not-allowed; }
.stepper__value { min-width: 34px; text-align: center; font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; }

/* ---------- Avisos ---------- */
.alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid; font-size: .95rem; }
.alert--info { background: var(--teal-50); border-color: var(--teal-100); color: var(--teal-800); }
.alert--warning { background: var(--gold-50); border-color: var(--gold-200); color: var(--gold-700); }
.alert--danger { background: var(--danger-bg); border-color: #f5c2bd; color: var(--danger); }
.alert--success { background: var(--success-bg); border-color: var(--teal-200); color: var(--teal-800); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(16px + var(--safe-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); width: min(92vw, 420px); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--s-3);
  padding: 14px 18px; border-radius: var(--r-md);
  background: var(--ink-900); color: #fff; box-shadow: var(--shadow-lg);
  font-weight: 600; animation: toast-in .35s var(--ease-spring);
}
.toast--success { background: var(--teal-700); }
.toast--error { background: var(--danger); }
.toast--gold { background: var(--gold-400); color: var(--ink-900); }
.toast.is-leaving { animation: toast-out .25s ease-in forwards; }

/* ---------- Modal / hoja inferior ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 40, 38, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .2s ease-out;
}
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow: auto;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-6) var(--s-5) calc(var(--s-6) + var(--safe-bottom));
  box-shadow: var(--shadow-lg); animation: sheet-up .35s var(--ease-out);
}
.modal__title { margin-bottom: var(--s-2); }
.modal__actions { display: flex; gap: var(--s-3); justify-content: flex-end; margin-top: var(--s-5); flex-wrap: wrap; }
.modal__actions .btn { flex: 1 1 140px; }
.modal-backdrop.is-leaving { animation: fade-out .2s ease-in forwards; }
.modal-backdrop.is-leaving .modal { animation: sheet-down .2s ease-in forwards; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: var(--s-4); }
  .modal { border-radius: var(--r-xl); animation: pop-in .3s var(--ease-spring); }
  .modal-backdrop.is-leaving .modal { animation: pop-out .18s ease-in forwards; }
}

/* ---------- Carga ---------- */
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--teal-100); border-top-color: var(--teal-600); animation: girar .8s linear infinite; }
.spinner--light { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.loading-block { display: grid; place-items: center; gap: var(--s-3); padding: var(--s-10) var(--s-4); color: var(--text-muted); }
.skeleton { position: relative; overflow: hidden; background: var(--cream-100); border-radius: var(--r-md); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: brillo 1.3s infinite; }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: var(--s-10) var(--s-4); color: var(--text-muted); }
.empty__icon { font-size: 3rem; margin-bottom: var(--s-3); animation: flotar 3s ease-in-out infinite; }
.empty h3 { color: var(--ink-700); }

/* ---------- Tablas (admin) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-family: var(--font-head); font-weight: 600; color: var(--ink-700); background: var(--surface-2); padding: 10px 14px; white-space: nowrap; }
.table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--cream-50); }

/* ---------- Animaciones ---------- */
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes brillo { to { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.95); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes pulso { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes flotar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes rebote { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes entrar-arriba { from { opacity: 0; transform: translateY(14px); } }
@keyframes sacudir { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
.anim-entrar { animation: entrar-arriba .45s var(--ease-out) both; }
.anim-rebote { animation: rebote .4s var(--ease-spring); }
.anim-sacudir { animation: sacudir .45s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
