/* ============ ULTRACALL OS — DESIGN SYSTEM ============ */
:root {
  --bg: #0a0e14;
  --bg-2: #0e131c;
  --surface: #131a26;
  --surface-2: #1a2332;
  --surface-3: #222d40;
  --border: #243047;
  --border-soft: #1c2638;
  --text: #e8edf5;
  --text-2: #9aa8be;
  --text-3: #5f6d85;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --green-bg: rgba(52, 211, 153, 0.12);
  --amber-bg: rgba(251, 191, 36, 0.12);
  --red-bg: rgba(248, 113, 113, 0.12);
  --accent-bg: rgba(34, 211, 238, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; font-size: 14px; }
.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

/* ============ SHELL ============ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 248px; min-width: 248px; background: var(--bg-2); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid var(--border-soft); }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: flex; align-items: center; justify-content: center; font-size: 17px; color: #0a0e14; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.3px; }
.brand-name span { color: var(--accent); }
.brand-sub { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1.2px; margin-top: 1px; }
.nav-section { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; font-size: 13.5px; transition: all 0.15s; }
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 10px; }
.tenant-pill { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; }
.tenant-pill i { color: var(--accent-2); }
.tenant-name { font-size: 12.5px; font-weight: 600; }
.tenant-plan { font-size: 11px; color: var(--text-3); }
.demo-badge { font-size: 10.5px; color: var(--text-3); text-align: center; padding: 6px; background: var(--surface); border-radius: 8px; }
.demo-badge i { color: var(--amber); margin-right: 4px; }

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 58px; min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--bg-2); border-bottom: 1px solid var(--border-soft); }
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.live-dot { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--green); font-weight: 600; }
.pulse { width: 8px; height: 8px; background: var(--green); border-radius: 50%; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); } 50% { box-shadow: 0 0 0 6px rgba(52,211,153,0); } }
.clock { font-size: 13px; color: var(--text-2); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--accent-2), #a855f7); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--text-3); }
.page-content { flex: 1; overflow-y: auto; padding: 22px 24px; }

/* ============ COMPONENTES ============ */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-6 { grid-template-columns: repeat(6, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 18px; }
.card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title i { margin-right: 7px; color: var(--accent); }

.kpi { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 16px 18px; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-3); }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin: 6px 0 4px; font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 11.5px; font-weight: 600; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-violet { background: rgba(139, 92, 246, 0.14); color: #a78bfa; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 8px 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-3); border-bottom: 1px solid var(--border-soft); font-weight: 600; }
table.data td { padding: 10px; border-bottom: 1px solid var(--border-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255,255,255,0.015); }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); transition: all 0.15s; font-family: inherit; }
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent); color: #0a0e14; border-color: var(--accent); }
.btn-primary:hover { background: #3de0fa; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.22); }
.btn-green { background: var(--green-bg); color: var(--green); border-color: rgba(52,211,153,0.3); }
.btn-green:hover { background: rgba(52,211,153,0.22); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

.progress-track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

/* ============ WALLBOARD ============ */
.queue-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 16px; position: relative; overflow: hidden; }
.queue-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--green); }
.queue-card.warn::before { background: var(--amber); }
.queue-card.crit::before { background: var(--red); }
.queue-name { font-weight: 700; font-size: 14px; }
.queue-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.qm { background: var(--bg-2); border-radius: 8px; padding: 8px 10px; }
.qm-label { font-size: 10px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.6px; }
.qm-value { font-size: 18px; font-weight: 800; font-family: 'JetBrains Mono', monospace; margin-top: 2px; }

.agent-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border-soft); }
.agent-row.warn { border-color: rgba(251,191,36,0.35); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.st-en_llamada { background: var(--accent); box-shadow: 0 0 8px rgba(34,211,238,0.6); }
.st-disponible { background: var(--green); }
.st-wrap_up { background: var(--amber); }
.st-pausa { background: var(--text-3); }

.alert-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border-soft); background: var(--bg-2); }
.alert-row.critico { border-left: 3px solid var(--red); }
.alert-row.warning { border-left: 3px solid var(--amber); }
.alert-row.info { border-left: 3px solid var(--accent); }

/* ============ CONSOLA AGENTE ============ */
.agent-console { display: grid; grid-template-columns: 280px 1fr 320px; gap: 16px; height: 100%; }
.call-bar { display: flex; align-items: center; justify-content: space-between; background: linear-gradient(90deg, var(--surface-2), var(--surface)); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; margin-bottom: 16px; }
.call-timer { font-size: 26px; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.call-controls { display: flex; gap: 8px; }
.ctl-btn { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 15px; transition: all 0.15s; }
.ctl-btn:hover { background: var(--surface-3); color: var(--text); }
.ctl-btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.ctl-btn.active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

.transcript-area { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; padding-right: 6px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; position: relative; animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bubble.cliente { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.agente { background: rgba(99, 102, 241, 0.16); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble-meta { font-size: 10px; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.sent-tag { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; }
.sent-pos { background: var(--green); } .sent-neu { background: var(--text-3); } .sent-neg { background: var(--red); }

.copilot-card { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 11px 13px; animation: fadeUp 0.35s ease; }
.copilot-card.objecion { border-left: 3px solid var(--amber); }
.copilot-card.dato { border-left: 3px solid var(--accent); }
.copilot-card.cierre { border-left: 3px solid var(--green); }
.copilot-card.compliance { border-left: 3px solid var(--red); }
.copilot-title { font-size: 11.5px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.copilot-body { font-size: 12px; color: var(--text-2); line-height: 1.5; }

.queue-item { padding: 11px 13px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border-soft); cursor: pointer; transition: all 0.15s; }
.queue-item:hover { border-color: var(--border); }
.queue-item.alta { border-left: 3px solid var(--red); }
.queue-item.media { border-left: 3px solid var(--amber); }

/* wrap-up modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(5,8,12,0.75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; animation: fadeUp 0.2s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 560px; max-width: 92vw; max-height: 86vh; overflow-y: auto; }

/* ============ CRM ============ */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; min-height: 60vh; }
.kanban-col { min-width: 250px; width: 250px; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px; flex-shrink: 0; }
.kanban-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-2); }
.deal-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px; margin-bottom: 10px; cursor: pointer; transition: all 0.15s; }
.deal-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.deal-card.live { border-color: var(--accent); box-shadow: 0 0 14px rgba(34,211,238,0.15); }
.deal-name { font-weight: 600; font-size: 13px; }
.deal-value { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--accent); font-size: 14px; margin-top: 4px; }

.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-dot { position: absolute; left: -28px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 8px; color: var(--accent); }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-detail { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.5; }
.tl-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ============ CENTRO IA ============ */
.ia-agent-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 18px; }
.ia-agent-card.restringido { border-color: rgba(251,191,36,0.4); }
.rule-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 5px; }
.rule-list li { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.rule-list li i { margin-top: 2px; font-size: 10px; }
.kill-switch { display: flex; align-items: center; gap: 8px; }

.log-row { display: flex; gap: 12px; padding: 9px 12px; border-radius: 8px; background: var(--bg-2); font-size: 12px; align-items: flex-start; }
.log-ts { font-family: 'JetBrains Mono', monospace; color: var(--text-3); flex-shrink: 0; font-size: 11px; padding-top: 1px; }
.log-tag { flex-shrink: 0; }

.approval-card { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px; }

@media (max-width: 1100px) {
  .cols-6 { grid-template-columns: repeat(3, 1fr); }
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .agent-console { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
