/* ============================================================
   Call Center Bot — Integridad Informática S.A.
   Sistema de diseño unificado (mismo lenguaje que Gestión Comercial):
   Inter + acento azul, neutros suaves, alta legibilidad (base 18px).
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e6eaf0;
  --line-2: #eef1f6;

  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --brand-soft: #eff4ff;

  --ok: #16a34a; --ok-soft: #effdf4;
  --danger: #dc2626; --danger-soft: #fef2f2;
  --warn: #d97706; --warn-soft: #fff7ed;
  --violet: #8b5cf6;

  --sidebar: #0f172a;
  --sidebar-2: #111c33;

  --radius: 14px;
  --radius-sm: 9px;
  --pill: 999px;
  --sh-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
  --sh: 0 6px 22px rgba(15,23,42,.08);
  --sh-lg: 0 24px 60px rgba(15,23,42,.28);
  --fs: 18px; /* base grande: alta legibilidad */
}

* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #e8eefb, var(--bg));
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--brand-d); }

/* ---------- Contenedor del chat ---------- */
.chat-wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 28px; min-height: 100vh; display: flex; flex-direction: column; }

.chat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--sh); overflow: hidden; display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}

/* Cabecera */
.chat-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-d));
}
.chat-avatar {
  width: 48px; height: 48px; border-radius: 14px; flex: none;
  background: rgba(255,255,255,.18); display: grid; place-items: center;
  font-size: 1.6rem; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.chat-titles { line-height: 1.25; }
.chat-titles .t { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.chat-titles .s { font-size: .92rem; opacity: .9; display: flex; align-items: center; gap: 7px; }
.dot-online { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.3); display: inline-block; }
.head-link { margin-left: auto; color: #fff; opacity: .85; text-decoration: none; font-size: .9rem; font-weight: 600; border: 1px solid rgba(255,255,255,.4); padding: 7px 12px; border-radius: var(--pill); }
.head-link:hover { opacity: 1; background: rgba(255,255,255,.14); }

/* Hilo de mensajes */
.thread {
  flex: 1; min-height: 360px; overflow-y: auto;
  padding: 22px; display: flex; flex-direction: column; gap: 14px;
  background:
    linear-gradient(transparent, transparent),
    var(--bg);
}
.msg { max-width: 82%; padding: 13px 17px; border-radius: 18px; font-size: 1.02rem; line-height: 1.5; box-shadow: var(--sh-sm); white-space: pre-wrap; word-wrap: break-word; }
.msg.bot { align-self: flex-start; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.msg b, .msg strong { font-weight: 800; }
.msg.bot a { color: var(--brand-d); font-weight: 700; }
.msg.user a { color: #fff; text-decoration: underline; }

/* Indicador "escribiendo…" */
.typing { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; padding: 15px 18px; border-radius: 18px; display: inline-flex; gap: 5px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Sugerencias (chips) */
.chips { display: flex; flex-wrap: wrap; gap: 9px; padding: 4px 22px 14px; background: var(--bg); }
.chip {
  border: 1.5px solid var(--brand); background: #fff; color: var(--brand-d);
  border-radius: var(--pill); padding: 10px 16px; font: inherit; font-size: .98rem; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .05s; line-height: 1.2;
}
.chip:hover { background: var(--brand-soft); }
.chip:active { transform: translateY(1px); }
.chip.ghost { border-color: var(--line); color: var(--muted); }
.chip.ghost:hover { background: var(--line-2); }

/* Barra de entrada */
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea {
  flex: 1; resize: none; font: inherit; font-size: 1.05rem; padding: 13px 15px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
  max-height: 130px; line-height: 1.4; transition: border-color .15s, box-shadow .15s;
}
.composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.send-btn {
  flex: none; width: 52px; height: 52px; border-radius: 14px; border: 0;
  background: var(--brand); color: #fff; cursor: pointer; display: grid; place-items: center;
  font-size: 1.4rem; transition: background .15s, transform .05s;
}
.send-btn:hover { background: var(--brand-d); }
.send-btn:active { transform: translateY(1px); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }

.foot-note { text-align: center; color: var(--muted); font-size: .82rem; margin: 14px 4px 0; }

/* ---------- Panel de agentes ---------- */
.panel-wrap { max-width: 1100px; margin: 0 auto; padding: 26px 18px 60px; }
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); display: grid; place-items: center; color: #fff; font-size: 1.5rem; box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.panel-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.panel-head .spacer { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--brand); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--sh-sm); }
.kpi .label { color: var(--muted); font-weight: 600; font-size: .85rem; }
.kpi .value { font-size: 1.9rem; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }
.kpi.t-new { border-left-color: var(--brand); } .kpi.t-new .value { color: var(--brand-d); }
.kpi.t-proc { border-left-color: var(--warn); } .kpi.t-proc .value { color: var(--warn); }
.kpi.t-done { border-left-color: var(--ok); } .kpi.t-done .value { color: var(--ok); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; box-shadow: var(--sh-sm); overflow: hidden; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { background: #f8fafc; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
tbody tr:hover { background: #f8fafd; }
.tk-num { font-weight: 800; color: var(--brand-d); white-space: nowrap; }
.tk-det { color: var(--ink-2); font-size: .95rem; }
.muted { color: var(--muted); font-size: .88rem; }

.tag { display: inline-block; padding: 4px 12px; border-radius: var(--pill); font-size: .8rem; font-weight: 700; }
.tag.soporte { background: var(--danger-soft); color: var(--danger); }
.tag.venta { background: var(--ok-soft); color: var(--ok); }
.tag.facturacion { background: var(--warn-soft); color: var(--warn); }
.tag.derivacion { background: #f5f3ff; color: var(--violet); }

.estado-sel { font: inherit; font-size: .92rem; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; font-weight: 700; cursor: pointer; }
.estado-sel.nuevo { color: var(--brand-d); border-color: #bcd0ff; }
.estado-sel.proceso { color: var(--warn); border-color: #fcd9a8; }
.estado-sel.cerrado { color: var(--ok); border-color: #b6f0c9; }

.empty { text-align: center; color: var(--muted); padding: 54px 10px; font-size: 1.05rem; }
.login-box { max-width: 380px; margin: 12vh auto; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; box-shadow: var(--sh-lg); text-align: center; }
.login-box h1 { font-size: 1.3rem; margin: 12px 0 18px; }
.login-box input { width: 100%; font: inherit; font-size: 1.05rem; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.login-box input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--brand); color: #fff; border: 0; border-radius: 12px; padding: 13px 18px; font: inherit; font-size: 1.02rem; font-weight: 700; cursor: pointer; width: 100%; }
.btn:hover { background: var(--brand-d); }
.btn.sec { background: #fff; color: var(--ink); border: 1.5px solid var(--line); width: auto; padding: 10px 16px; }
.btn.sec:hover { background: #f8fafc; }
.err { color: var(--danger); font-weight: 600; min-height: 1.2em; font-size: .9rem; }

/* ---------- Consola: pestañas, grillas, capacitación ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: var(--pill); padding: 9px 16px; font: inherit; font-size: .95rem; font-weight: 700; cursor: pointer; }
.tab:hover { background: #f8fafc; color: var(--ink); }
.tab.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.card.pad { padding: 18px 20px; }
.card.pad h2 { font-size: 1.1rem; font-weight: 800; margin: 0 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.barlist { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.barrow { display: flex; align-items: center; gap: 10px; }
.barrow .lbl { width: 130px; min-width: 130px; font-weight: 700; font-size: .95rem; }
.barrow .track { flex: 1; background: var(--bg); border-radius: 7px; height: 22px; overflow: hidden; }
.barrow .fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-d)); border-radius: 7px; }
.barrow .fill.red { background: linear-gradient(90deg, #f59e0b, #dc2626); }
.barrow .n { width: 38px; text-align: right; font-weight: 800; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 18px; }
.form-row input { flex: 1; min-width: 180px; font: inherit; font-size: 1rem; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 11px; }
.form-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.aplist { display: flex; flex-direction: column; gap: 8px; }
.ap-grupo { margin-bottom: 18px; }
.ap-grupo-tit { font-size: 1.05rem; font-weight: 800; color: var(--ink); margin: 6px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.ap-grupo .apitem { margin-bottom: 8px; }
.apitem { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.apitem .ap-k { font-weight: 800; color: var(--brand-d); }
.apitem .ap-r { flex: 1; color: var(--ink-2); }
.apitem .ap-del { border: 0; background: var(--danger-soft); color: var(--danger); font-weight: 800; border-radius: 8px; padding: 7px 11px; cursor: pointer; }

/* Badge de no leídos */
.badge { display: inline-block; background: var(--danger); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 1px 7px; margin-left: 4px; }

/* Selector de cliente */
#clienteSel { font-weight: 700; max-width: 240px; }

/* Tendencia (SVG) y horas pico */
.hours { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin-top: 10px; }
.hours .hbar { flex: 1; background: var(--brand-soft); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.hours .hbar .hb-fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(180deg, var(--brand), var(--brand-d)); border-radius: 4px 4px 0 0; }
.hours .hbar.peak .hb-fill { background: linear-gradient(180deg, #f59e0b, #dc2626); }
.hours-x { display: flex; gap: 3px; margin-top: 4px; }
.hours-x span { flex: 1; text-align: center; font-size: .6rem; color: var(--muted); }
svg.trend { width: 100%; height: 120px; display: block; margin-top: 10px; }

/* Bandeja de conversaciones */
.inbox { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: stretch; min-height: 60vh; }
.inbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 72vh; overflow-y: auto; }
.conv { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; }
.conv:hover { border-color: #d6dde7; background: #f8fafc; }
.conv.sel { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.conv .conv-top { display: flex; align-items: center; gap: 8px; }
.conv .conv-name { font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .conv-last { color: var(--muted); font-size: .88rem; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot-unread { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; }
.chip-canal { font-size: .68rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: #f1f5f9; color: var(--muted); }
.chip-canal.whatsapp { background: #dcfce7; color: #166534; }
.chip-human { font-size: .68rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }

.inbox-chat { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ic-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f8fafc; flex-wrap: wrap; }
.ic-head .ic-name { font-weight: 800; }
.ic-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 320px; max-height: 56vh; background: var(--bg); }
.ic-msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: .98rem; line-height: 1.45; white-space: pre-wrap; box-shadow: var(--sh-sm); }
.ic-msg.user { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.ic-msg.bot { align-self: flex-end; background: var(--brand-soft); color: var(--ink); }
.ic-msg.agente { align-self: flex-end; background: var(--ok); color: #fff; }
.ic-msg .who { font-size: .68rem; font-weight: 800; opacity: .7; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .04em; }
.ic-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.ic-foot input { flex: 1; font: inherit; font-size: 1rem; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 11px; }
.ic-foot input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ic-foot input:disabled { background: #f1f5f9; }

@media (max-width: 820px) { .inbox { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  :root { --fs: 17px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
  .chat-wrap { padding: 0; }
  .chat-card { border-radius: 0; border: 0; min-height: 100vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
