/* Copyright (C) 2026 S&M Digital Solutions. Todos los derechos reservados. */
/* Panel de administración — estilo SaaS B2B sobrio y minimalista. */

:root {
  --bg: #F7F7F8;
  --surface: #FFFFFF;
  --fg: #0F172A;
  --muted: #64748B;
  --line: #E5E7EB;
  --soft: #F1F5F9;
  --accent: #111827;
  --accent-fg: #FFFFFF;
  --brand: #2563EB;
  --ok: #047857;
  --ok-bg: #ECFDF5;
  --warn: #B45309;
  --warn-bg: #FFFBEB;
  --err: #B91C1C;
  --err-bg: #FEF2F2;
  --r: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .03);
  --s1: #2563EB;
  --s2: #94A3B8;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 10.5px; letter-spacing: -.02em; flex: none; }
.logo small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--fg); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--soft); }
.nav a.active { background: var(--accent); color: var(--accent-fg); }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top .grow { flex: 1; }
.content { padding: 28px; max-width: 1180px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); filter: none; }
.btn.danger { background: var(--surface); color: var(--err); border-color: #FECACA; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: #334155; display: flex; align-items: center; gap: 6px; }
.field .help { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid #D1D5DB; border-radius: 8px; background: #fff;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: var(--soft); color: var(--muted); cursor: not-allowed; }
input[type=color] { width: 44px; height: 38px; padding: 3px; border: 1px solid #D1D5DB; border-radius: 8px; background: #fff; }
input[type=range] { width: 100%; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { width: 36px; height: 20px; appearance: none; background: #CBD5E1; border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:disabled { opacity: .5; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: #334155; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.dark { background: var(--accent); color: #fff; }
.lock { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--warn); background: var(--warn-bg); padding: 1px 7px; border-radius: 999px; cursor: pointer; border: 0; }

.kpi { padding: 16px 18px; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.kpi .l { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .d { font-size: 12px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #FAFAFA; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FAFAFA; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }

.bar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--s1); border-radius: 999px; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 12px; align-items: center; font-size: 13px; }

.code { position: relative; background: #0F172A; color: #E2E8F0; border-radius: 8px; padding: 14px 16px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.code .copy { position: absolute; top: 8px; right: 8px; }

.list-item { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #FCFCFD; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plan { border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan ul { margin: 0; padding-left: 18px; color: #334155; font-size: 13px; display: grid; gap: 4px; }

.preview-frame { position: sticky; top: 84px; height: 640px; border-radius: 14px; border: 1px dashed #CBD5E1; background: repeating-linear-gradient(45deg, #F8FAFC, #F8FAFC 10px, #F1F5F9 10px, #F1F5F9 20px); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
#preview-mount { flex: 1; min-height: 0; display: flex; }
#preview-mount > div { flex: 1; }

.transcript { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow: auto; padding-right: 4px; }
.msg { max-width: 80%; padding: 9px 12px; border-radius: 10px; background: var(--soft); white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg .meta { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }

.drawer-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { width: min(640px, 100%); height: 100%; background: var(--surface); padding: 24px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--surface); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 9px; }
.tabs button { flex: 1; height: 32px; border: 0; border-radius: 7px; background: transparent; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; }
#toast .t { background: #0F172A; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-weight: 500; }
#toast .t.err { background: var(--err); }

.empty { text-align: center; padding: 32px; color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .preview-frame { position: static; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; }
  .side .logo, .side .foot { display: none; }
  .nav { display: flex; gap: 4px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2, .plans { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .top { padding: 12px 16px; }
  .funnel-row { grid-template-columns: 110px 1fr 56px; }
}
