/* Elffuss — tema oscuro, acento rosa/violeta */
:root {
  --bg: #0b0d12;
  --bg2: #11141c;
  --bg3: #171b26;
  --line: #262c3d;
  --fg: #e8ebf4;
  --muted: #8b93a8;
  --accent: #ff4d8d;
  --accent2: #7c5cff;
  --ok: #3fb970;
  --warn: #e5a53a;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.logo { width: 30px; height: 30px; }
.beta { color: var(--accent2); font-size: .75rem; }
.claim { color: var(--muted); font-size: .8rem; font-style: italic; }
.controls { display: flex; align-items: center; gap: 10px; }
.model-pick { font-size: .9rem; color: var(--muted); }
select {
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: .85rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.off { background: #4a5062; }
.dot.loading { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.on { background: var(--ok); }
.dot.gpu { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- layout ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 42%) 1fr;
  min-height: 0;
}
@media (max-width: 800px) {
  main { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* ---------- chat ---------- */
#chat {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-height: 0;
}
#log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 92%; white-space: pre-wrap; word-break: break-word; line-height: 1.45; font-size: .93rem; }
.msg.sys { background: linear-gradient(135deg, #1c1430, #14202e); border: 1px solid var(--line); white-space: normal; }
.msg.user { background: var(--accent2); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--bg3); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.err { border-color: #a03050; }
.msg.thinking {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg3); border: 1px dashed var(--line);
  align-self: flex-start; color: var(--muted); font-size: .85rem;
}
.msg.thinking .mini { width: 22px; height: 22px; }
.msg.thinking .dots i {
  display: inline-block; width: 6px; height: 6px; margin-left: 4px;
  border-radius: 50%; background: var(--accent);
  animation: bounce 1.2s ease-in-out infinite;
}
.msg.thinking .dots i:nth-child(2) { animation-delay: .2s; }
.msg.thinking .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-5px); opacity: 1; } }
.msg.thinking .gen {
  width: 100%; font-family: ui-monospace, monospace; font-size: .72rem;
  white-space: pre-wrap; word-break: break-word;
  max-height: 76px; overflow: hidden; color: #5f6880;
}
.msg.tool { color: var(--accent); font-size: .8rem; background: none; padding: 0 14px; }
.msg.tool-result { font-size: .8rem; color: var(--muted); background: var(--bg2); border: 1px dashed var(--line); border-radius: 10px; padding: 6px 10px; }
.msg.tool-result.err summary { color: var(--warn); }
.msg.tool-result pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow: auto; }
.msg.tool-result summary { cursor: pointer; }

#chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; }
.chip {
  font-size: .78rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { color: var(--fg); border-color: var(--accent); }

#composer { display: flex; gap: 8px; padding: 12px 14px 16px; }
#prompt {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--fg);
  padding: 12px 14px;
  font-size: .95rem;
  outline: none;
}
#prompt:focus { border-color: var(--accent2); }
#send {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- visualizador ---------- */
#viz { display: flex; flex-direction: column; min-height: 0; background: var(--bg2); }
#tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
#tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: .88rem;
  cursor: pointer;
}
#tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.panel { display: none; flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.panel.active { display: block; }
#panel-vista { padding: 0; position: relative; }
#panel-vista.active { display: flex; }
#appframe { flex: 1; width: 100%; height: 100%; border: none; background: #0d1117; }
#vista-empty[hidden] { display: none; }
#vista-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; gap: 8px;
}
#vista-empty .big { width: 120px; opacity: .5; }
.msg.sys .avatar { width: 44px; height: 44px; float: left; margin: 2px 10px 4px 0; }

/* ---------- tarjetas y controles de paneles ---------- */
.card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: .9rem;
}
.card b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card code { background: var(--bg); padding: 2px 8px; border-radius: 6px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.card.col { flex-direction: column; align-items: stretch; gap: 8px; }
.card.col b { flex: none; }
.row.between { justify-content: space-between; align-items: center; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field .muted { font-size: .74rem; }
.msg.user.queued { opacity: .55; }
.msg.user.queued::after { content: ' ⏳'; }
.muted { color: var(--muted); font-size: .82rem; }
.row { display: flex; gap: 8px; margin: 10px 0; }
.row.right { justify-content: flex-end; }
.panel input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  padding: 9px 12px;
  flex: 1;
}
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-size: .88rem;
}
button.ghost {
  background: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: .85rem;
}
button.ghost:hover { color: var(--fg); border-color: var(--accent); }
h3 { margin: 6px 0 12px; font-size: .95rem; }

/* ---------- modal de permisos ---------- */
dialog {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(5, 6, 10, .7); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 8px; }
dialog p { margin: 6px 0; font-size: .9rem; }

/* ---------- toasts y progreso ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .85rem;
  max-width: 340px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  animation: slidein .2s ease-out;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
#model-progress {
  position: fixed; bottom: 18px; left: 18px; z-index: 50;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: .8rem; color: var(--muted); width: 300px;
}
#model-progress .track { height: 4px; background: var(--bg); border-radius: 2px; margin-bottom: 6px; overflow: hidden; }
#model-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .2s; }
