/**
 * eclipse-engine - Hoja de estilo del frontend.
 *
 * @author    Ecom Experts <ecomyseo@gmail.com>
 * @copyright 2026 Ecom Experts
 * @license   AFL-3.0
 */

:root {
  --bg: #0a0d14;
  --bg-2: #111621;
  --bg-3: #171d2b;
  --bg-4: #1e2637;
  --line: #26304a;
  --line-2: #33405f;
  --txt: #e6ecf7;
  --txt-2: #9aa8c4;
  --txt-3: #64728f;
  --accent: #f5a623;
  --accent-2: #ffd06b;
  --total: #e0403a;
  --annular: #f0a500;
  --hybrid: #14b8c4;
  --partial: #7b8cad;
  --ok: #35c67a;
  --warn: #f0a500;
  --bad: #e0403a;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  --r: 8px;
  --panel-w: 344px;
  --pov-w: 400px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--txt);
  font: 13px/1.5 "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* ------------------------------------------------------------ estructura */

#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr auto;
  grid-template-rows: 46px 1fr auto;
  grid-template-areas:
    "head head head"
    "side main pov"
    "side time pov";
  height: 100%;
}
#app.pov-hidden { --pov-w: 0px; }

header    { grid-area: head; }
#side     { grid-area: side; }
#mapwrap  { grid-area: main; }
#timeline { grid-area: time; }
#pov      { grid-area: pov; }

/* ---------------------------------------------------------------- header */

header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand svg { display: block; }
.brand small { color: var(--txt-3); font-weight: 400; font-size: 11px; }

.hsearch { position: relative; flex: 0 1 300px; }
.hsearch input {
  width: 100%; padding: 6px 10px 6px 28px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
}
.hsearch::before {
  content: "⌕"; position: absolute; left: 9px; top: 4px;
  color: var(--txt-3); font-size: 15px;
}
.hsearch input:focus { outline: none; border-color: var(--accent); }

.spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-4); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--txt-2); white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.warn { border-color: #6b4d12; color: var(--warn); }
.pill.warn .dot { background: var(--warn); }

.btn {
  padding: 5px 11px; border-radius: 6px; cursor: pointer;
  background: var(--bg-4); border: 1px solid var(--line); color: var(--txt);
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--line); border-color: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1204; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.on { background: var(--accent); border-color: var(--accent); color: #1a1204; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.sm { padding: 3px 8px; font-size: 11.5px; }
.btn.icon { padding: 5px 8px; }

/* ------------------------------------------------------- panel izquierdo */

#side {
  background: var(--bg-2); border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
#side::-webkit-scrollbar, #pov::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 9px; height: 9px; }
#side::-webkit-scrollbar-thumb, #pov::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 5px;
}
#side::-webkit-scrollbar-track, #pov::-webkit-scrollbar-track { background: transparent; }

.sec { border-bottom: 1px solid var(--line); }
.sec > h3 {
  margin: 0; padding: 9px 12px;
  font-size: 11px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--txt-3);
  display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none;
}
.sec > h3::before { content: "▾"; font-size: 9px; transition: transform .15s; color: var(--txt-3); }
.sec.collapsed > h3::before { transform: rotate(-90deg); }
.sec.collapsed > .body { display: none; }
.sec > h3 .badge {
  margin-left: auto; padding: 1px 7px; border-radius: 999px;
  background: var(--bg-4); color: var(--txt-2); font-size: 10px; letter-spacing: 0;
}
.body { padding: 0 12px 12px; }

/* -------------------------------------------------------- ficha eclipse */

.eclipse-card { padding: 10px 12px 12px; }
.eclipse-card .type {
  display: inline-block; padding: 2px 9px; border-radius: 4px;
  font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
}
.type.total   { background: rgba(224, 64, 58, .18);  color: #ff8b86; }
.type.annular { background: rgba(240, 165, 0, .18);  color: #ffc95e; }
.type.hybrid  { background: rgba(20, 184, 196, .18); color: #6de3ec; }
.type.partial { background: rgba(123, 140, 173, .18); color: #b3bfd6; }
.eclipse-card .date { font-size: 19px; font-weight: 620; margin: 6px 0 2px; }
.eclipse-card .sub { color: var(--txt-2); font-size: 12px; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin-top: 11px; font-size: 12.5px; }
.kv dt { color: var(--txt-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

.note {
  margin-top: 11px; padding: 8px 10px; border-radius: 6px;
  background: rgba(240, 165, 0, .08); border: 1px solid rgba(240, 165, 0, .25);
  color: #f3cd8a; font-size: 11.5px; line-height: 1.45;
}
.note.good { background: rgba(53, 198, 122, .07); border-color: rgba(53, 198, 122, .22); color: #8fe3b6; }
.note.bad  { background: rgba(224, 64, 58, .08);  border-color: rgba(224, 64, 58, .28); color: #ffa19c; }
.note b { color: #fff; }

/* --------------------------------------------------------------- capas */

.layer {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 0; cursor: pointer; user-select: none;
}
.layer input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.layer .swatch { width: 15px; height: 11px; border-radius: 2px; flex: none; }
.layer span { flex: 1; font-size: 12.5px; }

.slider-row { display: flex; align-items: center; gap: 9px; margin: 9px 0 3px; }
.slider-row label { color: var(--txt-2); font-size: 12px; min-width: 62px; }
.slider-row output { font-family: var(--mono); font-size: 11.5px; color: var(--txt-2); min-width: 38px; text-align: right; }
input[type=range] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 3px; border-radius: 2px; background: var(--line-2); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg-2);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 2px solid var(--bg-2);
}

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button {
  flex: 1; padding: 5px 4px; background: transparent; border: 0; cursor: pointer;
  color: var(--txt-2); font-size: 11.5px;
}
.seg button.on { background: var(--bg-4); color: var(--txt); font-weight: 600; }
.seg button:hover:not(.on) { background: var(--bg-3); }

/* -------------------------------------------------------------- listas */

.field { margin-bottom: 9px; }
.field > label { display: block; margin-bottom: 4px; color: var(--txt-2); font-size: 11.5px; }
.field input, .field select {
  width: 100%; padding: 5px 8px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

.list { max-height: 290px; overflow-y: auto; margin: 0 -12px; }
.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; cursor: pointer; border-left: 2px solid transparent;
}
.list-item:hover { background: var(--bg-3); }
.list-item.on { background: var(--bg-4); border-left-color: var(--accent); }
.list-item.hl { background: rgba(245, 166, 35, .10); }
.list-item.hl .t { color: var(--accent-2); font-weight: 600; }
.list-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.list-item .t { flex: 1; font-size: 12px; }
.list-item .m { font-family: var(--mono); font-size: 11px; color: var(--txt-2); }

.dot.total { background: var(--total); }
.dot.annular { background: var(--annular); }
.dot.hybrid { background: var(--hybrid); }
.dot.partial { background: var(--partial); }

.empty { padding: 16px 4px; text-align: center; color: var(--txt-3); font-size: 12px; }

.bar { height: 3px; background: var(--bg-4); border-radius: 2px; overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* ----------------------------------------------------------------- mapa */

#mapwrap { position: relative; background: #05070c; overflow: hidden; }
#map, #canvasmap { position: absolute; inset: 0; }
#canvasmap { display: none; }
#app.canvasmode #map { display: none; }
#app.canvasmode #canvasmap { display: block; }

#hud {
  position: absolute; top: 10px; left: 10px; z-index: 8;
  background: rgba(10, 13, 20, .86); backdrop-filter: blur(9px);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 9px 12px; box-shadow: var(--shadow);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.7;
  pointer-events: none; min-width: 208px;
}
#hud .clock { font-size: 19px; font-weight: 600; letter-spacing: .5px; color: #fff; font-family: var(--mono); }
#hud .clock small { font-size: 11px; color: var(--txt-3); font-weight: 400; letter-spacing: 0; }
#hud .g { color: var(--txt-3); }
#hud .v { color: var(--txt); }

#cursorbox {
  position: absolute; bottom: 10px; left: 10px; z-index: 8;
  background: rgba(10, 13, 20, .86); backdrop-filter: blur(9px);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 7px 11px; font-family: var(--mono); font-size: 11px;
  color: var(--txt-2); pointer-events: none; display: none;
}

#maptools {
  position: absolute; top: 10px; right: 10px; z-index: 8;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
#maptools .seg { background: rgba(10, 13, 20, .86); backdrop-filter: blur(9px); box-shadow: var(--shadow); }

#loading {
  position: absolute; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  background: rgba(5, 7, 12, .72); backdrop-filter: blur(2px);
}
#loading.on { display: flex; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading .msg { color: var(--txt-2); font-size: 12.5px; }

.nokey {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.nokey .card {
  pointer-events: auto; max-width: 400px; text-align: center;
  background: rgba(17, 22, 33, .95); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow);
}

/* ------------------------------------------------------- linea de tiempo */

#timeline {
  background: var(--bg-2); border-top: 1px solid var(--line);
  padding: 9px 14px 11px; z-index: 12;
}
.tl-controls { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; flex-wrap: wrap; }
.tl-controls .grow { flex: 1; }
.tl-time {
  font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--txt); white-space: nowrap;
}
.tl-time span { color: var(--txt-3); }

.tl-track { position: relative; height: 26px; }
.tl-track input[type=range] { position: absolute; top: 11px; left: 0; right: 0; width: 100%; }
.tl-marks { position: absolute; top: 0; left: 0; right: 0; height: 26px; pointer-events: none; }
.tl-marks i {
  position: absolute; top: 0; width: 1px; height: 8px; background: var(--line-2);
}
.tl-marks i.big { background: var(--accent); height: 11px; }
.tl-marks b {
  position: absolute; top: 12px; transform: translateX(-50%);
  font-size: 9.5px; color: var(--txt-3); font-weight: 500; letter-spacing: .04em;
}
.tl-umbra {
  position: absolute; top: 9px; height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(224,64,58,.15), rgba(224,64,58,.55), rgba(224,64,58,.15));
  pointer-events: none;
}

/* --------------------------------------------------------- panel POV */

#pov {
  width: var(--pov-w); background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .18s;
}
#app.pov-hidden #pov { width: 0; border-left: 0; }

.pov-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); flex: none;
}
.pov-head .ttl { font-weight: 620; font-size: 12.5px; flex: 1; white-space: nowrap; overflow: hidden; }

/* Control de intensidad del oscurecimiento */
.pov-dark {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.pov-dark label { color: var(--txt-2); font-size: 11.5px; }
.pov-dark output { font-family: var(--mono); font-size: 11px; color: var(--txt-2); min-width: 34px; text-align: right; }

/* Panel ancho */
#app.pov-wide { --pov-w: min(62vw, 900px); }
#app.pov-wide .stage { aspect-ratio: 16 / 9; }

/* Pantalla completa: la escena ocupa todo y las capas la siguen */
.stage:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; background: #000; }
.stage:fullscreen > canvas.sunsprite { width: 240px; height: 240px; }
#app.pov-wide .stage > canvas.sunsprite { width: 130px; height: 130px; }
.stage:fullscreen .fs-hud {
  display: block; position: absolute; left: 18px; bottom: 18px; z-index: 20;
  background: rgba(10, 13, 20, .82); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  font-family: var(--mono); font-size: 13px; line-height: 1.7; color: var(--txt);
  pointer-events: none;
}
.fs-hud { display: none; }
.stage:fullscreen .fs-exit {
  display: block; position: absolute; right: 18px; top: 18px; z-index: 21;
}
.fs-exit { display: none; }

.pov-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.pov-tabs button {
  flex: 1; padding: 7px 3px; background: transparent; border: 0; cursor: pointer;
  color: var(--txt-3); font-size: 11.5px; border-bottom: 2px solid transparent;
}
.pov-tabs button.on { color: var(--txt); border-bottom-color: var(--accent); font-weight: 600; }
.pov-tabs button:hover:not(.on) { color: var(--txt-2); }

.pov-body { flex: 1; overflow-y: auto; }
.pov-pane { display: none; }
.pov-pane.on { display: block; }

.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #05070c; overflow: hidden;
  isolation: isolate; /* contexto de apilamiento propio */
}
.stage > canvas, .stage > div, .stage > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.stage img { object-fit: cover; }

/*
 * El panorama de Google monta dentro de #sv-pano una jerarquía con z-index
 * propios. Si el contenedor no crea su propio contexto de apilamiento, esos
 * hijos pintan POR ENCIMA de las capas del eclipse y el Street View se ve a
 * pleno sol aunque el motor diga que hay totalidad. Con z-index en el
 * contenedor, todo lo de Google queda confinado por debajo.
 */
#sv-pano, #d3-host { z-index: 1; }

/*
 * Capas del eclipse: siempre por encima del mundo real.
 * El oscurecimiento se compone en MULTIPLY: superponer un color claro con
 * opacidad lava la imagen, mientras que multiplicar apaga la luz de verdad.
 */
.darklayer {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  mix-blend-mode: multiply;
  transition: background .25s linear;
}
/* El resplandor de horizonte SUMA luz: se compone en screen. */
.horizonglow {
  position: absolute; left: 0; right: 0; bottom: 0; top: auto; height: 38%;
  width: auto; z-index: 6; mix-blend-mode: screen;
  pointer-events: none; opacity: 0; transition: opacity .25s;
}
.stage > canvas.sunsprite {
  position: absolute; inset: auto; z-index: 7;
  width: 82px; height: 82px;
  pointer-events: none; transform: translate(-50%, -50%);
}
#sv-msg, #d3-msg { z-index: 8; }

.pov-info { padding: 10px 12px; }
.pov-info .kv { margin-top: 0; }

.coordbar { display: flex; gap: 6px; padding: 9px 10px; border-bottom: 1px solid var(--line); flex: none; }
.coordbar input {
  flex: 1; min-width: 0; padding: 5px 8px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px;
}

.phasebar { display: flex; gap: 2px; padding: 8px 12px 0; }
.phasebar > i {
  flex: 1; height: 4px; border-radius: 2px; background: var(--bg-4);
}
.phasebar > i.on { background: var(--accent); }

.ai-controls { padding: 10px 12px; display: grid; gap: 8px; }
.ai-prompt {
  width: 100%; min-height: 62px; resize: vertical; padding: 7px 9px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  font-size: 11.5px; line-height: 1.5; font-family: inherit;
}
.ai-status { font-size: 11.5px; color: var(--txt-2); min-height: 17px; }
.ai-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-thumbs img { width: 54px; height: 40px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 1px solid var(--line); }
.ai-thumbs img.on { border-color: var(--accent); }

/* ------------------------------------------------------------- dialogos */

dialog {
  background: var(--bg-2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 0; box-shadow: var(--shadow); max-width: 560px; width: 92vw;
}
dialog::backdrop { background: rgba(3, 5, 9, .72); backdrop-filter: blur(3px); }
dialog h2 { margin: 0; padding: 14px 18px; font-size: 15px; border-bottom: 1px solid var(--line); }
dialog .dbody { padding: 16px 18px; max-height: 66vh; overflow-y: auto; }
dialog .dfoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
dialog p { margin: 0 0 10px; color: var(--txt-2); font-size: 12.5px; line-height: 1.6; }
dialog code { font-family: var(--mono); font-size: 11.5px; background: var(--bg); padding: 1px 5px; border-radius: 3px; color: var(--accent-2); }
dialog table { width: 100%; border-collapse: collapse; font-size: 12px; }
dialog td { padding: 3px 0; border-bottom: 1px solid var(--line); }
dialog td:last-child { text-align: right; font-family: var(--mono); color: var(--txt-2); }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--bg-4); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 9px 16px; box-shadow: var(--shadow); z-index: 999; font-size: 12.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.bad { border-color: var(--bad); color: #ffa19c; }

.mono { font-family: var(--mono); }
.dim { color: var(--txt-3); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 10px; }
.hidden { display: none !important; }

@media (max-width: 1280px) { :root { --panel-w: 300px; --pov-w: 340px; } }
@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "head" "main" "time" "side"; }
  #pov { position: fixed; right: 0; top: 46px; bottom: 0; z-index: 40; box-shadow: var(--shadow); }
}
