/* =========================
   FONT
========================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

/* =========================
   DESIGN SYSTEM
========================= */

/* Spacing */
:root {
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 20px;
}

/* Radius */
:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* =========================
   THEME VARIABLES (LIGHT)
========================= */
:root {

  /* BASE */
  --bg-app: #f5f6f8;
  --bg-graph: #ffffff;
  --bg-panel: #e9ecef;
  --bg-panel-soft: #f1f1f3;

  --border-soft: #e5e7eb;
  --border-strong: #d1d5db;

  /* TEXT */
  --text-primary: #18181b;
  --text-secondary: #6b7280;

  /* ACCENT */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;

  /* NODE */
  --node-bg: #0059ff;
  --node-border: #d1d5db;

  /* EDGE */
  --edge-color: #a1a1aa;
  --edge-active: var(--accent);

  /* UI */
  --ui-bg: rgba(0,0,0,0.65);
  --ui-bg-hover: rgba(0,0,0,0.5);

  /* TIME */
  --time-track: rgba(0,0,0,0.2);
  --time-thumb: #444;

  --primary: #18181b;
}

/* =========================
   DARK MODE
========================= */
[data-theme="dark"] {

  --bg-app: #18181b;
  --bg-graph: #1f1f23;
  --bg-panel: #27272a;
  --bg-panel-soft: #323236;

  --border-soft: #3f3f46;

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;

  --node-bg: #3f3f46;
  --node-border: #52525b;

  --edge-color: #71717a;

  --time-track: rgba(255,255,255,0.2);
  --time-thumb: #aaa;
}

/* =========================
   RESET
========================= */
* {
  font-family: 'Poppins', sans-serif;
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-primary);
}

#logo-btn img {
  width: 60%;
  height: 60%;
  object-fit: contain;
}

/* =========================
   GRAPH
========================= */
#graph-wrapper,
#graph {
  position: absolute;
  inset: 0;
}

#graph {
  background: var(--bg-graph);
}

/* =========================
   TOP UI
========================= */
#top-ui {
  position: absolute;
  top: var(--space-lg);
  left: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  z-index: 10;
}

/* =========================
   ROUND BUTTON
========================= */
.round-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--ui-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.round-btn:hover {
  transform: scale(1.05);
  background: var(--ui-bg-hover);
}

.round-btn:active {
  transform: scale(0.95);
}

/* =========================
   BUTTONS
========================= */
#settings-btn {
  position: absolute;
  bottom: var(--space-lg);
  left: var(--space-lg);
  z-index: 10;
}

#settings-btn svg {
  width: 40px;
  height: 40px;
}

#add-node-btn {
  position: absolute;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 10;
}

#add-node-btn .plus {
  font-size: 56px;
  color: white;
}

/* =========================
   MODEL NAME
========================= */

#model-name {
  border: none;
  background: transparent;
  height: 42px;
  font-size: 32px;
  font-weight: 400;
  color: var(--text-primary);
  margin-top: -8px;
  padding: 0;
  line-height: 0;
}

#model-name::placeholder {
  color: var(--text-secondary);
}

/* =========================
   TIME UI
========================= */
#time-ui {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: row-reverse;
  gap: var(--space-sm);
  z-index: 10;
}

#time-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#time-circle {
  position: relative;
  transform: translateZ(0); 
}

#time-value {
  color: white;
  font-size: 36px;
  font-weight: 700;
}

#time-badge {
  position: absolute;
  will-change: transform;
  width: 30px;
  height: 30px;
  top: -5px;
  right: -5px;
  background: #272727;
  color: white;
  font-size: 12px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#time-label {
  font-size: 20px;
  color: var(--text-secondary);
}

/* =========================
   SLIDER
========================= */
#time-slider {
  width: 250px;
  margin: var(--space-sm) 0;
  background: transparent;
}

#time-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--time-track);
  border-radius: 4px;
}

#time-slider::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--time-thumb);
  margin-top: -5px;
  cursor: pointer;
}

/* =========================
   NODE LABELS
========================= */
#node-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.node-label {
  position: absolute;
  transform: translate(-50%, -55%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  color: inherit;
}

.node-label .title {
  font-size: 11px;
}

.node-label .value {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.node-label .unit {
  font-size: 10px;
  opacity: 0.6;
}

/* =========================
   PANEL
========================= */
#bottom-panel {
  position: absolute;
  left: 50%;
  bottom: var(--space-lg);
  transform: translateX(-50%);
  width: 98%;
  max-width: 100%;
  height: 0;
  overflow: hidden;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  transition: height 0.25s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

#bottom-panel.open {
  height: 20%;
}

/* HEADER */
#panel-header {
  display: flex;
  align-items: center;
  padding: var(--space-md);
}

/* TITLE */
#panel-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  font-weight: 500;
  color: var(--text-secondary);
  pointer-events: none;
}

/* CLOSE */
#panel-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  background: var(--text-secondary);
  color: white;
}

/* CONTENT */
#panel-content {
  flex: 1;
  overflow-y: auto;
}

#panel-inner {
  padding: var(--space-md);
  display: block;
  text-align: left;
  line-height: 1.1;
}

/* =========================
   CHIP
========================= */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  margin: 2px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #fff;
  background: #888;
  cursor: pointer;
}

/* =========================
   PANEL GRID (FLEX SYSTEM)
========================= */
.panel-grid {
  display: flex;
  gap: var(--space-md);
  min-width: 0;
}

.col-4 { flex: 1; }
.col-8 { flex: 2; }

/* TODO: legacy grid system (no usado actualmente)
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }
*/

.panel-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.panel-input {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.panel-btn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
}

#model-meta {
  font-size: 10px;
  color: var(--text-secondary);
}

.panel-block {
  background: var(--bg-panel-soft);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
}

.row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 10px;
  text-transform: uppercase;
}

.value {
  font-size: 14px;
  font-weight: 500;
  margin-left: 10px;
}

.hint {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.5;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  margin-left: 10px;
}

.panel-left {
  border-right: 1px solid var(--border-soft);
  padding-right: var(--space-md);
}

/* =========================
   DANGER BUTTON
========================= */
.panel-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #ef4444;
  color: white;
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 80px;
  width: fit-content;
  transition: background 0.2s;
  margin-top: var(--space-sm);
}



/* =========================
   LOADER
========================= */

:root{ --t:1s; }

#loader {
  position: fixed;
  inset: 0;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 9999;
}

#loader.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#loader-inner img {
  width: 60px; /* podés ajustar */
  opacity: 0.8;
}

/* estado base */
.ray{
  opacity:0;
}

svg{
  width:4%;
}

.st0 {
  fill: white;
  stroke: white;
}

/* secuencia circular (11 rayos reales) */
.r1  { animation: ray var(--t) linear infinite; animation-delay:0s; }
.r2  { animation: ray var(--t) linear infinite; animation-delay:0.1s; }
.r3  { animation: ray var(--t) linear infinite; animation-delay:0.2s; }
.r4  { animation: ray var(--t) linear infinite; animation-delay:0.3s; }
.r5  { animation: ray var(--t) linear infinite; animation-delay:0.4s; }
.r6  { animation: ray var(--t) linear infinite; animation-delay:0.5s; }
.r7  { animation: ray var(--t) linear infinite; animation-delay:0.6s; }
.r8  { animation: ray var(--t) linear infinite; animation-delay:0.7s; }
.r9  { animation: ray var(--t) linear infinite; animation-delay:0.8s; }
.r10 { animation: ray var(--t) linear infinite; animation-delay:0.9s; }
.r11 { animation: ray var(--t) linear infinite; animation-delay:1s; }

@keyframes ray{
  0%   { opacity:0; }
  50%  { opacity:1; }   /* 👈 antes terminaba muy tarde */
  80%  { opacity:0; }   /* 👈 apagado global sincronizado */
  100% { opacity:0; }
}

/* sonrisa ORIGINAL */
.smile{
  opacity:0;
  animation: smile var(--t) linear infinite;
}

@keyframes smile{
  0%   { opacity:0; }
  60%  { opacity:1; }   /* espera fin del giro */
  80%  { opacity:1; }   /* aparece */ /* pausa */
  100% { opacity:0; }   /* reset */
}