/* Medesthetique — base compartida: tokens de marca, tipografía, botones, formularios, cajón, modal y avisos. */

:root {
  /* Marca: gris del logotipo, azul polvo del subtítulo y azul marino de su web */
  --navy: #27477d;
  --navy-deep: #182f57;
  --navy-ink: #14233f;
  --powder: #9bc9d8;
  --powder-100: #e6f2f6;
  --powder-200: #cfe5ed;
  --sea: #4f97b3;
  --graphite: #6f6f73;
  --porcelain: #f7f2ee;
  --pearl: #fcfaf8;
  --blush: #efe1da;
  --nude: #d8b8a9;
  --rose: #c58f7c;
  --ink: #1b2740;
  --muted: #5d6679;
  --line: rgba(39, 71, 125, 0.12);
  --line-strong: rgba(39, 71, 125, 0.22);
  --ok: #2f7d5b;
  --warn: #a8661b;
  --danger: #b13a32;
  --white: #fff;

  /* Superficies y estados: el tema oscuro los redefine abajo */
  --brand-navy: #27477d;
  --on-accent: #fff;
  --surface: #fff;
  --surface-a: rgba(255, 255, 255, 0.65);
  --glass: rgba(252, 250, 248, 0.86);
  --glass-border: #fff;
  --header-glass: rgba(247, 242, 238, 0.82);
  --glow-a: rgba(207, 229, 237, 0.9);
  --glow-b: rgba(239, 225, 218, 0.9);
  --tint: #eef4f6;
  --wordmark: var(--graphite);
  --ok-bg: #e3f1ea;
  --warn-bg: #f8ecdc;
  --danger-bg: #f7e3e1;
  --muted-bg: #eeeff2;
  --wa-bg: #e9f5ee;
  --wa-ink: #29453a;
  --chart-1: #27477d;
  --chart-2: #9bc9d8;
  --chart-3: #c58f7c;
  --admin-bg: #f3efeb;
  --admin-top: rgba(243, 239, 235, 0.9);

  --font-display: 'Instrument Serif', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-brand: 'Quicksand', 'Manrope', sans-serif;

  --radius: 28px;
  --radius-md: 20px;
  --radius-sm: 12px;
  --shadow: 0 30px 60px -30px rgba(24, 47, 87, 0.35);
  --shadow-sm: 0 10px 24px -14px rgba(24, 47, 87, 0.35);
  --header-h: 76px;
  --gutter: clamp(16px, 4vw, 56px);
  --max: 1240px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Tema oscuro: noche en la clínica, mármol bajo luz fría. Se activa con data-theme-resolved="dark" en <html>. */
:root[data-theme-resolved='dark'] {
  color-scheme: dark;
  --navy: #a9d2e0;
  --navy-deep: #c8e4ee;
  --on-accent: #0d1422;
  --sea: #7fbcd3;
  --powder-100: rgba(155, 201, 216, 0.13);
  --powder-200: rgba(155, 201, 216, 0.24);
  --porcelain: #0d1422;
  --pearl: #141d2e;
  --blush: #1a2131;
  --ink: #e7ecf4;
  --muted: #a3adc0;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --ok: #7fd1a9;
  --warn: #e7ae62;
  --danger: #f0928a;
  --surface: #1a2438;
  --surface-a: rgba(255, 255, 255, 0.05);
  --glass: rgba(20, 29, 46, 0.84);
  --glass-border: rgba(255, 255, 255, 0.08);
  --header-glass: rgba(13, 20, 34, 0.8);
  --glow-a: rgba(79, 151, 179, 0.3);
  --glow-b: rgba(197, 143, 124, 0.12);
  --tint: #0f1a2b;
  --wordmark: #cfd4de;
  --ok-bg: rgba(47, 125, 91, 0.24);
  --warn-bg: rgba(168, 102, 27, 0.26);
  --danger-bg: rgba(177, 58, 50, 0.28);
  --muted-bg: rgba(255, 255, 255, 0.08);
  --wa-bg: rgba(31, 143, 85, 0.16);
  --wa-ink: #bfe8cf;
  --chart-1: #a9d2e0;
  --chart-2: #4d73b0;
  --chart-3: #c58f7c;
  --admin-bg: #0b111c;
  --admin-top: rgba(11, 17, 28, 0.88);
  --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.75);
  --shadow-sm: 0 10px 24px -14px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--porcelain);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 3px; border-radius: 8px; }
::selection { background: var(--powder-200); color: var(--navy-ink); }

.wrap { width: min(100% - var(--gutter) * 2, var(--max)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Tipografía */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; line-height: 0.98; }
.display em { font-style: italic; color: var(--navy); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--sea);
}
.eyebrow::before { content: ''; width: 26px; height: 1px; background: currentColor; }
.lead { font-size: clamp(1.02rem, 1.2vw, 1.14rem); color: var(--muted); max-width: 56ch; }
.note { font-size: 0.86rem; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Logotipo en texto (sustituir por el archivo oficial) */
.wordmark { display: inline-flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--wordmark); line-height: 1; }
.wordmark b { font-family: var(--font-brand); font-weight: 400; font-size: 1.42rem; letter-spacing: 0.02em; }
.wordmark b i { font-style: normal; color: var(--powder); margin: 0 0.04em; }
.wordmark small { font-family: var(--font-brand); font-weight: 600; font-size: 0.5rem; letter-spacing: 0.32em; color: var(--powder); margin-top: 5px; }
.wordmark.is-light { color: #fff; }

/* Botón de tema: luna en claro, sol en oscuro */
.theme-btn .i-sun { display: none; }
:root[data-theme-resolved='dark'] .theme-btn .i-sun { display: block; }
:root[data-theme-resolved='dark'] .theme-btn .i-moon { display: none; }
html { transition: background-color 0.4s; }

/* Botones */
.btn {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 26px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 600; font-size: 0.94rem; letter-spacing: 0.01em; text-decoration: none; white-space: nowrap;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), background 0.25s, color 0.25s, border-color 0.25s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--navy); color: var(--on-accent); box-shadow: 0 14px 30px -14px rgba(39, 71, 125, 0.7); }
:root[data-theme-resolved='dark'] .btn-primary { box-shadow: 0 14px 30px -16px rgba(155, 201, 216, 0.45); }
.btn-primary::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.9s var(--ease);
}
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary:hover { background: var(--navy-deep); }
.btn-ghost { background: var(--surface-a); border-color: var(--line-strong); color: var(--navy); backdrop-filter: blur(8px); }
.btn-ghost:hover { background: var(--surface); border-color: var(--navy); }
.btn-soft { background: var(--powder-100); color: var(--navy); }
.btn-soft:hover { background: var(--powder-200); }
.btn-light { background: #fff; color: var(--brand-navy); }
.btn-wa { background: #1f8f55; color: #fff; }
.btn-wa:hover { background: #18774a; }
.btn-sm { min-height: 40px; padding: 0 18px; font-size: 0.86rem; }
.btn-xs { min-height: 32px; padding: 0 13px; font-size: 0.78rem; gap: 6px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface-a); color: var(--navy);
  transition: background 0.2s, border-color 0.2s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line-strong); }
.icon-btn svg { width: 20px; height: 20px; }

.link { color: var(--navy); font-weight: 600; text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.35s var(--ease); }
.link:hover { background-size: 100% 1px; }

/* Chips y etiquetas */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-a);
  font-size: 0.8rem; font-weight: 500; color: var(--ink);
}
.chip-powder { background: var(--powder-100); border-color: transparent; color: var(--navy); }
.chip-navy { background: var(--navy); border-color: transparent; color: var(--on-accent); }
.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; background: var(--powder-100); color: var(--navy); }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-muted { background: var(--muted-bg); color: var(--muted); }
.demo-badge { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; background: var(--blush); color: var(--rose); }

/* Formularios */
.field { display: grid; gap: 6px; }
.field > span { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 15px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.textarea { min-height: 92px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 4px rgba(79, 151, 179, 0.15); }
.input-sm { min-height: 38px; padding: 7px 12px; font-size: 0.9rem; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.92rem; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--navy); flex: none; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-a); border: 1px solid var(--line); }
.seg button { border: 0; background: none; border-radius: 999px; min-height: 38px; padding: 0 16px; font-weight: 600; font-size: 0.86rem; color: var(--muted); transition: background 0.25s, color 0.25s; }
.seg button[aria-pressed='true'], .seg button[aria-selected='true'] { background: var(--navy); color: var(--on-accent); }

/* Cajón lateral y modal */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(20, 35, 63, 0.38); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.35s var(--ease); }
.scrim.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90; width: min(100%, 520px);
  display: flex; flex-direction: column; background: var(--pearl); box-shadow: -30px 0 60px -30px rgba(20, 35, 63, 0.45);
  transform: translateX(104%); transition: transform 0.5s var(--ease); visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.7rem; line-height: 1.1; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px 28px; overscroll-behavior: contain; }
.drawer-foot { padding: 16px 24px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; align-items: center; }

.modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px; background: rgba(20, 35, 63, 0.4); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal-card { width: min(100%, 560px); max-height: calc(100dvh - 32px); overflow: auto; background: var(--pearl); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); transform: translateY(14px) scale(0.98); transition: transform 0.4s var(--ease); }
.modal.is-open .modal-card { transform: none; }

/* Avisos */
.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 120; display: grid; gap: 8px; transform: translateX(-50%); width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 13px 18px; border-radius: 16px; background: var(--navy-ink); color: #fff; font-size: 0.9rem; box-shadow: var(--shadow); animation: toast-in 0.45s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* Revelado al hacer scroll */
[data-reveal] { opacity: 0; transform: translateY(26px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: calc(var(--i, 0) * 80ms); }
[data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
