/* ════════════════════════════════════════════════════════════
   DEMOS PREMIUM — AigenciaLab.cl Tech-Noir v3
   Shared premium stylesheet for all agent demos
   ════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;600&display=swap');

:root {
  --bg:        #080a12;
  --bg2:       #0d101e;
  --bg3:       #111525;
  --glass:     rgba(255,255,255,.03);
  --glass-b:   rgba(255,255,255,.06);
  --primary:   #00cfff;
  --primary-g: rgba(0,207,255,.12);
  --secondary: #7c3aed;
  --green:     #25d366;
  --green-g:   rgba(37,211,102,.1);
  --red:       #ef4444;
  --amber:     #f59e0b;
  --text:      #f1f5f9;
  --sub:       #64748b;
  --border:    rgba(255,255,255,.06);
  --border-b:  rgba(255,255,255,.1);
  --ff:        'Inter', sans-serif;
  --ffm:       'Geist Mono', monospace;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --radius:    12px;
  --radius-lg: 18px;
  --glow-p:    0 0 20px rgba(0,207,255,.25);
  --glow-g:    0 0 20px rgba(37,211,102,.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 52px;
  background: rgba(8,10,18,.97);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 50;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,207,255,.3), transparent);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--sub);
  font-size: .8rem;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all .2s;
  white-space: nowrap;
}
.back-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-g); }

.topbar-logo {
  font-size: .9rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
  margin-right: 4px;
}
.topbar-logo span { color: var(--primary); }

.topbar-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 4px 12px;
  border-radius: 50px;
  background: linear-gradient(135deg, rgba(37,211,102,.2), rgba(37,211,102,.1));
  border: 1px solid rgba(37,211,102,.3);
  color: var(--green);
}

.topbar-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-green 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--green);
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .6; transform: scale(.85); }
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(0,207,255,.04) 0%, transparent 100%);
}

.agent-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(0,207,255,.25);
}

.agent-name   { font-size: .92rem; font-weight: 700; color: var(--text); }
.agent-status {
  font-size: .72rem;
  color: var(--green);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.agent-status::before {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-green 2s infinite;
}

/* TABS */
.sidebar-tabs {
  display: flex;
  padding: 12px 16px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stab {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--sub);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--ff);
  font-size: .75rem;
  font-weight: 600;
  transition: all .2s;
}
.stab:hover  { border-color: var(--border-b); color: var(--text); background: var(--glass); }
.stab.active { background: var(--primary-g); border-color: rgba(0,207,255,.3); color: var(--primary); }

/* TAB PANELS */
.tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex-shrink: 0; }

.kpi-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  transition: all .2s;
}
.kpi-card:hover { border-color: var(--border-b); background: var(--glass-b); }
.kpi-card.highlight { background: var(--primary-g); border-color: rgba(0,207,255,.2); }
.kpi-card.green     { background: var(--green-g);   border-color: rgba(37,211,102,.2); }
.kpi-card.hl { background: var(--primary-g); border-color: rgba(0,207,255,.2); }

.kpi-val {
  font-family: var(--ff);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-card.green .kpi-val  { color: var(--green); }
.kpi-label { font-size: .7rem; color: var(--sub); font-weight: 500; }

/* Section label */
.section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sub);
  flex-shrink: 0;
}

/* Leads table */
.leads-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.leads-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.leads-table thead { background: var(--primary-g); }
.leads-table th { padding: 8px 10px; text-align: left; color: var(--sub); font-weight: 600; font-size: .72rem; text-transform: uppercase; }
.leads-table td { padding: 8px 10px; border-top: 1px solid var(--border); }
.leads-table tr:hover td { background: var(--glass); }

/* Badges */
.badge             { padding: 2px 8px; border-radius: 50px; font-size: .68rem; font-weight: 700; }
.badge-hot  { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.2); }
.badge-warm { background: rgba(245,158,11,.12); color: var(--amber); border: 1px solid rgba(245,158,11,.2); }
.badge-new  { background: var(--primary-g); color: var(--primary); border: 1px solid rgba(0,207,255,.2); }
.badge-conv { background: var(--green-g); color: var(--green); border: 1px solid rgba(37,211,102,.2); }

/* Activity log */
.activity-log {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.activity-log li {
  padding: 7px 10px;
  background: var(--glass);
  border-radius: 8px;
  color: var(--sub);
  font-size: .77rem;
  border-left: 2px solid var(--primary);
  line-height: 1.4;
  animation: fadeIn .3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Ticket list */
.ticket-list { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.ticket-item {
  padding: 10px 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  transition: all .2s;
  cursor: pointer;
}
.ticket-item:hover { border-color: var(--border-b); background: var(--glass-b); }
.ticket-item .ti-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ticket-num  { font-family: var(--ffm); font-size: .7rem; color: var(--primary); font-weight: 600; }
.ticket-pri  { font-size: .65rem; padding: 2px 7px; border-radius: 4px; font-weight: 700; }
.pri-critico { background: rgba(239,68,68,.15); color: var(--red); }
.pri-alto    { background: rgba(245,158,11,.15); color: var(--amber); }
.pri-medio   { background: rgba(0,207,255,.1);   color: var(--primary); }
.ticket-issue { color: var(--sub); font-size: .78rem; }

/* KB List */
.kb-list { list-style: none; display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.kb-list li {
  padding: 7px 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .78rem;
  color: var(--sub);
  cursor: pointer;
  transition: all .15s;
}
.kb-list li:hover { color: var(--primary); border-color: rgba(0,207,255,.2); background: var(--primary-g); }

/* Cyber notice */
.cyber-notice {
  margin: 16px;
  font-size: .7rem;
  color: var(--sub);
  padding: 10px 12px;
  background: rgba(0,207,255,.03);
  border: 1px solid rgba(0,207,255,.08);
  border-radius: var(--radius);
  line-height: 1.55;
  flex-shrink: 0;
}

/* Client DB */
.db-toolbar { display: flex; gap: 8px; flex-shrink: 0; }
.db-search {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--ff);
  font-size: .82rem;
  outline: none;
  transition: border-color .2s;
}
.db-search:focus { border-color: rgba(0,207,255,.4); }
.btn-export {
  background: var(--primary-g);
  border: 1px solid rgba(0,207,255,.2);
  color: var(--primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.btn-export:hover { background: rgba(0,207,255,.2); }

.client-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.client-card {
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.client-card:hover { border-color: rgba(0,207,255,.25); background: var(--primary-g); }
.cc-avatar { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; flex-shrink: 0; }
.cc-body   { flex: 1; min-width: 0; }
.cc-top    { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 2px; }
.cc-name   { font-weight: 700; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-status { padding: 2px 7px; border-radius: 50px; font-size: .65rem; font-weight: 700; border: 1px solid; flex-shrink: 0; }
.cc-company{ font-size: .75rem; color: var(--sub); margin-bottom: 4px; }
.cc-meta   { display: flex; flex-wrap: wrap; gap: 5px; font-size: .7rem; color: var(--sub); }
.empty-state { text-align: center; padding: 24px; color: var(--sub); font-size: .85rem; }

/* ── CHAT PANEL ──────────────────────────────────────────── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.chat-contact { display: flex; align-items: center; gap: 12px; }
.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.contact-name { font-weight: 700; font-size: .92rem; }
.contact-info { font-size: .72rem; color: var(--sub); margin-top: 1px; }

.header-info { display: flex; flex-direction: column; gap: 2px; }
.ticket-badge {
  font-family: var(--ffm);
  font-size: .78rem;
  color: var(--primary);
  font-weight: 600;
}
.header-sub { font-size: .72rem; color: var(--sub); }
.header-actions { display: flex; gap: 8px; }

/* CTA Buttons */
.btn-new-lead, .btn-new {
  background: linear-gradient(135deg, var(--primary), #0099cc);
  color: #000;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--ff);
  font-weight: 700;
  font-size: .8rem;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-new-lead:hover, .btn-new:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-p);
}

.btn-escalate {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  color: var(--red);
  padding: 8px 14px;
  border-radius: 8px;
  font-family: var(--ff);
  font-weight: 600;
  font-size: .78rem;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-escalate:hover { background: rgba(239,68,68,.2); }

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.system-msg {
  text-align: center;
  color: var(--sub);
  font-size: .83rem;
  padding: 20px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.6;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: msgIn .25s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg.user  { align-self: flex-end; align-items: flex-end; }
.msg.agent { align-self: flex-start; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.6;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--green), #059669);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.agent .msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.typing-bubble .msg-bubble {
  display: flex; gap: 5px; align-items: center; padding: 14px 18px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--sub);
  border-radius: 50%;
  animation: typing-anim 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing-anim { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }

.msg-meta { font-size: .7rem; color: var(--sub); margin-top: 4px; }

/* Chat input */
.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--ff);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.chat-input-row input:focus { border-color: rgba(0,207,255,.4); }
.chat-input-row input::placeholder { color: var(--sub); }

.btn-send {
  background: linear-gradient(135deg, var(--primary), #0099cc);
  color: #000;
  border: none;
  padding: 12px 22px;
  border-radius: 10px;
  font-family: var(--ff);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--glow-p); }
.btn-send:disabled, .chat-input-row input:disabled { opacity: .35; cursor: not-allowed; }

.chat-note {
  text-align: center;
  font-size: .73rem;
  color: var(--sub);
  padding: 6px 0 12px;
  background: var(--bg2);
}

/* ── HISTORY MODAL ──────────────────────────────────────── */
.hist-msg { display: flex; flex-direction: column; max-width: 80%; animation: fadeIn .2s ease; }
.hist-user  { align-self: flex-end; align-items: flex-end; }
.hist-agent { align-self: flex-start; }
.hist-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: .87rem;
  line-height: 1.5;
}
.hist-user .hist-bubble  { background: linear-gradient(135deg, var(--green), #059669); color: #fff; border-bottom-right-radius: 3px; }
.hist-agent .hist-bubble { background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.hist-time { font-size: .68rem; color: var(--sub); margin-top: 3px; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-messages { padding: 16px; }
  .msg { max-width: 88%; }
  .topbar-logo { display: none; }
}
