/* ══════════════════════════════════════════════════════
   TRAFFIC LIVE — estilos completos v4
   ══════════════════════════════════════════════════════ */

/* ── Client selector ── */
.tl-client-selector {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.tl-client-selector select {
  background: rgba(0,200,255,.06); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 5px 10px;
  font-size: 12px; cursor: pointer; outline: none; min-width: 210px;
}
.tl-client-selector select:focus { border-color: var(--accent); }

/* ── Mode toggle ── */
.mode-toggle {
  display: flex; background: rgba(0,200,255,.05);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.mode-btn {
  background: transparent; border: none; color: var(--text-muted);
  padding: 6px 16px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .2s;
}
.mode-btn.active { background: rgba(0,200,255,.15); color: var(--accent); }
.mode-btn:hover:not(.active) { color: var(--text); }

/* ── Legend dots ── */
.legend { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.tl-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}
.tl-dot.active  { background: #00ff88; box-shadow: 0 0 5px #00ff88; }
.tl-dot.idle    { background: #f59e0b; box-shadow: 0 0 5px #f59e0b; }
.tl-dot.trigger { background: #ef4444; box-shadow: 0 0 7px #ef4444; }

/* ── High load banner ── */
.high-load-banner {
  background: rgba(255,109,58,.12); border-bottom: 1px solid rgba(255,109,58,.3);
  color: var(--orange); font-size: 12px; padding: 6px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.high-load-banner button { background:none; border:none; color:var(--orange); cursor:pointer; font-size:16px; }

/* ── Layout ── */
.tl-layout { display: flex; flex: 1; overflow: hidden; position: relative; z-index: 1; }

/* ── Sidebar ── */
.tl-sidebar {
  width: 220px; background: rgba(10,10,20,.96);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0; overflow-y: auto;
}
.tl-sidebar-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tl-sidebar-section h3 {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 8px;
}
.mini-stat { display:flex; justify-content:space-between; align-items:center; padding:3px 0; font-size:12px; color:var(--text-muted); }
.mini-stat span:last-child { color:var(--text); font-weight:600; }
.url-item { display:flex; align-items:center; gap:6px; padding:4px 0; font-size:11px; border-bottom:1px solid rgba(0,200,255,.04); }
.url-item .url-path { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text); }
.url-item .url-count { font-weight:700; color:var(--accent); font-size:11px; background:rgba(0,200,255,.1); border-radius:8px; padding:1px 7px; }

/* ── Main ── */
.tl-main { flex:1; overflow:hidden; display:flex; flex-direction:column; }
.tl-view { flex:1; overflow:hidden; display:flex; flex-direction:column; }
.tl-empty {
  flex:1; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:16px; color:var(--text-muted); font-size:14px; text-align:center;
}
.tl-empty .empty-icon { font-size:56px; opacity:.15; }

/* ══════════════════════════════════════════════════════
   VISITOR LIST — estilo Zopim
   ══════════════════════════════════════════════════════ */

.vl-wrap { flex:1; overflow-y:auto; display:flex; flex-direction:column; }

.vl-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  background: rgba(10,10,20,.8); flex-shrink: 0;
}
.vl-topbar-title { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; }
.vl-topbar-total { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.vl-search {
  background: rgba(0,200,255,.05); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 12px; color: var(--text);
  font-size: 12px; outline: none; width: 180px;
}
.vl-search:focus { border-color: var(--accent); }

.vl-group { flex-shrink: 0; }
.vl-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; cursor: pointer; user-select: none;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.vl-group-header:hover { background: rgba(255,255,255,.03); }
.vl-group-header.trigger { color: #ef4444; background: rgba(239,68,68,.05); }
.vl-group-header.active  { color: #00ff88; background: rgba(0,255,136,.04); }
.vl-group-header.idle    { color: #f59e0b; background: rgba(245,158,11,.04); }
.vl-group-header.offline { color: #888; background: rgba(100,100,120,.04); }
.vl-toggle { font-size: 16px; line-height:1; width:16px; text-align:center; flex-shrink:0; }
.vl-group-name { flex: 1; }
.vl-group-count { font-size: 11px; opacity: .7; font-weight: 400; text-transform: none; letter-spacing: 0; }

.vl-table { width:100%; border-collapse:collapse; font-size:12px; }
.vl-table th {
  text-align:left; padding:7px 10px 7px 20px; font-size:10px; font-weight:700;
  text-transform:uppercase; letter-spacing:.8px; color:var(--text-muted);
  border-bottom:1px solid var(--border); white-space:nowrap;
  background:rgba(10,10,20,.5); position:sticky; top:0; z-index:2;
}
.vl-table th:first-child { width:36px; text-align:center; padding-left:20px; }
.vl-table td { padding:8px 10px 8px 20px; border-bottom:1px solid rgba(0,200,255,.04); vertical-align:middle; }
.vl-table tr:hover td { background:rgba(0,200,255,.04); }
.vl-table tr:last-child td { border-bottom:none; }

.vl-num { width:36px; text-align:center; color:var(--text-muted); font-size:11px; }

.vl-visitor-cell { display:flex; align-items:center; gap:8px; min-width:0; }
.vl-status-orb {
  width:12px; height:12px; border-radius:50%; flex-shrink:0;
  box-shadow: 0 0 7px currentColor;
}
.vl-status-orb.active  { background:#00ff88; color:#00ff88; }
.vl-status-orb.idle    { background:#f59e0b; color:#f59e0b; }
.vl-status-orb.trigger { background:#ef4444; color:#ef4444; animation:trigPulse 1s ease-in-out infinite; }
.vl-status-orb.offline { background:#666; color:#666; box-shadow:none; }
@keyframes trigPulse { 0%,100%{opacity:.6;transform:scale(1)}50%{opacity:1;transform:scale(1.3)} }

.vl-visitor-id { font-family:monospace; font-size:11px; color:var(--accent); white-space:nowrap; }
.vl-ctx-badge {
  font-size:10px; padding:1px 6px; border-radius:6px; font-weight:600; flex-shrink:0;
}
.vl-ctx-badge.admin  { background:rgba(255,109,58,.12); color:#ff6d3a; }
.vl-ctx-badge.user   { background:rgba(0,255,136,.1);   color:#00ff88; }
.vl-ctx-badge.public { background:rgba(0,200,255,.07);  color:var(--accent); }

.vl-online { white-space:nowrap; font-weight:600; font-size:12px; color:var(--text); }
.vl-online.offline-time { color: var(--text-muted); font-weight:400; font-style:italic; }

.vl-viewing { max-width:220px; }
.vl-page-step {
  display:inline-flex; align-items:center; justify-content:center;
  width:18px; height:18px; border-radius:4px; font-size:10px; font-weight:700;
  background:rgba(0,200,255,.12); color:var(--accent); flex-shrink:0; margin-right:6px;
}
.vl-page-title { font-size:11px; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.vl-ref { font-size:11px; color:var(--text-muted); max-width:160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.vl-country { font-size:12px; white-space:nowrap; }
.vl-empty-group { padding:14px 20px; font-size:12px; color:var(--text-muted); font-style:italic; }

/* Offline rows */
.vl-row-offline td { opacity: .5; }
.vl-row-offline:hover td { opacity: .7 !important; }

/* Clickable rows */
.vl-row-clickable { cursor: pointer; transition: background .12s; }
.vl-row-clickable.vl-row-active td { background: rgba(0,200,255,.07) !important; }

/* ══════════════════════════════════════════════════════
   VISUALIZATION LIVE v2 — motor avanzado
   ══════════════════════════════════════════════════════ */

.viz-wrap {
  flex:1; overflow:auto; position:relative;
  background: radial-gradient(ellipse at center, rgba(0,200,255,.03) 0%, transparent 70%);
}
.viz-canvas {
  position:relative; min-width:100%; min-height:100%;
  padding:40px;
}

/* Cluster */
.viz-cluster {
  position:absolute;
  display:flex; flex-direction:column; align-items:center;
  cursor:default;
  transition: opacity .3s, transform .3s;
}
.viz-cluster-bubble-area {
  position:relative;
  transition: width .4s cubic-bezier(.4,0,.2,1), height .4s cubic-bezier(.4,0,.2,1);
}

/* Círculo de fondo del cluster */
.viz-cluster-bg {
  position:absolute; border-radius:50%;
  background: rgba(0,200,255,.05);
  border: 1px solid rgba(0,200,255,.1);
  transform:translate(-50%,-50%); top:50%; left:50%;
  transition: background .4s, border-color .4s, box-shadow .4s, width .4s, height .4s;
  pointer-events:none;
}
.viz-cluster-bg.has-trigger {
  background: rgba(239,68,68,.07);
  border-color: rgba(239,68,68,.25);
  box-shadow: 0 0 30px rgba(239,68,68,.08);
}
.viz-cluster-bg.has-active {
  background: rgba(0,255,136,.05);
  border-color: rgba(0,255,136,.2);
}

/* Etiqueta y contador de cluster */
.viz-cluster-label {
  margin-top:10px; max-width:160px; text-align:center;
  font-size:11px; font-family:monospace; color:var(--accent);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  background:rgba(0,200,255,.07); border:1px solid var(--border);
  border-radius:6px; padding:3px 10px;
}
.viz-cluster-count {
  font-size:10px; color:var(--text-muted); margin-top:3px; text-align:center;
}

/* ── Burbuja individual ── */
@keyframes bubblePop    { 0%{transform:translate(-50%,-50%) scale(0)} 100%{transform:translate(-50%,-50%) scale(1)} }
@keyframes trigBubble   { 0%,100%{box-shadow:0 0 20px rgba(239,68,68,.5)} 50%{box-shadow:0 0 32px rgba(239,68,68,.9),0 0 10px rgba(239,68,68,.6)} }
@keyframes vizFloat     {
  0%,100% { margin-top:0; margin-left:0; }
  25%     { margin-top:calc(var(--fy,2px) * -1); margin-left:var(--fx,3px); }
  75%     { margin-top:var(--fy,2px); margin-left:calc(var(--fx,3px) * -1); }
}

.viz-bubble {
  position:absolute;
  width:54px; height:54px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  transform:translate(-50%,-50%);
  border: 2px solid rgba(255,255,255,.12);
  font-size:11px; font-weight:700; color:rgba(255,255,255,.85);
  text-align:center; line-height:1.2; user-select:none;
  transition: left .5s cubic-bezier(.4,0,.2,1),
              top  .5s cubic-bezier(.4,0,.2,1),
              opacity .3s, filter .3s, box-shadow .3s;
  animation: bubblePop .35s cubic-bezier(.34,1.56,.64,1);
}
.viz-bubble:hover { z-index:100; }

/* Estado activo — verde + float */
.viz-bubble.active {
  background: radial-gradient(circle at 35% 35%, rgba(0,255,136,.9), #00b060);
  box-shadow: 0 0 16px rgba(0,255,136,.5), 0 0 4px rgba(0,255,136,.3);
  animation: bubblePop .35s cubic-bezier(.34,1.56,.64,1),
             vizFloat var(--fdur,4s) ease-in-out var(--fd,0s) infinite;
}

/* Estado idle — azul + float suave */
.viz-bubble.idle {
  background: radial-gradient(circle at 35% 35%, rgba(0,180,255,.7), rgba(0,120,200,.5));
  box-shadow: 0 0 10px rgba(0,180,255,.25);
  animation: bubblePop .35s cubic-bezier(.34,1.56,.64,1),
             vizFloat var(--fdur,5s) ease-in-out var(--fd,0s) infinite;
}

/* Estado trigger — rojo pulsante */
.viz-bubble.trigger {
  background: radial-gradient(circle at 35% 35%, #ff6666, #cc0000);
  box-shadow: 0 0 20px rgba(239,68,68,.6), 0 0 6px rgba(239,68,68,.4);
  animation: bubblePop .35s cubic-bezier(.34,1.56,.64,1),
             trigBubble 1.2s ease-in-out infinite .35s;
}

/* Estado offline — gris translúcido */
.viz-bubble.offline {
  background: radial-gradient(circle at 35% 35%, rgba(120,120,140,.6), rgba(70,70,90,.4));
  box-shadow: none; border-color: rgba(255,255,255,.06);
  opacity: .45; filter: grayscale(.7);
  animation: bubblePop .35s cubic-bezier(.34,1.56,.64,1);
}

/* Contenido de burbuja */
.viz-bubble-inner { pointer-events:none; text-align:center; }
.viz-bubble-icon  { font-size:20px; line-height:1; }
.viz-bubble-label { font-size:9px; opacity:.85; margin-top:1px; }

/* Tooltip via ::after */
.viz-bubble::after {
  content: attr(data-tip);
  position:absolute; bottom:calc(100% + 8px); left:50%; transform:translateX(-50%);
  background:rgba(10,10,20,.97); border:1px solid var(--border);
  border-radius:7px; padding:5px 10px; font-size:11px;
  white-space:nowrap; color:var(--text); opacity:0; pointer-events:none;
  transition:opacity .2s; z-index:200; font-weight:400;
}
.viz-bubble:hover::after { opacity:1; }

/* ── Modo inspección ── */
.viz-bubble.viz-dimmed {
  opacity: .08 !important;
  filter: grayscale(1) !important;
  pointer-events: none;
  animation: none !important;
}
.viz-bubble.viz-focused {
  transform: translate(-50%,-50%) scale(1.22) !important;
  z-index: 200;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1) !important;
}
.viz-bubble.viz-focused::after { opacity:1; }

/* ── Burbuja en tránsito ── */
.viz-transit-bubble {
  position: absolute;
  width: 44px; height: 44px; border-radius: 50%;
  pointer-events: none; z-index: 300;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.2);
  box-shadow: 0 0 20px rgba(0,200,255,.4);
}
.viz-transit-bubble.active  { background: radial-gradient(circle at 35% 35%, rgba(0,255,136,.85), #00b060); }
.viz-transit-bubble.idle    { background: radial-gradient(circle at 35% 35%, rgba(0,180,255,.7), rgba(0,120,200,.5)); }
.viz-transit-bubble.trigger { background: radial-gradient(circle at 35% 35%, #ff6666, #cc0000); }
.viz-transit-bubble.offline { background: rgba(100,100,120,.5); }

/* Trail del tránsito */
.viz-transit-trail {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none; z-index: 299;
  transform: translate(-50%, -50%);
  background: rgba(0,200,255,.4);
  animation: trailFade .4s ease-out forwards;
}
@keyframes trailFade { 0%{opacity:.6;transform:translate(-50%,-50%) scale(1)} 100%{opacity:0;transform:translate(-50%,-50%) scale(.3)} }

/* ── SVG overlay (path lines) ── */
#viz-svg-overlay { position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; overflow:visible; }
.viz-path-line { stroke-linecap:round; stroke-linejoin:round; }

/* ── Zoom controls ── */
.viz-controls {
  position:absolute; bottom:16px; right:16px;
  display:flex; flex-direction:column; gap:4px; z-index:50;
}
.viz-ctrl-btn {
  width:32px; height:32px; border-radius:7px; border:1px solid var(--border);
  background:rgba(10,10,20,.9); color:var(--accent); font-size:16px;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:all .2s;
}
.viz-ctrl-btn:hover { background:rgba(0,200,255,.1); border-color:var(--accent); }

/* High load */
.high-load-active .viz-bubble.idle {
  animation: none !important;
  opacity: .35; box-shadow: none;
}
.high-load-active .viz-bubble.active {
  animation: bubblePop .35s cubic-bezier(.34,1.56,.64,1) !important;
}

/* ── Toast ── */
.toast {
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px);
  background:rgba(20,20,40,.97); border:1px solid var(--border);
  border-radius:10px; padding:10px 20px; font-size:13px; color:var(--text);
  opacity:0; transition:all .3s; pointer-events:none; z-index:9999; white-space:nowrap;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* ══════════════════════════════════════════════════════
   VISITOR DETAIL DRAWER
   ══════════════════════════════════════════════════════ */

.vd-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; z-index: 500;
  transition: opacity .25s;
}
.vd-overlay.open { opacity: 1; pointer-events: auto; }

.vd-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 340px; max-width: 90vw;
  background: rgba(10,10,22,.98);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 501; box-shadow: -8px 0 40px rgba(0,0,0,.5);
}
.vd-drawer.open { transform: translateX(0); }

.vd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.vd-header-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vd-status-orb {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.vd-status-orb.active  { background: #00ff88; color: #00ff88; }
.vd-status-orb.idle    { background: #f59e0b; color: #f59e0b; }
.vd-status-orb.trigger { background: #ef4444; color: #ef4444; animation: trigPulse 1s ease-in-out infinite; }
.vd-status-orb.offline { background: #666; color: #666; box-shadow: none; }
.vd-title { font-size: 14px; font-weight: 700; color: var(--text); font-family: monospace; }
.vd-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 6px; font-weight: 600; flex-shrink: 0;
}
.vd-badge.admin  { background: rgba(255,109,58,.15); color: #ff6d3a; }
.vd-badge.user   { background: rgba(0,255,136,.1);   color: #00ff88; }
.vd-badge.public { background: rgba(0,200,255,.08);  color: var(--accent); }
.vd-close {
  background: none; border: none; color: var(--text-muted); font-size: 16px;
  cursor: pointer; padding: 4px; border-radius: 5px; line-height: 1;
  transition: color .15s, background .15s; flex-shrink: 0;
}
.vd-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

.vd-meta {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 5px; flex-shrink: 0;
}
.vd-meta-row {
  display: flex; justify-content: space-between; align-items: center; font-size: 12px;
}
.vd-meta-row span:first-child { color: var(--text-muted); }
.vd-meta-row span:last-child  { color: var(--text); font-weight: 500; }
.vd-status-text.active  { color: #00ff88; }
.vd-status-text.idle    { color: #f59e0b; }
.vd-status-text.trigger { color: #ef4444; font-weight: 700; }
.vd-status-text.offline { color: #888; }

.vd-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.4px; color: var(--text-muted);
  padding: 12px 18px 6px; flex-shrink: 0;
}

.vd-timeline {
  flex: 1; overflow-y: auto; padding: 6px 18px 20px;
  display: flex; flex-direction: column; gap: 0;
}
.vd-tl-empty { font-size: 12px; color: var(--text-muted); font-style: italic; padding: 8px 0; }

.vd-tl-item { display: flex; gap: 12px; min-height: 48px; }
.vd-tl-line-wrap {
  display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 16px;
}
.vd-tl-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(0,200,255,.25); border: 2px solid var(--border);
  flex-shrink: 0; margin-top: 4px; transition: background .2s, border-color .2s;
}
.vd-tl-dot.current { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px rgba(0,200,255,.6); }
.vd-tl-connector { flex: 1; width: 2px; background: rgba(0,200,255,.1); margin: 3px 0; border-radius: 1px; min-height: 16px; }
.vd-tl-content { flex: 1; padding-bottom: 12px; min-width: 0; }
.vd-tl-path {
  font-size: 12px; color: var(--text); font-family: monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4;
}
.vd-tl-item.current .vd-tl-path { color: var(--accent); font-weight: 600; }
.vd-tl-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
