/* ============================================================
   SYMPHO · K'IN — Energy Intelligence Platform styles
   Acento solar dorado sobre la base navy de Sympho.
   ============================================================ */

:root {
  /* solar gold — el acento propio de K'in (PRD §18.3) */
  --kin:     oklch(0.80 0.155 80);
  --kin-dim: oklch(0.80 0.155 80 / 0.16);
}
[data-theme="light"] { --kin: oklch(0.72 0.15 72); }

/* ---- live pulse dot ---- */
.kin-live { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11px; color: var(--text-3); letter-spacing: 0.04em; }
.kin-live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ek);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--ek) 70%, transparent);
  animation: kinPulse 2s var(--ease) infinite;
}
@keyframes kinPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ek) 60%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .kin-live::before { animation: none; } }

/* ---- big live metric tile ---- */
.kin-live-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; overflow: hidden;
}
.kin-live-tile[data-accent="true"] {
  background: linear-gradient(160deg, color-mix(in oklch, var(--kin) 12%, var(--surface)), var(--surface) 60%);
  border-color: color-mix(in oklch, var(--kin) 32%, var(--line));
}
.kin-live-tile .kin-tile-top { display: flex; align-items: center; justify-content: space-between; }
.kin-tile-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--kin-dim); color: var(--kin); border: 1px solid color-mix(in oklch, var(--kin) 28%, transparent); }
.kin-tile-val { font-family: var(--disp); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.kin-tile-val small { font-size: 14px; color: var(--text-4); font-weight: 500; }
.kin-tile-lbl { font-size: 12.5px; color: var(--text-3); }

/* ---- radial gauge ---- */
.kin-gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kin-gauge-cap { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-4); }

/* ============================================================
   DIGITAL TWIN — diagrama unifilar
   ============================================================ */
.kin-twin {
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg-2);
  border: 1px solid var(--line); border-radius: 14px; padding: 26px; position: relative; overflow: auto;
}
.kin-bus { position: relative; display: flex; flex-direction: column; align-items: center; }
.kin-source {
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 15px; border-radius: 10px;
  background: var(--surface); border: 1px solid color-mix(in oklch, var(--kin) 36%, var(--line-2));
  color: var(--text); font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.kin-source .kin-src-ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--kin); color: oklch(0.16 0.02 264); }
.kin-drop { width: 2px; height: 24px; background: var(--line-strong); }
.kin-mainbus { height: 3px; border-radius: 3px; background: var(--line-strong); }

/* node card in the single-line diagram */
.kin-node {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px 13px; min-width: 150px; cursor: pointer; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  position: relative; text-align: left;
}
.kin-node:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kin-node[data-on="true"] { border-color: color-mix(in oklch, var(--kin) 60%, transparent); box-shadow: 0 0 0 3px var(--kin-dim); }
.kin-node[data-sev="warn"] { border-color: color-mix(in oklch, var(--warn) 50%, var(--line-2)); }
.kin-node[data-sev="crit"] { border-color: color-mix(in oklch, var(--bad) 55%, var(--line-2)); }
.kin-node-top { display: flex; align-items: center; gap: 8px; }
.kin-node-ic { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; flex: none; color: oklch(0.16 0.02 264); }
.kin-node-name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.25; }
.kin-node-kw { font-family: var(--mono); font-size: 15px; color: var(--text); margin-top: 8px; }
.kin-node-meta { font-family: var(--mono); font-size: 10px; color: var(--text-4); margin-top: 3px; }
.kin-node-bar { height: 4px; border-radius: 3px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.kin-node-bar > i { display: block; height: 100%; border-radius: 3px; }

.kin-feeders { display: flex; gap: 18px; align-items: flex-start; flex-wrap: nowrap; }
.kin-feeder { display: flex; flex-direction: column; align-items: center; }
.kin-feeder-drop { width: 2px; height: 18px; background: var(--line-2); }
.kin-children { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.kin-child {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; transition: background 0.13s, border-color 0.13s; min-width: 200px;
}
.kin-child:hover { background: var(--surface-3); }
.kin-child[data-on="true"] { border-color: color-mix(in oklch, var(--kin) 50%, transparent); }
.kin-dot-sm { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* inspector panel */
.kin-inspect { background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; padding: 18px; }
.kin-inspect-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.kin-inspect-row:first-of-type { border-top: none; }

/* topology tree */
.kin-tree { font-family: var(--mono); font-size: 12.5px; }
.kin-tree-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; cursor: pointer; transition: background 0.12s; }
.kin-tree-row:hover { background: var(--surface-2); }
.kin-tree-row[data-on="true"] { background: var(--kin-dim); }
.kin-tree-kw { margin-left: auto; color: var(--text-3); }

/* ============================================================
   MONITOREO — live bars
   ============================================================ */
.kin-livebars { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.kin-livebar { flex: 1; border-radius: 3px 3px 0 0; background: color-mix(in oklch, var(--kin) 55%, var(--surface-3)); transition: height 0.6s var(--ease); min-width: 0; }
.kin-livebar[data-now="true"] { background: var(--kin); }
.kin-livebar[data-period="punta"] { background: color-mix(in oklch, var(--bad) 60%, var(--surface-3)); }

/* harmonic spectrum bars */
.kin-harm { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.kin-harm-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.kin-harm-bar { width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(var(--kin), color-mix(in oklch, var(--kin) 50%, var(--surface-3))); }
.kin-harm-bar[data-hot="true"] { background: linear-gradient(var(--bad), color-mix(in oklch, var(--bad) 50%, var(--surface-3))); }

/* ============================================================
   ALERTAS
   ============================================================ */
.kin-alert {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 14px; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: border-color 0.14s;
}
.kin-alert:hover { border-color: var(--line-strong); }
.kin-alert-spine { width: 4px; }
.kin-alert[data-sev="crit"] .kin-alert-spine { background: var(--bad); }
.kin-alert[data-sev="high"] .kin-alert-spine { background: var(--warn); }
.kin-alert[data-sev="med"] .kin-alert-spine { background: var(--kin); }
.kin-alert[data-sev="low"] .kin-alert-spine { background: var(--text-4); }
.kin-alert-body { padding: 14px 0; }
.kin-alert-side { padding: 14px 16px 14px 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; justify-content: center; }
.kin-sev-tag { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 7px; border-radius: 5px; }
.kin-sev-tag[data-sev="crit"] { background: color-mix(in oklch, var(--bad) 22%, transparent); color: color-mix(in oklch, var(--bad) 84%, white); }
.kin-sev-tag[data-sev="high"] { background: color-mix(in oklch, var(--warn) 22%, transparent); color: color-mix(in oklch, var(--warn) 80%, white); }
.kin-sev-tag[data-sev="med"] { background: var(--kin-dim); color: color-mix(in oklch, var(--kin) 82%, white); }
.kin-sev-tag[data-sev="low"] { background: var(--surface-3); color: var(--text-3); }

/* ============================================================
   COPILOT — chat
   ============================================================ */
.kin-chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kin-chat-scroll { flex: 1; overflow-y: auto; padding: 8px 2px; display: flex; flex-direction: column; gap: 16px; }
.kin-msg { display: flex; gap: 11px; max-width: 92%; }
.kin-msg[data-role="user"] { align-self: flex-end; flex-direction: row-reverse; }
.kin-msg-av { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.kin-msg-av[data-role="ai"] { background: linear-gradient(150deg, color-mix(in oklch, var(--kin) 96%, white), color-mix(in oklch, var(--kin) 72%, black)); color: oklch(0.16 0.02 264); }
.kin-msg-av[data-role="user"] { background: var(--surface-3); color: var(--text-2); }
.kin-bubble {
  padding: 12px 15px; border-radius: 13px; font-size: 13.5px; line-height: 1.6; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-2); white-space: pre-wrap;
}
.kin-msg[data-role="user"] .kin-bubble { background: var(--kin-dim); border-color: color-mix(in oklch, var(--kin) 30%, transparent); }
.kin-bubble.thinking { color: var(--text-3); }
.kin-typing { display: inline-flex; gap: 4px; align-items: center; }
.kin-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); animation: kinType 1.2s infinite var(--ease); }
.kin-typing i:nth-child(2) { animation-delay: 0.18s; }
.kin-typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes kinType { 0%,60%,100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.kin-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kin-chip-q {
  padding: 8px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2);
  color: var(--text-2); font-size: 12.5px; cursor: pointer; transition: all 0.14s; font-family: var(--ui); text-align: left;
}
.kin-chip-q:hover { border-color: color-mix(in oklch, var(--kin) 50%, var(--line-2)); color: var(--text); background: var(--surface-3); }

.kin-composer { display: flex; gap: 9px; align-items: flex-end; padding-top: 12px; }
.kin-composer textarea {
  flex: 1; resize: none; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px 14px; color: var(--text); font-family: var(--ui); font-size: 13.5px; line-height: 1.5; outline: none; max-height: 120px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kin-composer textarea:focus { border-color: color-mix(in oklch, var(--kin) 60%, var(--line-2)); box-shadow: 0 0 0 3px var(--kin-dim); }
.kin-send { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--kin); color: oklch(0.16 0.02 264); border: none; cursor: pointer; transition: filter 0.14s; }
.kin-send:hover { filter: brightness(1.06); }
.kin-send:disabled { opacity: 0.5; cursor: default; }

/* source citation pill under AI answers */
.kin-cite { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; font-family: var(--mono); font-size: 10.5px; color: var(--text-4); }

/* ============================================================
   RECOMENDACIONES / AUTOMATIZACIÓN
   ============================================================ */
.kin-rec { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color 0.15s; }
.kin-rec:hover { border-color: color-mix(in oklch, var(--kin) 38%, var(--line)); }
.kin-rec-impact { font-family: var(--disp); font-size: 22px; font-weight: 600; color: var(--kin); letter-spacing: -0.01em; }
.kin-conf { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.kin-conf > i { display: block; height: 100%; background: var(--kin); border-radius: 3px; }

.kin-level-tag { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 5px; background: var(--surface-3); color: var(--text-3); }
.kin-level-tag[data-lvl="Advisory"] { background: var(--surface-3); color: var(--text-2); }
.kin-level-tag[data-lvl="Approval"] { background: var(--kin-dim); color: color-mix(in oklch, var(--kin) 82%, white); }
.kin-level-tag[data-lvl="Autónomo"], .kin-level-tag[data-lvl="Autonomous"] { background: color-mix(in oklch, var(--ek) 18%, transparent); color: color-mix(in oklch, var(--ek) 82%, white); }

/* rule builder */
.kin-flow { display: flex; flex-direction: column; gap: 0; }
.kin-flow-node { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); }
.kin-flow-node[data-kind="trigger"] { border-color: color-mix(in oklch, var(--kin) 40%, var(--line-2)); }
.kin-flow-node[data-kind="condition"] { border-style: dashed; }
.kin-flow-ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.kin-flow-link { width: 2px; height: 18px; background: var(--line-2); margin-left: 33px; }

/* control level cards */
.kin-ctrl { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 16px; position: relative; }
.kin-ctrl-num { font-family: var(--disp); font-size: 34px; font-weight: 600; color: var(--kin); opacity: 0.4; line-height: 1; }

/* connector card */
.kin-conn { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color 0.15s; }
.kin-conn[data-on="true"] { border-color: color-mix(in oklch, var(--kin) 36%, var(--line)); }

/* segmented tabs reuse .seg (from views.css) — kin accent */
.kin .seg-btn[data-on="true"] svg { color: var(--kin); }

/* stacked bar (tariff periods) */
.kin-stack { display: flex; height: 30px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.kin-stack > i { height: 100%; }

/* mini legend dot */
.kin-leg { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
