/* Panel del cliente — identidad v1 (22-nov-2026).
 * Colores con los nombres de tokens.json del manual de identidad (tema claro: es una herramienta de trabajo).
 * Negro, blanco y grises zinc + un solo verde (#10B981) solo para lo transaccional, cifras de ventas y estados positivos. */
:root {
  --bg: #FFFFFF;
  --bg-alt: #FAFAFA;
  --surface: #FFFFFF;
  --surface-raised: #F4F4F5;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --ink: #09090B;
  --ink-muted: #52525B;
  --ink-subtle: #71717A;
  --action: #10B981;
  --action-hover: #059669;
  --on-action: #09090B;
  --action-text: #047857;
  --action-soft: #ECFDF5;
  --action-soft-border: #A7F3D0;
  --focus-ring: rgba(16, 185, 129, 0.45);
  --notify: #DC2626;
  --danger-soft: #FEF2F2;
  --danger-border: #FECACA;
  --chat-header: #18181B;
  --chat-bot-bubble: #F4F4F5;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card-light: 0 1px 2px rgba(9, 9, 11, 0.04), 0 4px 16px rgba(9, 9, 11, 0.04);
  --font-display: 'Plus Jakarta Sans', Inter, system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Fuentes alojadas en nuestro servidor (no Google Fonts: RGPD) */
@font-face { font-family: 'Inter'; src: url('fuentes/Inter-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fuentes/Inter-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fuentes/Inter-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url('fuentes/PlusJakartaSans-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg-alt); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.015em; }
a { color: var(--ink); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
::selection { background: #3F3F46; color: #FAFAFA; }

/* Login */
.login-wrap { max-width: 400px; margin: 100px auto; padding: 40px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.login-wrap h1 { margin-bottom: 24px; color: var(--ink); font-size: 24px; }
.login-wrap .logo-login { display: block; margin-bottom: 24px; }
.login-wrap input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-size: 14px; font-family: inherit; color: var(--ink); background: var(--surface); }
.login-wrap input:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--focus-ring); }
/* "Entrar" no es una compra: botón neutro */
.login-wrap button { width: 100%; padding: 12px; background: var(--ink); color: #fff; border: none; border-radius: var(--radius-md); font-weight: 600; cursor: pointer; font-family: inherit; }
.login-wrap button:hover { background: #27272A; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--bg); color: var(--ink); padding: 24px 0; flex-shrink: 0; border-right: 1px solid var(--border); }
.sidebar .logo { padding: 0 24px 24px; }
.sidebar .logo img { display: block; height: 30px; width: auto; }
.sidebar nav a { display: block; margin: 1px 12px; padding: 9px 12px; color: var(--ink-muted); text-decoration: none; font-size: 13px; font-weight: 500; border-radius: var(--radius-md); transition: background .15s, color .15s; }
.sidebar nav a:hover { background: var(--surface-raised); color: var(--ink); }
.sidebar nav a.active { background: var(--surface-raised); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
.main { flex: 1; padding: 28px; overflow-y: auto; max-height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar h1 { font-size: 22px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-label { font-size: 13px; color: var(--ink-muted); }
.topbar .logout { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); padding: 8px 14px; border-radius: var(--radius-md); cursor: pointer; font-size: 13px; font-family: inherit; }
.topbar .logout:hover { background: var(--surface-raised); }

/* Agent switcher */
.agent-switcher { position: relative; }
.agent-switcher-btn { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 8px; font-family: inherit; }
.agent-switcher-btn:hover { border-color: #A1A1AA; }
.agent-switcher-btn .chev { color: var(--ink-subtle); font-size: 10px; }
.agent-switcher-menu { position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card-light); min-width: 240px; z-index: 20; padding: 4px; display: none; }
.agent-switcher-menu.open { display: block; }
.agent-switcher-menu .item { padding: 10px 12px; cursor: pointer; border-radius: var(--radius-sm); font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.agent-switcher-menu .item:hover { background: var(--surface-raised); }
.agent-switcher-menu .item.active { background: var(--surface-raised); color: var(--ink); font-weight: 600; }
.agent-switcher-menu .item .domain { font-size: 11px; color: var(--ink-subtle); font-weight: 400; }
.agent-switcher-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.agent-switcher-menu .manage { padding: 10px 12px; font-size: 12px; color: var(--ink); cursor: pointer; border-radius: var(--radius-sm); font-weight: 600; }
.agent-switcher-menu .manage:hover { background: var(--surface-raised); }

/* Agentes view */
.agent-card { background: var(--surface); padding: 18px; border-radius: var(--radius-lg); border: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.agent-card.active { border: 2px solid var(--ink); }
.agent-card .meta { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.agent-card .actions { display: flex; gap: 8px; }

/* Hint banner (ej: "estás configurando X") */
.agent-hint { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 14px; }
.agent-hint a { color: var(--ink); font-weight: 600; margin-left: 6px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--surface); padding: 18px; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.card .label { font-size: 11px; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; margin-bottom: 4px; letter-spacing: .3px; }
.card .value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.card .value.highlight { color: var(--ink); }
/* Cifras de ventas en verde (texto, no fondo) */
.card .value.success { color: var(--action-text); }
.card .value.plan-badge { font-size: 18px; text-transform: capitalize; }

/* Tables */
.table { width: 100%; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg-alt); font-size: 11px; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; letter-spacing: .3px; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable:hover td { background: var(--bg-alt); cursor: pointer; }

/* Badges: verde solo para estados positivos; el resto neutro (rojo, los problemas) */
.badge { display: inline-block; padding: 3px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; border: 1px solid transparent; }
.badge.compro, .badge.activo, .badge.convertido { background: var(--action-soft); color: var(--action-text); }
.badge.lead, .badge.pausado, .badge.en_curso, .badge.cualificado { background: var(--surface-raised); color: var(--ink); border-color: var(--border); }
.badge.sin_datos, .badge.cancelado { background: var(--surface-raised); color: var(--ink-muted); border-color: var(--border); }

/* Buttons: .btn es neutro (negro); .btn-compra es el verde de lo transaccional (pagar, contratar, conectar) */
.btn { padding: 10px 16px; background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: var(--radius-md); cursor: pointer; font-weight: 600; font-size: 13px; font-family: inherit; transition: background .15s, border-color .15s; text-decoration: none; display: inline-block; }
.btn:hover { background: #27272A; border-color: #27272A; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-compra { background: var(--action); border-color: var(--action); color: var(--on-action); }
.btn-compra:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-raised); border-color: var(--border-strong); }
.btn-danger { background: var(--notify); border-color: var(--notify); color: #fff; }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }
.btn-text { background: none; border: none; color: var(--ink-muted); font-weight: 400; text-decoration: underline; padding: 6px 0; }
.btn-text:hover { color: var(--notify); background: none; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }

/* Panels */
.panel { background: var(--surface); padding: 20px; border-radius: var(--radius-lg); margin-bottom: 14px; border: 1px solid var(--border); }
.panel h2 { margin-bottom: 14px; font-size: 16px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-header h2 { margin-bottom: 0; }

/* Snippet */
.snippet-wrap { display: flex; align-items: center; gap: 10px; }
.snippet { flex: 1; background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius-md); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; overflow-x: auto; word-break: break-all; }

/* Messages (como en el chat de Valeria) */
.msg-list { display: flex; flex-direction: column; gap: 8px; max-height: 500px; overflow-y: auto; padding: 10px 0; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: var(--radius-lg); font-size: 14px; }
.msg.user { background: var(--chat-header); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--chat-bot-bubble); color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-role { font-size: 10px; font-weight: 600; text-transform: uppercase; margin-bottom: 4px; opacity: .7; }
.msg-text { white-space: pre-wrap; line-height: 1.5; }

/* Fields */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--ink); }
.field input, .field select, .field textarea { width: 100%; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-size: 14px; font-family: inherit; color: var(--ink); background: var(--surface); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--focus-ring); }
.field textarea { resize: vertical; }
.field input[type="checkbox"], .field input[type="radio"] { width: auto; margin-right: 6px; accent-color: var(--ink); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); }

/* List items (FAQs, objeciones) */
.list-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px; gap: 12px; }
.list-item-content { flex: 1; }
.list-q { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.list-a { font-size: 13px; color: var(--ink-muted); }

/* Plan cards */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.plan-card { background: var(--surface); padding: 24px; border-radius: var(--radius-lg); border: 1px solid var(--border); text-align: center; transition: border-color .2s, box-shadow .2s; }
.plan-card:hover { box-shadow: var(--shadow-card-light); }
.plan-card.current { border: 2px solid var(--ink); }
.plan-card.upgrade { border-color: var(--border-strong); }
.plan-card.popular { border: 2px solid var(--ink); position: relative; }
.plan-popular-badge { position: absolute; top: -10px; right: 16px; background: var(--ink); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 9999px; text-transform: uppercase; letter-spacing: .5px; }
.plan-card h3 { font-size: 18px; margin-bottom: 8px; }
.plan-price { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--ink); margin-bottom: 8px; letter-spacing: -0.02em; }
.plan-price span { font-family: var(--font-body); font-size: 14px; font-weight: 400; color: var(--ink-muted); letter-spacing: 0; }
.plan-desc { font-size: 13px; color: var(--ink-muted); margin-bottom: 16px; }
.plan-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(9, 9, 11, 0.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-content { background: var(--surface); padding: 28px; border-radius: var(--radius-lg); border: 1px solid var(--border); max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2); }
.modal-content h2 { margin-bottom: 16px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.empty-state p { font-size: 16px; color: var(--ink-muted); margin-bottom: 8px; }

/* Bar chart: conversaciones en negro, contactos en gris, ventas en verde */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; padding: 10px 0; height: 160px; overflow-x: auto; }
.bar-group { display: flex; flex-direction: column; align-items: center; min-width: 44px; }
.bars { display: flex; gap: 2px; align-items: flex-end; height: 130px; }
.bar { width: 10px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s; }
.bar-conv { background: var(--ink); }
.bar-lead { background: var(--ink-subtle); }
.bar-sale { background: var(--action); }
.bar-label { font-size: 10px; color: var(--ink-subtle); margin-top: 4px; text-transform: capitalize; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink-muted); margin-bottom: 8px; align-items: center; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; }

/* Config guided setup */
.config-banner { background: var(--chat-header); color: #FAFAFA; padding: 24px; border-radius: var(--radius-lg); margin-bottom: 20px; }
.config-banner h2 { font-size: 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.config-banner p { font-size: 13px; color: #A1A1AA; margin-top: 8px; line-height: 1.5; }
.config-progress { height: 8px; background: #3F3F46; border-radius: 4px; overflow: hidden; }
.config-progress-fill { height: 100%; background: #FAFAFA; border-radius: 4px; transition: width .5s ease; }
.config-progress-pct { font-size: 14px; font-weight: 700; margin-top: 8px; }
.config-section { background: var(--surface); border-radius: var(--radius-lg); margin-bottom: 10px; border: 1px solid var(--border); overflow: hidden; }
.section-header { display: flex; align-items: center; padding: 16px 20px; cursor: pointer; gap: 10px; user-select: none; transition: background .15s; }
.section-header:hover { background: var(--bg-alt); }
.section-header h3 { flex: 1; font-size: 15px; margin: 0; font-weight: 600; font-family: var(--font-body); letter-spacing: 0; }
.section-count { font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.section-arrow { font-size: 12px; color: var(--ink-subtle); transition: transform .2s; }
.config-section.open .section-arrow { transform: rotate(180deg); }
.section-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong); flex-shrink: 0; }
.section-dot.filled { background: var(--action); border-color: var(--action); }
.section-dot.partial { background: var(--ink-subtle); border-color: var(--ink-subtle); }
.section-body { display: none; padding: 0 20px 20px; }
.config-section.open .section-body { display: block; }
.section-intro { font-size: 13px; color: var(--ink-muted); margin-bottom: 16px; padding: 12px 14px; background: var(--bg-alt); border-radius: var(--radius-md); border: 1px solid var(--border); line-height: 1.5; }
.field-hint { font-size: 11px; color: var(--ink-subtle); margin-top: 2px; line-height: 1.4; }
.radio-row { display: flex; gap: 16px; padding: 8px 0; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.radio-row input[type="radio"] { width: auto; margin: 0; }

/* Globo del chat: 5 colores, vista previa y aviso de contraste */
.globo-config { display: grid; gap: 10px; margin-bottom: 10px; }
.globo-opciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.globo-opcion { display: flex !important; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; font-weight: 400 !important; font-size: 13px; margin: 0 !important; background: var(--surface); }
.globo-opcion:has(input:checked) { border: 2px solid var(--ink); padding: 9px 11px; }
.globo-opcion input[type="radio"] { width: auto; margin: 0; flex: none; }
.globo-opcion input[type="color"] { width: 28px !important; height: 28px; padding: 0 !important; border: 1px solid var(--border-strong) !important; border-radius: 50% !important; overflow: hidden; flex: none; cursor: pointer; background: none; }
.globo-muestra { width: 28px; height: 28px; border-radius: 50%; flex: none; border: 1px solid rgba(9, 9, 11, .12); }
.globo-vista { display: flex; align-items: center; gap: 12px; }
.globo-burbuja { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1.5px solid rgba(255, 255, 255, .22); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.globo-aviso { background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--notify); padding: 10px 12px; border-radius: var(--radius-md); font-size: 13px; }
.globo-check { display: flex !important; gap: 8px; align-items: center; font-weight: 400 !important; font-size: 13px; margin: 0 !important; cursor: pointer; }
.globo-check input { width: 16px !important; height: 16px; margin: 0 !important; }
#globoManual .btn { margin-bottom: 12px; }

/* Utils */
.loading { color: var(--ink-muted); font-style: italic; }
.muted { color: var(--ink-muted); font-size: 12px; }
.highlight { color: var(--ink); font-weight: 600; }
code { background: var(--surface-raised); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; font-size: 12px; color: var(--ink); }
strong { font-weight: 600; }
small { font-size: 11px; }

/* Toast notifications */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 20px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; color: #fff; animation: toastIn .3s ease; max-width: 400px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); pointer-events: auto; line-height: 1.4; white-space: pre-line; }
.toast.success { background: var(--action); color: var(--on-action); font-weight: 600; }
.toast.error { background: var(--notify); }
.toast.info { background: var(--chat-header); }
.toast.fadeOut { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.login-wrap button.btn-compra { background: var(--action); color: var(--on-action); }
.login-wrap button.btn-compra:hover { background: var(--action-hover); }
