/* ══════════════════════════════════════════════════════════
   IngelCoding — Factory Viz v2
   Tokens, layout y 3 skins: Classic / Gamer / Negocio / Técnico
   ══════════════════════════════════════════════════════════ */

/* ── Tokens base (skin: classic / paper-amber) ─────────── */
:root {
  --paper:   #F4F1EA;
  --ink:     #1A1A1C;
  --ink2:    #3D3D40;
  --amber:   #B56A1C;
  --amber-l: #D4892E;
  --amber-xl:#F2C07A;
  --muted:   #7A7570;
  --rule:    #D6D0C4;
  --green:   #3A7D44;
  --yellow:  #C8960C;
  --surface: #EDE9DF;
  --overlay: rgba(244,241,234,0.96);

  /* canvas grid */
  --grid-color: var(--rule);
  --belt-top:   #cfc9be;
  --belt-bot:   #b8b2a7;
  --belt-inner: #D6D0C4;

  /* header / legend surface */
  --chrome-bg: var(--paper);
  --chrome-border: var(--rule);

  /* transitions */
  --skin-transition: 0.25s ease;
}

/* ── SKIN: Gamer ─────────────────────────────────────────── */
body.skin-gamer {
  --paper:   #0f0f1a;
  --ink:     #e8e8ff;
  --ink2:    #b0b0cc;
  --amber:   #7c3aed;       /* violeta neon */
  --amber-l: #a855f7;
  --amber-xl:#d8b4fe;
  --muted:   #6b7280;
  --rule:    #2a2a40;
  --green:   #22c55e;
  --yellow:  #eab308;
  --surface: #13131f;
  --overlay: rgba(15,15,26,0.96);
  --grid-color: #1e1e30;
  --belt-top:   #1e1e30;
  --belt-bot:   #151525;
  --belt-inner: #2a2a40;
  --chrome-bg: #0b0b14;
  --chrome-border: #3a3a5c;
}

/* ── SKIN: Negocio ───────────────────────────────────────── */
body.skin-negocio {
  --paper:   #ffffff;
  --ink:     #111827;
  --ink2:    #374151;
  --amber:   #1d4ed8;       /* azul corporativo */
  --amber-l: #2563eb;
  --amber-xl:#93c5fd;
  --muted:   #6b7280;
  --rule:    #e5e7eb;
  --green:   #059669;
  --yellow:  #d97706;
  --surface: #f9fafb;
  --overlay: rgba(255,255,255,0.97);
  --grid-color: #e5e7eb;
  --belt-top:   #d1d5db;
  --belt-bot:   #9ca3af;
  --belt-inner: #e5e7eb;
  --chrome-bg: #f9fafb;
  --chrome-border: #e5e7eb;
}

/* ── SKIN: Técnico ───────────────────────────────────────── */
body.skin-tecnico {
  --paper:   #0d1117;
  --ink:     #c9d1d9;
  --ink2:    #8b949e;
  --amber:   #58a6ff;       /* azul GitHub */
  --amber-l: #79c0ff;
  --amber-xl:#cae8ff;
  --muted:   #484f58;
  --rule:    #21262d;
  --green:   #3fb950;
  --yellow:  #d29922;
  --surface: #161b22;
  --overlay: rgba(13,17,23,0.97);
  --grid-color: #161b22;
  --belt-top:   #1c2128;
  --belt-bot:   #161b22;
  --belt-inner: #21262d;
  --chrome-bg: #010409;
  --chrome-border: #30363d;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body ────────────────────────────────────────────────── */
body {
  font-family: 'Georgia', serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition:
    background var(--skin-transition),
    color var(--skin-transition);
}

body.skin-tecnico {
  font-family: 'Courier New', 'Consolas', monospace;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1.5px solid var(--chrome-border);
  background: var(--chrome-bg);
  gap: 16px;
  flex-wrap: wrap;
  transition: background var(--skin-transition), border-color var(--skin-transition);
}

.header-left h1 {
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: .06em;
  color: var(--ink2);
}
.header-left h1 strong { color: var(--amber); }

.badge-poc {
  font-size: 0.62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--rule);
  padding: 2px 8px;
  border-radius: 2px;
}

/* skin-specific header tweaks */
body.skin-gamer .header-left h1 { font-family: 'Courier New', monospace; }
body.skin-gamer .header-left h1 strong {
  text-shadow: 0 0 8px var(--amber);
}

/* ── Skin switcher ───────────────────────────────────────── */
.skin-switcher {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.skin-btn {
  font-size: 0.7rem;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: transparent;
  color: var(--ink2);
  cursor: pointer;
  letter-spacing: .04em;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.skin-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}
.skin-btn.active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--paper);
}
body.skin-gamer .skin-btn.active {
  box-shadow: 0 0 8px var(--amber);
}

/* ── Workspace ───────────────────────────────────────────── */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 180px;
  border-right: 1.5px solid var(--chrome-border);
  padding: 20px 16px;
  overflow-y: auto;
  background: var(--surface);
  transition: background var(--skin-transition), border-color var(--skin-transition);
}
.sidebar h2 {
  font-size: 0.65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  font-family: inherit;
}
body.skin-tecnico .sidebar h2 { font-family: 'Courier New', monospace; }

.cat-item {
  margin-bottom: 16px;
  cursor: pointer;
  padding: 10px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.cat-item:hover, .cat-item.active {
  border-color: var(--amber);
  background: var(--paper);
}
.cat-label {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--ink);
  margin-bottom: 4px;
}
.cat-desc {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}
.auto-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 2px 6px;
  border-radius: 2px;
  font-family: monospace;
}
.auto-manual  { background: #e8e0d0; color: var(--muted); }
.auto-semi    { background: #fde8c0; color: #8a5a00; }
.auto-auto    { background: #d4edda; color: #1a5c2a; }

/* gamer badge overrides */
body.skin-gamer .auto-manual  { background: #1e1e30; color: #a78bfa; }
body.skin-gamer .auto-semi    { background: #1e2a1e; color: #86efac; }
body.skin-gamer .auto-auto    { background: #1a1a3a; color: #c4b5fd; }

/* negocio / tecnico badge overrides */
body.skin-negocio .auto-manual { background: #e5e7eb; color: #374151; }
body.skin-negocio .auto-semi   { background: #fef3c7; color: #92400e; }
body.skin-negocio .auto-auto   { background: #d1fae5; color: #065f46; }
body.skin-tecnico .auto-manual { background: #21262d; color: #8b949e; }
body.skin-tecnico .auto-semi   { background: #1c2813; color: #56d364; }
body.skin-tecnico .auto-auto   { background: #0c1f39; color: #79c0ff; }

/* ── Sidebar: XP bar (gamer) ─────────────────────────────── */
.xp-bar-wrap { display: none; }
body.skin-gamer .xp-bar-wrap { display: block; margin-top: 6px; }
.xp-bar-label {
  font-size: 0.6rem;
  font-family: monospace;
  color: var(--amber-l);
  margin-bottom: 3px;
}
.xp-bar-track {
  height: 5px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--amber);
  box-shadow: 0 0 4px var(--amber);
  transition: width 0.6s ease;
}

/* ── Sidebar: completitud (negocio) ─────────────────────── */
.completitud-wrap { display: none; }
body.skin-negocio .completitud-wrap { display: block; margin-top: 6px; }
.completitud-label {
  font-size: 0.62rem;
  color: var(--muted);
  font-family: sans-serif;
}
.completitud-pct {
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--amber);
  font-family: sans-serif;
}

/* ── Sidebar: módulo Python (técnico) ───────────────────── */
.modulo-wrap { display: none; }
body.skin-tecnico .modulo-wrap {
  display: block;
  margin-top: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.62rem;
  color: var(--amber-l);
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
}

/* ── Canvas ──────────────────────────────────────────────── */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  background-color: var(--paper);
  transition: background-color var(--skin-transition);
}

#factory-svg {
  width: 100%;
  height: 100%;
  cursor: default;
}

/* ── Gamer: glow on station hover ───────────────────────── */
body.skin-gamer .station rect {
  transition: filter 0.2s;
}
body.skin-gamer .station:hover rect {
  filter: drop-shadow(0 0 6px var(--amber));
}

/* ── Detail panel ────────────────────────────────────────── */
.detail-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 310px;
  background: var(--overlay);
  border: 1.5px solid var(--amber);
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  display: none;
  z-index: 10;
  transition: background var(--skin-transition), border-color var(--skin-transition);
}
.detail-panel.open { display: block; }

body.skin-gamer .detail-panel {
  box-shadow: 0 0 20px rgba(124,58,237,.35);
}

.panel-close {
  float: right;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  margin-top: -4px;
}
.panel-title {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--ink);
  margin-bottom: 4px;
}
.panel-subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--amber);
  margin-bottom: 12px;
}
.panel-desc {
  font-size: 0.78rem;
  color: var(--ink2);
  line-height: 1.55;
  margin-bottom: 14px;
}
.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  margin-bottom: 14px;
}
.param-table th {
  text-align: left;
  color: var(--muted);
  font-weight: normal;
  font-style: italic;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}
.param-table td {
  padding: 4px 0;
  color: var(--ink2);
  vertical-align: top;
}
.param-table td:first-child {
  color: var(--muted);
  width: 40%;
  padding-right: 8px;
}

/* ── Auto bar (classic / negocio / técnico) ─────────────── */
.auto-bar-wrap { margin-top: 4px; }
.auto-bar-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 4px;
}
.auto-bar-track {
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.auto-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--amber);
  transition: width .5s ease;
}
.auto-level-text {
  font-size: 0.65rem;
  color: var(--amber);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── XP panel (gamer) ───────────────────────────────────── */
.xp-panel-wrap { display: none; }
body.skin-gamer .xp-panel-wrap { display: block; margin-top: 8px; }
body.skin-gamer .auto-bar-wrap { display: none; }

.xp-panel-level {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--amber-xl);
  font-weight: bold;
  margin-bottom: 4px;
}
.xp-panel-bar-track {
  height: 8px;
  background: var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.xp-panel-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--amber), var(--amber-l));
  box-shadow: 0 0 6px var(--amber);
  transition: width .6s ease;
}
.xp-panel-score {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--amber-l);
  margin-top: 3px;
}

/* ── Módulos Python panel (técnico) ─────────────────────── */
.modules-panel-wrap { display: none; }
body.skin-tecnico .modules-panel-wrap {
  display: block;
  margin-top: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
}
body.skin-tecnico .auto-bar-wrap { display: none; }

.modules-panel-label {
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.module-chip {
  display: inline-block;
  margin: 2px 3px 2px 0;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: 2px;
  color: var(--amber-l);
  font-size: 0.68rem;
}

/* ── Score planta (gamer, footer) ───────────────────────── */
.score-planta-wrap { display: none; }
body.skin-gamer .score-planta-wrap { display: flex; align-items: center; gap: 8px; }

/* ── Legend / footer ─────────────────────────────────────── */
.legend {
  padding: 10px 28px;
  border-top: 1px solid var(--chrome-border);
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.68rem;
  color: var(--muted);
  background: var(--surface);
  flex-wrap: wrap;
  transition: background var(--skin-transition), border-color var(--skin-transition);
}
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* gamer legend glow dots */
body.skin-gamer .legend-dot {
  box-shadow: 0 0 4px currentColor;
}

.score-planta-wrap {
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--amber-xl);
}
.score-value {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--amber);
  text-shadow: 0 0 6px var(--amber);
}

/* ── Negocio: hide decorative elements ──────────────────── */
body.skin-negocio .legend-dot[data-muted] { display: none; }

/* ══════════════════════════════════════════════════════════
   MAIN CONTENT (contenedor dinámico)
   ══════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  overflow: auto;
  background:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  background-color: var(--paper);
  transition: background-color var(--skin-transition);
  position: relative;
}

/* canvas-area sigue existiendo para drill-in (SVG) */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

#factory-svg {
  width: 100%;
  height: 100%;
  cursor: default;
}

/* ── Loading / Error ──────────────────────────────────────── */
.loading-msg, .error-msg {
  padding: 48px 32px;
  color: var(--muted);
  font-size: 0.9rem;
  font-family: monospace;
}
.error-msg strong { color: var(--amber); }
.error-msg code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* ══════════════════════════════════════════════════════════
   OVERVIEW STYLES
   ══════════════════════════════════════════════════════════ */
.overview-canvas {
  padding: 24px 28px;
  min-height: 100%;
}

.overview-header {
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.overview-meta {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: monospace;
  letter-spacing: .04em;
}

/* ── Factory grid ────────────────────────────────────────── */
.factory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Factory card ────────────────────────────────────────── */
.factory-card {
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: 5px;
  padding: 16px 14px 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
  position: relative;
}
.factory-card:hover {
  border-color: var(--amber);
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  background: var(--surface);
}
body.skin-gamer .factory-card:hover {
  box-shadow: 0 0 14px var(--amber);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.card-icon { font-size: 1.2rem; }
.card-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--ink);
  font-family: Georgia, serif;
}
.card-level {
  font-size: 0.7rem;
  font-family: monospace;
  font-weight: bold;
}

.card-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.card-bar-track {
  flex: 1;
  height: 5px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.card-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .6s ease;
}
body.skin-gamer .card-bar-fill {
  box-shadow: 0 0 4px currentColor;
}
.card-pct {
  font-size: 0.72rem;
  font-family: monospace;
  font-weight: bold;
  min-width: 32px;
  text-align: right;
}

.card-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.stage-pill {
  font-size: 0.6rem;
  font-family: monospace;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 2px 5px;
  color: var(--ink2);
  white-space: nowrap;
}
.stage-more {
  color: var(--amber);
  border-color: var(--amber);
}

.card-desc {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-estado {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-family: monospace;
  padding: 2px 6px;
  border-radius: 2px;
}
.estado-activo { background: #d4edda; color: #1a5c2a; }
.estado-en-desarrollo { background: #fde8c0; color: #8a5a00; }
body.skin-gamer .estado-activo { background: #1a3a1a; color: #86efac; }
body.skin-gamer .estado-en-desarrollo { background: #2a2a1a; color: #fbbf24; }

.card-drill-btn {
  font-size: 0.65rem;
  padding: 3px 10px;
  border: 1px solid var(--amber);
  border-radius: 2px;
  background: transparent;
  color: var(--amber);
  cursor: pointer;
  font-family: monospace;
  transition: background .15s, color .15s;
}
.card-drill-btn:hover {
  background: var(--amber);
  color: var(--paper);
}

/* Extras por skin (dentro de cards) */
.card-xp { display: none; }
body.skin-gamer .card-xp { display: block; margin-top: 8px; }

.card-completitud { display: none; }
body.skin-negocio .card-completitud { display: block; margin-top: 6px; }

/* ── Overview sidebar ────────────────────────────────────── */
.overview-score-box {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.overview-score-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 2px;
}
.overview-score-value {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--amber);
  font-family: Georgia, serif;
}

.sidebar-section-title {
  font-size: 0.6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.infra-item .cat-label { font-size: 0.75rem; }

/* ── Back button (drill-in) ──────────────────────────────── */
.sidebar-back { margin-bottom: 12px; }
.back-btn {
  font-size: 0.7rem;
  padding: 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: transparent;
  color: var(--ink2);
  cursor: pointer;
  font-family: monospace;
  letter-spacing: .03em;
  transition: border-color .15s, color .15s;
  width: 100%;
}
.back-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}

/* ── Mina placeholder note ───────────────────────────────── */
.mina-placeholder-note {
  background: var(--surface);
  border: 1px dashed var(--muted);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}
.mina-placeholder-note span { font-size: 1.1rem; flex-shrink: 0; }
.mina-placeholder-note strong { color: var(--ink2); }

/* ── Overview overlay panel (infra click) ────────────────── */
.overview-overlay-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 310px;
  background: var(--overlay);
  border: 1.5px solid var(--amber);
  border-radius: 4px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  z-index: 20;
  display: none;
}
.overview-overlay-panel.open { display: block; }

/* ── Gamer: glow on station hover ───────────────────────── */
body.skin-gamer .station rect {
  transition: filter 0.2s;
}
body.skin-gamer .station:hover rect {
  filter: drop-shadow(0 0 6px var(--amber));
}
