/* ==========================================================================
   AI Business Universe — stylesheet
   Estética: Bloomberg Terminal x McKinsey Digital x NASA Mission Control
   ========================================================================== */

/* Todas las variables y el reset quedan SCOPEADOS a #abu-wrapper para no
   filtrarse al resto del tema de WordPress (nada de :root, html, body). */
#abu-wrapper {
  --bg-0: #05070d;
  --bg-1: #0a0f1c;
  --bg-2: #111827;
  --glass: rgba(15, 22, 40, 0.72);
  --stroke: rgba(120, 160, 220, 0.18);
  --text: #e6edf7;
  --muted: #8aa0c0;
  --accent: #4cc9f0;
  --accent-2: #7b5cff;
  --good: #3ddc97;
  --bad: #ff5d73;
  --warn: #ffc857;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --sans: 'Inter', 'SF Pro Display', system-ui, sans-serif;

  position: relative;
  width: 100%;
  height: 800px;
  max-height: 90vh;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
}
#abu-wrapper * { box-sizing: border-box; }

/* TOP BAR */
#abu-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(5,7,13,0.95), rgba(5,7,13,0.55));
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
}

.abu-brand { display: flex; align-items: center; gap: 12px; }

.abu-brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.abu-brand h1 { font-size: 13px; letter-spacing: 3px; font-weight: 600; margin: 0; color: var(--text); }
.abu-brand .sub { color: var(--muted); font-size: 10px; letter-spacing: 2px; }

.abu-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.abu-pill {
  background: linear-gradient(180deg, #0f1a2e, #0a1222);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  transition: all 0.25s ease;
}
.abu-pill:hover { border-color: var(--accent); color: var(--accent); }
.abu-pill.active {
  background: linear-gradient(180deg, #11304a, #0a1f33);
  border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 18px rgba(76,201,240,0.25);
}
.abu-pill.ghost { background: transparent; }

.abu-seg { display: flex; background: var(--bg-1); border: 1px solid var(--stroke); border-radius: 999px; padding: 3px; }
.abu-seg-btn {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  transition: all 0.25s;
}
.abu-seg-btn.active {
  background: linear-gradient(180deg, #1a2a48, #0f1a30);
  color: var(--accent);
  box-shadow: inset 0 0 10px rgba(76,201,240,0.2);
}
.abu-seg-btn:hover { color: var(--text); }


/* MAIN LAYOUT */
#abu-main { position: absolute; top: 60px; left: 0; right: 0; bottom: 0; display: flex; }

#abu-left { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#abu-network { flex: 1 1 auto; min-height: 200px; position: relative; overflow: hidden; }
#abu-network svg { display: block; }
#abu-network.company-off { opacity: 0.35; filter: grayscale(1); transition: opacity 0.3s, filter 0.3s; }

.abu-net-line { stroke: var(--stroke); stroke-width: 1.5; transition: stroke 0.3s, stroke-width 0.3s; }
.abu-net-line.active { stroke: var(--accent); stroke-width: 2.5; }

.abu-net-pulse { fill: var(--accent); opacity: 0; offset-rotate: 0deg; }
.abu-net-pulse.on { opacity: 1; animation: abuNetPulse 1.3s linear infinite; }
@keyframes abuNetPulse { from { offset-distance: 0%; } to { offset-distance: 100%; } }

.abu-net-hub circle {
  fill: #1f1a0c;
  stroke: #ffd166;
  stroke-width: 1.5;
}
.abu-net-hub-label { font-family: var(--mono); font-size: 15px; font-weight: 600; fill: #ffd166; }
.abu-net-hub-caption { font-family: var(--sans); font-size: 11px; letter-spacing: 1px; fill: var(--muted); text-transform: uppercase; }

.abu-net-node circle {
  fill: rgba(20, 30, 55, 0.8);
  stroke: var(--stroke);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.3s, stroke 0.3s, filter 0.3s;
}
.abu-net-node:hover circle { stroke: var(--accent); }
.abu-net-node:focus-visible circle { outline: none; stroke: var(--accent); stroke-width: 2.5; }
.abu-net-node.active circle {
  fill: var(--accent);
  stroke: var(--accent);
  filter: drop-shadow(0 0 8px rgba(76, 201, 240, 0.6));
}
.abu-net-label { font-family: var(--sans); font-size: 12px; fill: var(--text); }
.abu-net-node.active + .abu-net-label { fill: var(--accent); }

/* Rótulo que deja clarísimo qué hacer en el panel de agentes */
#abu-agents-heading {
  flex: 0 0 auto;
  padding: 8px 16px 6px;
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted);
  background: rgba(8, 12, 22, 0.6);
  border-top: 1px solid var(--stroke);
  display: flex; align-items: center; gap: 6px;
}
#abu-agents-heading::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent); flex-shrink: 0;
}

/* PANEL DE AGENTES — control directo, sin necesidad de clic en el 3D */
#abu-agents-panel {
  flex: 0 0 auto;
  height: 250px;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  gap: 10px;
  padding: 10px 16px 14px;
  background: rgba(8, 12, 22, 0.6);
}
#abu-agents-panel::-webkit-scrollbar { height: 6px; }
#abu-agents-panel::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 3px; }

.abu-dept-card {
  flex: 0 0 178px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.abu-dept-card .head {
  display: flex; align-items: center; gap: 6px;
  font-size: 9px; letter-spacing: 1px; color: var(--muted);
  text-transform: uppercase; padding-bottom: 6px;
  border-bottom: 1px solid var(--stroke); margin-bottom: 4px;
}
.abu-dept-card .head .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.abu-dept-card .head .dept-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abu-dept-card .head .dept-count { font-family: var(--mono); color: var(--accent); font-size: 8px; }

.abu-agent-row {
  position: relative;
  padding: 6px 0;
  border-top: 1px dashed var(--stroke);
}
.abu-agent-row:first-of-type { border-top: 0; }
.abu-agent-row .agent-main {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.agent-name-btn {
  background: none; border: 0; color: var(--text);
  font-size: 11px; text-align: left; cursor: pointer; padding: 0;
  font-family: var(--sans); flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agent-name-btn:hover { color: var(--accent); text-decoration: underline; }
.agent-impact {
  display: block; font-family: var(--mono); font-size: 9px;
  color: var(--muted); margin-top: 2px;
}

/* SWITCH — la acción principal, grande y directa */
.abu-switch {
  width: 32px; height: 17px; border-radius: 999px; flex-shrink: 0;
  background: var(--bg-1); border: 1px solid var(--stroke);
  position: relative; cursor: pointer; padding: 0;
}
.abu-switch .knob {
  position: absolute; top: 1px; left: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--muted);
  transition: transform 0.22s ease, background 0.22s ease;
}
.abu-switch.on {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(76,201,240,0.4);
}
.abu-switch.on .knob { transform: translateX(15px); background: #fff; }

.abu-float-badge {
  position: absolute; top: -4px; right: 0;
  font-family: var(--mono); font-size: 9px; color: var(--good);
  background: rgba(10,18,34,0.9); padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--good);
  animation: abuFloatUp 1.2s ease forwards;
  pointer-events: none; white-space: nowrap; z-index: 5;
}
@keyframes abuFloatUp {
  0% { opacity: 0; transform: translateY(4px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* DASHBOARD */
#abu-dashboard {
  width: 340px;
  background: rgba(10, 15, 28, 0.95);
  border-left: 1px solid var(--stroke);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#abu-dashboard::-webkit-scrollbar { width: 6px; }
#abu-dashboard::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 3px; }

.abu-panel {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
}
.abu-panel h2 {
  font-size: 9px; letter-spacing: 2px; color: var(--muted);
  text-transform: uppercase; margin: 0 0 10px;
  display: flex; align-items: center; gap: 6px;
}
.abu-panel h2::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}

/* IMPACTO — los números grandes, imposibles de no notar */
.abu-impact-banner {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.impact-stat {
  text-align: center; border-radius: 10px; padding: 10px 6px;
  background: linear-gradient(180deg, rgba(20,30,55,0.6), rgba(10,18,34,0.6));
  border: 1px solid var(--stroke);
}
.impact-stat .v {
  font-family: var(--mono); font-size: 19px; font-weight: 700;
  color: var(--accent); line-height: 1.2;
}
.impact-stat .l {
  font-size: 8px; letter-spacing: 1px; color: var(--muted);
  text-transform: uppercase; margin-top: 3px;
}
.impact-stat.flash .v { animation: abuPulseFlash 0.7s ease; }
@keyframes abuPulseFlash {
  0% { text-shadow: 0 0 0 transparent; }
  35% { color: var(--good); text-shadow: 0 0 16px var(--good); }
  100% { color: var(--accent); text-shadow: 0 0 0 transparent; }
}

.abu-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.abu-kpi {
  background: linear-gradient(180deg, rgba(20,30,55,0.6), rgba(10,18,34,0.6));
  border: 1px solid var(--stroke);
  border-radius: 8px; padding: 8px 10px;
  position: relative; overflow: hidden;
}
.abu-kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0.6;
}
.abu-kpi.good::before { background: var(--good); }
.abu-kpi.bad::before { background: var(--bad); }
.abu-kpi.warn::before { background: var(--warn); }
.abu-kpi .label { font-size: 8px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.abu-kpi .v { font-family: var(--mono); font-size: 13px; font-weight: 600; margin-top: 3px; color: var(--text); display: block; }
.abu-kpi .v.flash { animation: abuPulseFlash 0.7s ease; }
.abu-kpi .delta { font-family: var(--mono); font-size: 9px; margin-top: 2px; color: var(--good); }
.abu-kpi.bad .delta { color: var(--bad); }
.abu-kpi.warn .delta { color: var(--warn); }

.abu-chart-wrap { height: 140px; position: relative; }
.abu-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Detalle expandible: todo lo avanzado vive aquí, colapsado por defecto */
.abu-details { cursor: default; }
.abu-details > summary {
  list-style: none; cursor: pointer;
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.abu-details > summary::-webkit-details-marker { display: none; }
.abu-details > summary::after {
  content: '▾'; margin-left: auto; color: var(--accent);
  transition: transform 0.2s;
}
.abu-details[open] > summary::after { transform: rotate(180deg); }
.abu-details > summary:hover { color: var(--accent); }
.abu-details h3 {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin: 16px 0 6px;
}
.abu-details .abu-kpi-grid { margin-top: 10px; }

/* AGENT DRAWER */
#abu-drawer {
  position: absolute;
  top: 70px; left: 16px; bottom: 16px;
  width: 320px; z-index: 15;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 12px; padding: 20px;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  overflow-y: auto;
  transition: transform 0.35s cubic-bezier(0.2,0.8,0.2,1), opacity 0.3s;
}
#abu-drawer.hidden { transform: translateX(-360px); opacity: 0; pointer-events: none; }
#abu-drawer .close {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: 0; color: var(--muted);
  font-size: 20px; cursor: pointer;
}
#abu-drawer .close:hover { color: var(--accent); }
#abu-drawer h3 { font-size: 16px; margin: 0 0 3px; color: var(--text); }
#abu-drawer .area {
  color: var(--accent); font-family: var(--mono); font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 16px;
}
#abu-drawer .row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px dashed var(--stroke); font-size: 11px;
}
#abu-drawer .row .k { color: var(--muted); }
#abu-drawer .row .v { font-family: var(--mono); color: var(--text); }
#abu-drawer h4 { font-size: 10px; letter-spacing: 2px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; }
#abu-drawer ul { list-style: none; padding: 0; margin: 0; }
#abu-drawer ul li { padding: 5px 0 5px 16px; position: relative; font-size: 11px; color: #cdd7e8; }
#abu-drawer ul li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }
#abu-drawer p { margin: 0; }

.abu-autonomy-bar { height: 5px; background: var(--bg-1); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.abu-autonomy-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.6s; }

/* NOTIFICATIONS */
#abu-notifications {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none;
}
.abu-notif {
  background: linear-gradient(180deg, rgba(20,30,55,0.95), rgba(10,18,34,0.95));
  border: 1px solid var(--accent); color: var(--text);
  padding: 8px 18px; border-radius: 999px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px;
  box-shadow: 0 0 24px rgba(76,201,240,0.35);
  animation: abuSlideIn 0.35s ease, abuFadeOut 0.5s ease 3.5s forwards;
  white-space: nowrap;
}
@keyframes abuSlideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes abuFadeOut { to { opacity: 0; transform: translateY(-10px); } }

/* LOADER */
#abu-loader {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--bg-0);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#abu-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#abu-loader .ring {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid var(--stroke); border-top-color: var(--accent);
  animation: abuSpin 0.9s linear infinite;
}
#abu-loader .msg { font-family: var(--mono); font-size: 10px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }
@keyframes abuSpin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  #abu-dashboard { width: 280px; }
  #abu-drawer { width: 280px; }
  .abu-controls { gap: 8px; }
  .abu-seg-btn { padding: 5px 8px; font-size: 9px; }
  .abu-brand .sub { display: none; }
  #abu-agents-panel { height: 200px; }
  .abu-dept-card { flex-basis: 150px; }
  #abu-agents-heading { font-size: 8px; }
}

@media (max-width: 680px) {
  #abu-main { flex-direction: column; }
  #abu-left { flex: 1 1 auto; min-height: 0; }
  #abu-dashboard { width: 100%; height: 40%; border-left: 0; border-top: 1px solid var(--stroke); }
  #abu-network { min-height: 140px; }
  #abu-agents-panel { height: 180px; }
  #abu-drawer { width: calc(100% - 32px); }
}
