/* Paleta real de Klou (klou-zero/lib/colors.ts, klou-zero-admin-panel/app/globals.css)
   — negro + dorado "champagne", sin variante clara (el brand no tiene una). */
:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --border: #1f1f1f;
  --text: #ffffff;
  --text-muted: #888888;
  --accent: #b08400;
  --accent-hover: #8f6c00;
  --ok-bg: #052e1a; --ok-text: #4ade80;
  --warn-bg: rgba(176, 132, 0, 0.14); --warn-text: #d9a900;
  --code-bg: #0d0d0d; --code-text: #e2e8f0;
  --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; accent-color: var(--accent); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 1.25rem 3rem; }

header.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 2rem;
}
header.topbar .inner {
  max-width: 980px; margin: 0 auto; padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem;
}
header.topbar .brand {
  display: flex; align-items: center; gap: 0.4rem;
  font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none;
}
header.topbar .brand img { height: 22px; width: auto; display: block; }
header.topbar .brand span { color: var(--accent); }
header.topbar nav { display: flex; gap: 1.1rem; }
header.topbar nav a {
  color: var(--text-muted); text-decoration: none; font-size: 0.9rem; font-weight: 500;
  padding: 0.3rem 0; border-bottom: 2px solid transparent;
}
header.topbar nav a:hover, header.topbar nav a.active { color: var(--text); border-color: var(--accent); }
header.topbar .session-info { margin-left: auto; display: flex; align-items: center; gap: 0.9rem; font-size: 0.85rem; }
header.topbar .session-info a.muted { text-decoration: none; }
header.topbar .session-info a.muted:hover { color: var(--text); }
header.topbar .session-info form { margin: 0; }
header.topbar .session-info button { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

h1 { font-size: 1.5rem; margin: 0 0 0.3rem; }
h2 { font-size: 1.05rem; margin: 2rem 0 0.8rem; color: var(--text); }
p.subtitle { color: var(--text-muted); margin: 0 0 1.5rem; font-size: 0.92rem; }
.muted { color: var(--text-muted); font-size: 0.88rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}

.search-bar { display: flex; gap: 0.5rem; }
input[type=text], input[type=search], input[type=number], input[type=email], input[type=password], select {
  font: inherit; padding: 0.55rem 0.8rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 0.92rem; width: 100%;
}
input[type=text]:focus, input[type=search]:focus, input[type=number]:focus,
input[type=email]:focus, input[type=password]:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
input[type=text], input[type=search] { flex: 1; }
input[type=number] { width: 90px; }
select { min-width: 220px; width: auto; }

button, .btn {
  font: inherit; font-weight: 600; font-size: 0.88rem; padding: 0.55rem 1.1rem;
  background: var(--accent); color: white; border: none; border-radius: 8px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary, .btn.secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
button.secondary:hover, .btn.secondary:hover { color: var(--text); background: var(--bg); }

.btn-back {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.82rem; padding: 0.4rem 0.85rem; border-radius: 8px; margin-bottom: 1rem;
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
     color: var(--text-muted); padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
td a { color: var(--text); text-decoration: none; font-weight: 500; }
td a:hover { color: var(--accent); }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-missing { background: var(--warn-bg); color: var(--warn-text); }

dl.field { display: flex; gap: 0.5rem; margin: 0 0 0.55rem; font-size: 0.92rem; }
dl.field dt { font-weight: 600; color: var(--text-muted); min-width: 150px; flex-shrink: 0; }
dl.field dd { margin: 0; }

.evidence-link { font-size: 0.72rem; color: var(--text-muted); text-decoration: none; margin-left: 0.4rem; }
.evidence-link:hover { color: var(--accent); }

.quote {
  font-size: 0.85rem; padding: 0.4rem 0.7rem; border-left: 2px solid var(--border);
  margin: 0.3rem 0; color: var(--text-muted); background: var(--bg); border-radius: 0 6px 6px 0;
}

pre.output {
  background: var(--code-bg); color: var(--code-text); padding: 1rem 1.1rem; border-radius: 8px;
  overflow-x: auto; font-size: 0.8rem; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── formularios de varias secciones (ej. /extraer) ──────────────────── */
.form-section { padding: 1.2rem 0; border-bottom: 1px solid var(--border); }
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: none; padding-bottom: 0; }
.form-section-label {
  display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.7rem;
}
.pill-option {
  display: flex; align-items: center; gap: 0.45rem; padding: 0.5rem 0.95rem;
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 0.88rem;
  background: var(--surface); transition: border-color 0.15s;
}
.pill-option:has(input:checked) { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.plan-option {
  display: flex; align-items: baseline; gap: 0.6rem; padding: 0.65rem 0.9rem;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color 0.15s;
}
.plan-option:has(input:checked) { border-color: var(--accent); background: var(--bg); }
.form-field-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.form-actions {
  display: flex; align-items: flex-end; gap: 0.8rem; margin-top: 0.2rem;
}
.form-actions .form-field-group { display: flex; flex-direction: column; gap: 0.35rem; }

/* ── pantallas de auth (login) — centradas, separadas del layout de app ── */
.auth-shell {
  min-height: calc(100vh - 89px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.25rem;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 2.2rem 2rem; width: 100%; max-width: 380px;
}
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  font-weight: 700; font-size: 1.15rem; color: var(--text); margin-bottom: 1.4rem;
}
.auth-brand img { height: 30px; width: auto; display: block; }
.auth-brand span { color: var(--accent); }
.auth-card h1 { text-align: center; margin-bottom: 0.3rem; }
.auth-card p.subtitle { text-align: center; margin-bottom: 1.6rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.auth-form button { width: 100%; padding: 0.65rem 1.1rem; margin-top: 0.3rem; font-size: 0.92rem; }
.auth-error {
  background: var(--warn-bg); color: var(--warn-text); border-radius: 8px;
  padding: 0.6rem 0.8rem; font-size: 0.85rem; margin-bottom: 1.2rem; text-align: center;
}

/* ── grafo (event/venue/organizer/person, ver graph.py) ─────────────────── */
.graph-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.35rem;
}
.graph-side {
  position: absolute; top: 0; right: 0; bottom: 0; width: 320px; max-width: 85%;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 160ms ease-out; overflow-y: auto;
}
.graph-side.open { transform: translateX(0); }
.graph-side-inner { padding: 1.1rem 1.2rem 1.6rem; position: relative; }
.graph-side-close {
  position: absolute; top: 0.8rem; right: 0.9rem; background: none; border: none;
  color: var(--text-muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0;
}
.graph-side-close:hover { color: var(--text); }
.graph-side-image { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin: 1.9rem 0 0.8rem; display: block; }
.graph-side-inner h3 { margin: 0.6rem 0 0.4rem; font-size: 1.05rem; }
.graph-explain { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.9rem; line-height: 1.4; }
.graph-side-props { font-size: 0.85rem; margin: 0 0 0.3rem; }
.graph-side-props dt { color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.6rem; }
.graph-side-props dd { margin: 0.15rem 0 0; word-break: break-word; }

/* ── toolbar de navegación del grafo (buscar/zoom/fit/filtro por tipo) —
   mismo patrón que klou-ops-console/ui/app/graph/GraphView.tsx ─────────── */
.graph-toolbar {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  padding: 0.7rem 1rem; margin-bottom: 1rem;
}
.graph-search-wrap { position: relative; width: 220px; }
.graph-search-wrap input { width: 100%; }
.graph-search-results {
  position: absolute; top: calc(100% + 0.3rem); left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto;
}
.graph-search-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; background: none; border: none;
  padding: 0.5rem 0.7rem; font: inherit; font-size: 0.82rem; color: var(--text); cursor: pointer; text-align: left;
}
.graph-search-item:hover { background: var(--bg); }
.graph-search-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.graph-search-item-type { color: var(--text-muted); font-size: 0.72rem; }
.graph-search-empty { padding: 0.6rem 0.7rem; font-size: 0.8rem; color: var(--text-muted); }

.graph-legend { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.graph-legend-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; background: none;
  border: 1px solid var(--border); border-radius: 999px; padding: 0.3rem 0.7rem;
  font: inherit; font-size: 0.8rem; color: var(--text-muted); cursor: pointer; opacity: 0.55;
}
.graph-legend-chip.active { color: var(--text); opacity: 1; border-color: var(--border); }
.graph-legend-chip:hover { border-color: var(--accent); }

.graph-zoom-group { display: flex; overflow: hidden; border-radius: 8px; border: 1px solid var(--border); }
.graph-zoom-group button {
  background: transparent; color: var(--text); border: none; padding: 0.4rem 0.75rem;
  cursor: pointer; font-size: 0.95rem; line-height: 1;
}
.graph-zoom-group button:hover { background: var(--bg); }
.graph-zoom-group button:first-child { border-right: 1px solid var(--border); }

/* ── overlay de carga — visible mientras la página carga y durante las
   navegaciones/envíos lentos (ej. el run de scraping) ──────────────────── */
.app-loading {
  position: fixed; inset: 0; z-index: 999;
  display: none;
  align-items: center; justify-content: center; gap: 0.7rem;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(2px);
  color: var(--text-muted); font-size: 0.9rem; font-weight: 600;
}
.app-loading.visible { display: flex; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: app-loading-spin 0.8s linear infinite;
}
.app-loading .spinner { width: 26px; height: 26px; }
@keyframes app-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .app-loading .spinner { animation-duration: 1.6s; } }
