/* MAVI Ops Floor v3 — paleta navy de MAVI + técnica pixel del prototipo v2 */
:root{
  --bg: #0A0F1C;
  --panel: #111a2c;
  --panel-2: #0d1524;
  --line: #22324d;
  --outline: #05080f;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --mavi: #1CA3E8;
  --mavi-light: #4FC3F7;
  --accent: var(--mavi);

  --st-activo: #5fd38d;
  --st-pausado: #8b9bb4;
  --st-error: #ff5d6c;
  --st-construyendo: #f2b84b;

  --font: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --pixel: 'Press Start 2P', var(--mono);
  color-scheme: dark;
}
[data-theme="mavi"]  { --accent: #1CA3E8; --floor-a: #0f2240; --floor-b: #0c1c36; --wall: #0b1426; }
[data-theme="linda"] { --accent: #e57fb0; --floor-a: #2a1830; --floor-b: #231428; --wall: #170e1d; }
[data-theme="betsy"] { --accent: #f2b84b; --floor-a: #2b2214; --floor-b: #241c10; --wall: #18130b; }

*{ box-sizing: border-box; }
html, body{ margin: 0; }
body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  min-height: 100vh;
}
[hidden]{ display: none !important; }
.view{ max-width: 1120px; margin: 0 auto; padding: 20px 16px 40px; }
.muted{ color: var(--muted); margin: 0; }

.console{
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 0 var(--outline);
}

/* ---------- botones / inputs ---------- */
.btn{
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  background: var(--panel-2); color: var(--text);
  border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 12px; cursor: pointer;
  box-shadow: 0 3px 0 var(--outline);
  transition: transform .06s, box-shadow .06s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover{ border-color: var(--accent); }
.btn:active{ transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.btn-primary{ background: var(--accent); color: #06101f; border-color: var(--outline); font-weight: 600; }
.btn-primary:hover{ filter: brightness(1.1); border-color: var(--outline); }
.btn-ghost{ background: transparent; box-shadow: none; }
.btn-icon{ padding: 8px 10px; position: relative; }
.btn-small{ padding: 4px 8px; font-size: 12px; }
.link{ background: none; border: 0; color: var(--mavi-light); cursor: pointer; font-family: var(--mono); font-size: 12px; }

label{ display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-family: var(--mono); }
input, textarea, select{
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--bg); border: 2px solid var(--line); border-radius: 6px; padding: 9px 10px;
}
input:focus, textarea:focus, select:focus{ outline: none; border-color: var(--accent); }
input[type=color]{ padding: 2px; height: 38px; width: 80px; }
.form-error{ color: var(--st-error); font-size: 13px; margin: 0; }

.tag{
  font-family: var(--pixel); font-size: 7px; letter-spacing: .5px; line-height: 1;
  padding: 4px 5px; border-radius: 3px; border: 2px solid var(--outline); white-space: nowrap;
}
.tag-example{ background: #f2b84b; color: #1b1405; }
.tag-snapshot{ background: #2c3f5e; color: #cfe3ff; }
.tag-real{ background: var(--st-activo); color: #06140b; }

/* ---------- login ---------- */
.login-card{ max-width: 460px; margin: 6vh auto 0; padding: 26px 22px; display: flex; flex-direction: column; gap: 16px; }
.login-sign{ display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-sign h1{ font-family: var(--pixel); font-size: 15px; color: var(--mavi-light); margin: 0; text-shadow: 0 0 10px rgba(79,195,247,.55); }
.sign-dot{ width: 8px; height: 8px; background: var(--mavi); box-shadow: 0 0 8px var(--mavi); }
.login-card .muted{ text-align: center; }
.lineup{ display: flex; justify-content: center; gap: 14px; }
.pick{
  background: var(--panel-2); border: 2px solid var(--line); border-radius: 8px; padding: 10px 8px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; width: 96px;
  color: var(--text); font-family: var(--mono); font-size: 12px;
}
.pick[aria-pressed="true"]{ border-color: var(--pick-accent); box-shadow: 0 0 0 2px var(--pick-accent) inset; }
.pick small{ color: var(--muted); font-size: 10px; }
#login-form{ display: flex; flex-direction: column; gap: 12px; }

/* ---------- topbar ---------- */
.topbar{ display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; }
.brand{ display: flex; align-items: baseline; gap: 8px; }
.brand h1{ font-family: var(--pixel); font-size: 13px; margin: 0; color: var(--mavi-light); }
.version{ font-family: var(--mono); font-size: 12px; color: var(--muted); }
.top-actions{ display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.me-chip{ display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; padding: 2px 8px 2px 2px; border: 2px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
.me-chip:hover{ border-color: var(--accent); }
.me-chip canvas{ background: var(--panel-2); border-radius: 4px; }
.bell{ display: inline-block; width: 14px; height: 14px; background:
  linear-gradient(var(--text),var(--text)) 5px 0/4px 2px no-repeat,
  linear-gradient(var(--text),var(--text)) 2px 2px/10px 8px no-repeat,
  linear-gradient(var(--text),var(--text)) 0 10px/14px 2px no-repeat,
  linear-gradient(var(--text),var(--text)) 5px 12px/4px 2px no-repeat; }
.badge{ position: absolute; top: -7px; right: -7px; background: var(--st-error); color: #fff; font-family: var(--mono); font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; border: 2px solid var(--outline); }
.notif-wrap{ position: relative; }
.dropdown{ position: absolute; right: 0; top: calc(100% + 8px); width: min(340px, 86vw); z-index: 20; padding: 10px; }
.dropdown-head{ display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#notif-list{ list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
#notif-list li{ padding: 8px 6px; border-top: 1px dashed var(--line); font-size: 13px; }
#notif-list li.unread{ color: var(--text); }
#notif-list li.unread::before{ content: '● '; color: var(--accent); }
#notif-list li:not(.unread){ color: var(--muted); }
#notif-list time{ display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs{ display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 10px; }
.tab{
  font-family: var(--mono); font-size: 13px; background: var(--panel-2); color: var(--muted);
  border: 2px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer;
}
.tab[aria-selected="true"]{ color: #06101f; background: var(--tab-accent); border-color: var(--outline); font-weight: 600; }
.tab .n{ opacity: .7; margin-left: 4px; }

/* ---------- piso ---------- */
.floor-console{ padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.floor-head{ display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: flex-end; }
.floor-head h2{ font-family: var(--pixel); font-size: 12px; line-height: 1.6; margin: 0 0 4px; color: var(--accent); }
.floor-tools{ display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.legend{ display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.legend span{ display: inline-flex; align-items: center; gap: 5px; }
.dot{ width: 9px; height: 9px; border: 2px solid var(--outline); display: inline-block; }
.dot.activo{ background: var(--st-activo); } .dot.pausado{ background: var(--st-pausado); }
.dot.error{ background: var(--st-error); } .dot.construyendo{ background: var(--st-construyendo); }

.example-banner{ margin: 0; display: flex; gap: 10px; align-items: center; font-size: 13px; color: #f6dca4; background: rgba(242,184,75,.08); border: 2px dashed rgba(242,184,75,.4); border-radius: 6px; padding: 8px 10px; }
.example-banner.snapshot{ color: #cfe3ff; background: rgba(28,163,232,.07); border-color: rgba(79,195,247,.35); }

.room{
  border: 3px solid var(--outline); border-radius: 6px; overflow: hidden; position: relative;
  background-color: var(--floor-a);
  background-image:
    linear-gradient(45deg, var(--floor-b) 25%, transparent 25%, transparent 75%, var(--floor-b) 75%),
    linear-gradient(45deg, var(--floor-b) 25%, transparent 25%, transparent 75%, var(--floor-b) 75%);
  background-size: 32px 32px; background-position: 0 0, 16px 16px;
  padding-bottom: 18px;
}
.wall{
  height: 64px; background: var(--wall); border-bottom: 4px solid var(--outline);
  display: flex; align-items: center; justify-content: space-around; padding: 0 16px;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.25);
}
.window{
  width: 88px; height: 40px; border: 3px solid var(--outline); background:
    radial-gradient(circle at 70% 35%, #f5f1d0 0 3px, transparent 4px),
    linear-gradient(transparent 60%, #0e1830 60% 72%, transparent 72%),
    linear-gradient(90deg, transparent 20%, #121e3a 20% 32%, transparent 32% 55%, #121e3a 55% 64%, transparent 64%) bottom/100% 45% no-repeat,
    linear-gradient(#0a1a3a, #1b3566);
  box-shadow: inset 0 0 0 2px #2a3b5c;
  position: relative;
}
.window::after{ content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; background: var(--outline); }
.neon{
  font-family: var(--pixel); font-size: 13px; color: var(--accent); padding: 8px 12px;
  border: 2px solid var(--accent); border-radius: 4px; text-shadow: 0 0 8px var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 0 8px color-mix(in srgb, var(--accent) 30%, transparent);
  white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis;
}

.desks{ display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 14px; padding: 22px 16px 0; }
.station{
  display: flex; flex-direction: column; align-items: center; position: relative;
  background: none; border: 0; color: inherit; cursor: pointer; padding: 4px 2px; border-radius: 8px;
  font: inherit;
}
.station:hover, .station:focus-visible{ background: rgba(255,255,255,.04); outline: 2px dashed var(--accent); outline-offset: 2px; }
.bubble{
  font-size: 12px; line-height: 1.25; text-align: center; background: #16223a; color: #d6e0ec;
  border: 2px solid var(--outline); border-radius: 5px; padding: 5px 7px; min-height: 40px; width: 100%;
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px; position: relative;
}
.bubble::after{ content: ''; position: absolute; bottom: -7px; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--outline); border-bottom: 0; }
.station.error .bubble{ border-color: var(--st-error); color: #ffd0d4; }

.stage{ position: relative; width: 112px; height: 86px; }
.stage canvas.char{ position: absolute; left: 32px; top: 14px; image-rendering: pixelated; }
.stage canvas.desk{ position: absolute; left: 0; bottom: 0; image-rendering: pixelated; }
.st-light{ position: absolute; right: 4px; top: 4px; width: 10px; height: 10px; border: 2px solid var(--outline); }
.fx{ position: absolute; font-family: var(--pixel); pointer-events: none; }

.station.activo canvas.char{ animation: bob 1.1s steps(2) infinite; }
.station.construyendo canvas.char{ animation: hammer .5s steps(2) infinite; }
.station.error canvas.char{ animation: shake .35s steps(2) infinite; }
.station.pausado canvas.char{ filter: saturate(.45) brightness(.8); }
@keyframes bob{ 50%{ transform: translateY(-2px); } }
@keyframes hammer{ 50%{ transform: translateY(1px) rotate(-2deg); } }
@keyframes shake{ 50%{ transform: translateX(2px); } }

.fx-z{ left: 70px; top: 4px; color: #cfd8e6; font-size: 9px; animation: zz 2.4s linear infinite; }
.fx-z.b{ animation-delay: 1.2s; }
@keyframes zz{ 0%{ opacity: 0; transform: translate(0,6px); } 30%{ opacity: 1; } 100%{ opacity: 0; transform: translate(10px,-14px); } }
.fx-bang{ left: 70px; top: 0; color: var(--st-error); font-size: 14px; animation: blink .6s steps(1) infinite; text-shadow: 2px 2px 0 var(--outline); }
@keyframes blink{ 50%{ opacity: 0; } }
.fx-spark{ left: 22px; top: 44px; color: var(--st-construyendo); font-size: 8px; animation: blink .5s steps(1) infinite; }
.fx-type{ left: 86px; top: 48px; width: 20px; height: 3px; background: var(--st-activo); animation: typing 1s steps(4) infinite; box-shadow: 0 0 6px var(--st-activo); }
@keyframes typing{ 0%{ width: 4px; } 100%{ width: 20px; } }

.name-tag{ font-family: var(--mono); font-size: 12px; font-weight: 500; text-align: center; margin-top: 6px; line-height: 1.25; max-width: 150px; }
.meta-tags{ display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; justify-content: center; }
.status-pill{ font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border-radius: 3px; border: 2px solid var(--outline); color: #06101f; font-weight: 600; }
.status-pill.activo{ background: var(--st-activo); } .status-pill.pausado{ background: var(--st-pausado); }
.status-pill.error{ background: var(--st-error); color: #fff; } .status-pill.construyendo{ background: var(--st-construyendo); }

.empty{ text-align: center; color: var(--muted); padding: 30px 16px 10px; margin: 0; }
.poll-note{ font-family: var(--mono); font-size: 11px; }

/* ---------- pedidos ---------- */
.requests-console{ margin-top: 16px; padding: 14px; }
.requests{ list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.requests li{ background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.requests .r-main{ flex: 1 1 260px; min-width: 0; }
.requests .r-main strong{ display: block; }
.requests .r-main p{ margin: 3px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.requests .r-side{ display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.req-status{ font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 3px; border: 2px solid var(--outline); }
.req-status.pendiente{ background: #2c3f5e; } .req-status.en_construccion{ background: var(--st-construyendo); color: #1b1405; }
.req-status.entregada{ background: var(--st-activo); color: #06140b; } .req-status.descartada{ background: #3a3f4a; color: var(--muted); }
.prio-alta{ color: var(--st-error); font-family: var(--mono); font-size: 11px; }
.requests .empty-li{ color: var(--muted); justify-content: center; }

/* ---------- diálogos ---------- */
.dlg{ width: min(520px, calc(100vw - 32px)); padding: 18px; color: var(--text); }
.dlg::backdrop{ background: rgba(3,6,12,.72); }
.dlg form{ display: flex; flex-direction: column; gap: 12px; }
.dlg h3{ font-family: var(--pixel); font-size: 11px; line-height: 1.6; margin: 0; color: var(--accent); }
.dlg-actions{ display: flex; justify-content: flex-end; gap: 8px; }
.detail-head{ display: flex; gap: 14px; align-items: center; }
.detail-head canvas{ image-rendering: pixelated; background: var(--panel-2); border-radius: 6px; border: 2px solid var(--line); }
.detail-grid{ display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.detail-grid dt{ color: var(--muted); font-family: var(--mono); font-size: 12px; }
.detail-grid dd{ margin: 0; overflow-wrap: anywhere; }
.events{ list-style: none; padding: 0; margin: 6px 0 0; max-height: 160px; overflow: auto; font-size: 12px; }
.events li{ padding: 4px 0; border-top: 1px dashed var(--line); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.events time{ font-family: var(--mono); color: var(--muted); font-size: 11px; }
.admin-box{ border-top: 2px dashed var(--line); margin-top: 12px; padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.admin-box .row{ display: flex; gap: 8px; flex-wrap: wrap; }
.admin-box .row > *{ flex: 1 1 140px; }

/* ---------- asistente ---------- */
.drawer{
  position: fixed; right: 16px; bottom: 16px; top: 16px; width: min(520px, calc(100vw - 32px)); z-index: 30;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.drawer-head{ display: flex; justify-content: space-between; align-items: center; }
.drawer-head h3{ font-family: var(--pixel); font-size: 11px; margin: 0; color: var(--mavi-light); }
.placeholder-banner{ margin: 0; font-size: 13px; color: #f6dca4; background: rgba(242,184,75,.08); border: 2px dashed rgba(242,184,75,.4); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.chat{ flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.drawer-tools{ display: flex; gap: 4px; }
.assistant-context{ font-family: var(--mono); font-size: 12px; color: var(--muted); }
.assistant-context summary{ cursor: pointer; }
.assistant-context ul{ margin: 6px 0 0; padding-left: 18px; }
.msg{ max-width: 88%; padding: 8px 10px; border-radius: 8px; font-size: 14px; line-height: 1.45; border: 2px solid var(--outline); overflow-wrap: anywhere; }
.msg.user{ align-self: flex-end; background: var(--mavi); color: #06101f; white-space: pre-wrap; }
.msg.assistant{ align-self: flex-start; background: var(--panel-2); border-color: var(--line); max-width: 96%; position: relative; }
.msg.assistant.failed{ border-color: var(--st-error); color: #ffd0d4; }
.msg-copy{ display: block; margin: 6px 0 0 auto; background: none; border: 0; color: var(--muted); font-family: var(--mono); font-size: 11px; cursor: pointer; padding: 2px 0; }
.msg-copy:hover{ color: var(--mavi-light); }
.msg.pending .msg-copy{ visibility: hidden; }
.md > :first-child{ margin-top: 0; } .md > :last-child{ margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre{ margin: 0 0 8px; }
.md ul, .md ol{ padding-left: 20px; }
.md h3, .md h4, .md h5, .md h6{ font-size: 14px; margin: 12px 0 6px; color: var(--mavi-light); }
.md h3{ font-size: 15px; }
.md code{ font-family: var(--mono); font-size: 12.5px; background: var(--bg); padding: 1px 4px; border-radius: 3px; }
.md pre{ background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow-x: auto; }
.md pre code{ padding: 0; background: none; }
.md blockquote{ border-left: 3px solid var(--mavi); padding-left: 10px; color: #cfd9e8; }
.md hr{ border: 0; border-top: 1px dashed var(--line); margin: 10px 0; }
.md a{ color: var(--mavi-light); }
.md-table{ overflow-x: auto; margin: 0 0 8px; }
.md table{ border-collapse: collapse; font-size: 13px; }
.md th, .md td{ border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; }
.md th{ background: var(--bg); }
.typing{ display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i{ width: 6px; height: 6px; background: var(--mavi-light); animation: blink 1s steps(1) infinite; }
.typing i:nth-child(2){ animation-delay: .33s; } .typing i:nth-child(3){ animation-delay: .66s; }
.chat-empty{ display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 14px; }
.chat-empty p{ margin: 0 0 4px; }
.suggestion{ text-align: left; background: var(--panel-2); color: var(--text); border: 2px dashed var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.suggestion:hover{ border-color: var(--accent); }
.chat-form{ display: flex; gap: 8px; }
.chat-form textarea{ flex: 1; resize: none; }
.chat-form .btn:disabled{ opacity: .6; cursor: progress; }
.chat-hint{ font-family: var(--mono); font-size: 11px; margin-top: -4px; }

/* ---------- avisos / notas ---------- */
.toast{ position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; padding: 10px 14px; font-size: 14px; border-color: var(--st-error); max-width: calc(100vw - 32px); }
.form-ok{ color: var(--st-activo); font-size: 13px; margin: 0; }
.note-form{ flex-basis: 100%; display: flex; gap: 6px; }
.note-form input{ flex: 1; min-width: 0; font-size: 14px; padding: 6px 8px; }

@media (max-width: 600px){
  .desks{ grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 8px; padding: 18px 8px 0; }
  .stage{ transform: scale(.9); }
  .window{ width: 54px; }
  .neon{ font-size: 10px; }
  .top-actions{ width: 100%; }
}
