/* ════════════════════════════════════════════════════════════
   TurnosWeb.online — Sistema de diseño (light + dark)
   Tokens vía CSS variables. El tema se controla con [data-theme]
   en <html>. Claro por defecto.
   ════════════════════════════════════════════════════════════ */

:root {
  --brand: #6d5efc;
  --brand-600: #5a48f0;
  --brand-700: #4a39d6;
  --brand-soft: #efedff;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --border: #e6e8f0;
  --text: #1a1d29;
  --text-soft: #5b6072;
  --text-muted: #9aa0b4;

  --success: #18a957;
  --success-soft: #e4f7ec;
  --warning: #e0a200;
  --warning-soft: #fbf3da;
  --danger: #e5484d;
  --danger-soft: #fde9ea;
  --info: #2f7ed8;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06), 0 1px 3px rgba(20, 24, 40, .05);
  --shadow: 0 6px 24px rgba(28, 32, 56, .08);
  --shadow-lg: 0 18px 48px rgba(28, 32, 56, .16);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme='dark'] {
  --brand: #8b7dff;
  --brand-600: #7c6cff;
  --brand-700: #6857ff;
  --brand-soft: #232246;

  --bg: #0e1016;
  --surface: #171a23;
  --surface-2: #1f2330;
  --border: #2a2f3d;
  --text: #f6f8fd;
  --text-soft: #cdd2e2;
  --text-muted: #969cb1;

  --success-soft: #11321f;
  --warning-soft: #322a12;
  --danger-soft: #3a1d20;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, video, canvas { max-width: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; color: var(--text-soft); }

.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hide { display: none !important; }

/* ─────────── Botones ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: .95rem; font-weight: 600;
  padding: .65rem 1.15rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; transition: all .15s ease;
  text-decoration: none; white-space: nowrap; line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand-700); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-success { background: var(--success); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1.05rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ─────────── Cards ─────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.5rem;
}
.card-pad-lg { padding: 2rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.card-head h3 { margin: 0; }

/* ─────────── Formularios ─────────── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.field .hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .65rem .8rem; transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { min-height: 90px; resize: vertical; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon {
  display: flex; align-items: center; padding: 0 .8rem; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-muted); font-size: .9rem;
}
.input-group .addon.left { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon.right { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .input.has-left { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .input.has-right { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
/* label.switch + margin:0 ganan especificidad/orden a la regla genérica .field label */
.switch, label.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; margin-bottom: 0; font-weight: 500; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ─────────── Badges ─────────── */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; padding: .25rem .6rem; border-radius: 99px; }
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-confirmed { background: var(--success-soft); color: var(--success); }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-completed { background: var(--brand-soft); color: var(--brand-700); }
.badge-no_show { background: var(--surface-2); color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ─────────── Alertas ─────────── */
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-info { background: var(--brand-soft); color: var(--brand-700); }

/* ─────────── Tablas ─────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
.table td { padding: .85rem .8rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* ─────────── Theme toggle ─────────── */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; color: var(--text); transition: all .15s;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle .icon-moon { display: none; }
html[data-theme='dark'] .theme-toggle .icon-sun { display: none; }
html[data-theme='dark'] .theme-toggle .icon-moon { display: block; }

/* ─────────── Avatar ─────────── */
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-700); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ════════════ Topbar pública / app ════════════ */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -.02em; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #b39dff); display: grid; place-items: center; color: #fff; }
.nav-links { display: flex; align-items: center; gap: 1.4rem; }
.nav-links a:not(.btn) { color: var(--text-soft); font-weight: 500; font-size: .95rem; }
.nav-links a:not(.btn):hover { color: var(--text); text-decoration: none; }
.nav-links a.btn-primary { color: #fff; }
/* En desktop no afecta el layout flex; en mobile se oculta como bloque. */
.nav-sections { display: contents; }

/* ════════════ Landing ════════════ */
.hero { padding: 5rem 0 3rem; text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin-bottom: 1rem; }
.hero h1 .grad { background: linear-gradient(120deg, var(--brand), #c08bff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p.lead { font-size: 1.2rem; max-width: 640px; margin: 0 auto 2rem; }
.pill { display: inline-flex; align-items: center; gap: .5rem; background: var(--brand-soft); color: var(--brand-700); padding: .4rem .9rem; border-radius: 99px; font-size: .85rem; font-weight: 600; margin-bottom: 1.5rem; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; margin: 3rem 0; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; }
.feature .ic { width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 1rem; }
.feature h3 { margin-bottom: .4rem; }
.feature p { margin: 0; font-size: .92rem; }
.segments { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.segment { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; text-align: center; }
.segment .emoji { font-size: 1.6rem; }
.segment h4 { margin: .5rem 0 .3rem; font-size: 1rem; }
.segment ul { list-style: none; margin: .5rem 0 0; padding: 0; color: var(--text-muted); font-size: .85rem; }
.segment ul li { margin-bottom: .2rem; }
.cta-band { background: linear-gradient(120deg, var(--brand), var(--brand-700)); border-radius: var(--radius-lg); padding: 3rem 2rem; text-align: center; color: #fff; margin: 3rem 0; }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.85); }
.footer { border-top: 1px solid var(--border); padding: 2.5rem 0; color: var(--text-muted); font-size: .9rem; margin-top: 2rem; }

/* ════════════ Auth ════════════ */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: linear-gradient(150deg, var(--brand-700), var(--brand) 60%, #b39dff); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside h2 { color: #fff; font-size: 2rem; }
.auth-aside ul { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-aside li { display: flex; gap: .7rem; align-items: flex-start; margin-bottom: 1rem; color: rgba(255,255,255,.92); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.7rem; }
.divider { display: flex; align-items: center; gap: 1rem; color: var(--text-muted); font-size: .8rem; margin: 1.3rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-google { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-google:hover { background: var(--surface-2); }

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .features, .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ════════════ Dashboard ════════════ */
.app-shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.2rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { margin-bottom: 1.5rem; padding: 0 .4rem; }
.side-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .65rem .75rem; border-radius: var(--radius-sm); color: var(--text-soft); font-weight: 500; font-size: .93rem; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--brand-soft); color: var(--brand-700); font-weight: 600; }
.side-nav a svg { flex: none; }
.side-foot { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.main { display: flex; flex-direction: column; min-width: 0; }
.main-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 2rem; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; gap: 1rem; }
.main-header h1 { font-size: 1.35rem; margin: 0; }
.main-body { padding: 2rem; flex: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; }
.stat .label { font-size: .82rem; color: var(--text-muted); font-weight: 600; }
.stat .value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; margin-top: .3rem; }
.stat .ic { float: right; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }

.mobile-only { display: none; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .25s; width: 256px; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .main-body { padding: 1.2rem; }
  .main-header { padding: 1rem 1.2rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty .ic { width: 64px; height: 64px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 1rem; }

.list-row { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .7rem; background: var(--surface); }
.list-row .when { text-align: center; min-width: 64px; }
.list-row .when .d { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.list-row .when .m { font-size: .72rem; text-transform: uppercase; color: var(--text-muted); }

.color-swatch { width: 22px; height: 22px; border-radius: 6px; display: inline-block; border: 1px solid var(--border); vertical-align: middle; }

/* Filas de horario semanal (vista Horarios) */
.day-row { display: grid; grid-template-columns: 140px 1fr 1fr; gap: .6rem 1.2rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.day-row:last-of-type { border-bottom: 0; }
.day-row .range { display: flex; align-items: center; gap: .5rem; }
.day-row .range .sep { color: var(--text-muted); font-size: .85rem; flex: none; }
.day-row .range input[type='time'] { flex: 1; min-width: 0; }
.day-row.closed .range { opacity: .45; }
.day-cols { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 1.2rem; padding: 0 0 .5rem; }
.day-cols span { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; }
@media (max-width: 640px) {
  .day-cols { display: none; }
  .day-row { grid-template-columns: 1fr; gap: .5rem; }
}

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tabs a { padding: .6rem 1rem; color: var(--text-soft); font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,12,20,.5); z-index: 80; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-head { padding: 1.3rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; }
.modal-foot { padding: 1.1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .7rem; }

/* FAQ (landing) */
.faq { max-width: 760px; margin-inline: auto; }
.faq-list { margin-top: 1.5rem; display: flex; flex-direction: column; gap: .7rem; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .2rem .4rem; }
.faq-item summary { cursor: pointer; font-weight: 700; padding: .9rem 1rem; list-style: none; position: relative; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; position: absolute; right: 1rem; color: var(--brand); font-size: 1.3rem; line-height: 1; }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { padding: 0 1rem 1rem; margin: 0; color: var(--text-soft); }

/* ════════════════════════════════════════════════════════════
   Responsive / refinamientos mobile (no afectan desktop)
   ════════════════════════════════════════════════════════════ */

/* Tablas: scroll horizontal dentro de un contenedor en vez de desbordar */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Overlay del menú lateral en mobile (cierra al tocar fuera) */
.sidebar-overlay { display: none; }

/* Tablets y abajo: nav de la landing compacto */
@media (max-width: 820px) {
  .nav-sections { display: none; }
  .nav-links { gap: .7rem; }
}

@media (max-width: 900px) {
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar.open ~ .sidebar-overlay { opacity: 1; pointer-events: auto; }
}

@media (max-width: 768px) {
  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.3rem; }

  /* iOS no hace zoom al enfocar inputs si la fuente es ≥16px */
  .input, .select, .textarea { font-size: 16px; }

  /* Tablas con ancho mínimo: las columnas no se aplastan, el contenedor desliza */
  .table-wrap .table { min-width: 460px; }

  /* Tabs/filtros deslizables en lugar de amontonarse en varias líneas */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-width: 0; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; }

  .card { padding: 1.15rem; }
  .card-pad-lg { padding: 1.3rem; }

  /* Landing más compacta */
  .topbar .inner { height: 58px; }
  .hero { padding: 3rem 0 2rem; }
  .hero p.lead { font-size: 1.05rem; }
  .features { margin: 2rem 0; }
  .cta-band { padding: 2.2rem 1.3rem; margin: 2rem 0; }
  .auth-main { padding: 1.5rem; }

  /* Sitio de reservas: portada y logo más chicos */
  .booking-cover { height: 150px; }
  .booking-head { margin-top: -52px; }
  .biz-logo { width: 68px; height: 68px; font-size: 1.6rem; }
  .biz-meta h1 { font-size: 1.35rem; }
  .service-opt { padding: .9rem; gap: .7rem; }
}

/* Teléfonos chicos: botones de acción a ancho completo */
@media (max-width: 430px) {
  .hero .btn-lg { width: 100%; }
  .hero .flex { flex-direction: column; }
  .logo { font-size: 1.05rem; }
  .slots { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}
