/* ==========================================================================
   ViewDK2K · Panel
   Lenguaje visual: Fluent Design (Windows 11). Superficies planas, tipografía
   Segoe UI Variable, controles compactos y jerarquía por capas (Mica).
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #1b1b1b;
  --bg-nav: #202020;
  --card: #272727;
  --card-alt: #2b2b2b;
  --control: #2d2d2d;
  --control-hover: #383838;
  --bg-input: #1f1f1f;

  --border: #3d3d3d;
  --border-soft: #333333;

  --text: #f5f5f5;
  --text-dim: #c9c9c9;
  --text-mute: #9a9a9a;

  --accent: #60cdff;
  --accent-hover: #7bd7ff;
  --accent-text: #00232f;
  --accent-soft: rgba(96, 205, 255, 0.13);

  --green: #6ccb5f;
  --amber: #fce100;
  --red: #ff99a4;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

  --nav-w: 232px;
  --bar-h: 48px;
  --status-h: 28px;
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f3f3f3;
  --bg-nav: #ebebeb;
  --card: #ffffff;
  --card-alt: #f7f7f7;
  --control: #fdfdfd;
  --control-hover: #f2f2f2;
  --bg-input: #ffffff;

  --border: #d6d6d6;
  --border-soft: #e5e5e5;

  --text: #1b1b1b;
  --text-dim: #444444;
  --text-mute: #6f6f6f;

  --accent: #0f6cbd;
  --accent-hover: #1b7fd4;
  --accent-text: #ffffff;
  --accent-soft: rgba(15, 108, 189, 0.1);

  --green: #107c10;
  --amber: #9d5d00;
  --red: #c42b1c;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }

/* El atributo hidden siempre gana sobre cualquier display. */
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 560px at 18% -12%, rgba(96, 205, 255, 0.055), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-text strong, .card .value {
  font-family: "Segoe UI Variable Display", "Segoe UI Semibold", "Segoe UI", system-ui, sans-serif;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: "Cascadia Code", ui-monospace, Consolas, monospace;
  font-size: 0.92em;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  padding: 0 4px;
}

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: #4a4a4a;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #5c5c5c; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------- Login ---- */

#login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

#login.hidden, #app.hidden { display: none; }

.login-card {
  width: min(92vw, 360px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.2px; }
.login-brand p { margin: 1px 0 0; color: var(--text-mute); font-size: 12px; }

.app-logo {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.form-error { color: var(--red); font-size: 12.5px; min-height: 18px; margin: 10px 0 0; }
.login-note { color: var(--text-mute); font-size: 11.5px; margin: 12px 0 0; }

/* -------------------------------------------------------------- Layout ---- */

#app {
  min-height: 100vh;
  padding-bottom: var(--status-h);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: var(--status-h);
  width: var(--nav-w);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px 8px;
  background: var(--bg-nav);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 16px;
}

.brand .app-logo { width: 30px; height: 30px; border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 600; letter-spacing: 0.1px; }
.brand-text span { font-size: 10.5px; color: var(--text-mute); margin-top: 2px; }

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-mute);
  padding: 6px 12px 5px;
  letter-spacing: 0.2px;
}

.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
}

.nav-btn svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-btn:hover { background: rgba(255, 255, 255, 0.055); color: var(--text); }

.nav-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 2px;
  background: transparent;
}

.nav-btn.active { background: rgba(255, 255, 255, 0.07); color: var(--text); font-weight: 600; }
.nav-btn.active::before { background: var(--accent); }
.nav-btn.active svg { opacity: 1; color: var(--accent); }

.sidebar .spacer { flex: 1; min-height: 12px; }

.sidebar-footer {
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
  margin-top: 4px;
}

.sidebar-footer .meta {
  font-size: 11.5px;
  color: var(--text-mute);
  padding: 6px 10px 8px;
  line-height: 1.4;
}

.nav-btn.logout { color: var(--text-mute); }
.nav-btn.logout:hover { color: var(--red); }

.main-col {
  margin-left: var(--nav-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--status-h));
}

/* Barra superior: título + estado + tema (como una app nativa). */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--bar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg-nav) 88%, transparent);
  backdrop-filter: blur(14px);
}

.app-bar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.crumb { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.app-bar-sub { font-size: 11.5px; color: var(--text-mute); white-space: nowrap; }
.app-bar-actions { display: flex; align-items: center; gap: 8px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--control);
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); flex: none; }
.status-chip.ok .chip-dot { background: var(--green); }
.status-chip.warn .chip-dot { background: var(--amber); }
.status-chip.bad .chip-dot { background: var(--red); }
.status-chip.bad { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); }
.icon-btn:disabled { opacity: 0.45; cursor: default; }

#themeToggle { border-color: var(--border); background: var(--control); }
#themeToggle .icon-sun { display: none; }
html[data-theme="light"] #themeToggle .icon-sun { display: block; }
html[data-theme="light"] #themeToggle .icon-moon { display: none; }

.main {
  flex: 1;
  width: 100%;
  max-width: 1780px;
  padding: 20px 24px 44px;
}

.view { display: none; }
.view.active { display: block; animation: view-in 0.14s ease; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
}

h2 { margin: 0 0 3px; font-size: 22px; font-weight: 600; letter-spacing: -0.25px; }

.subtitle { color: var(--text-mute); font-size: 12.5px; margin: 0; }

.btn:focus-visible,
.nav-btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ------------------------------------------------------------ Superficies -- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow: hidden;
}

.card .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: var(--text-mute);
  margin-bottom: 7px;
  font-weight: 600;
}

.card .value { font-size: 25px; font-weight: 600; letter-spacing: -0.4px; line-height: 1.15; }
.card .hint { margin-top: 4px; font-size: 11.5px; color: var(--text-mute); }

.section {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.1px; }
.section-head .desc { font-size: 12px; color: var(--text-mute); margin: 3px 0 0; line-height: 1.55; max-width: 760px; }
.section-head .desc b { color: var(--text); font-weight: 600; }
.section-head .desc code { background: var(--bg-input); border: 1px solid var(--border-soft); color: var(--accent); }

.section.compact { padding: 12px 16px; }
.section.compact > .section-head { margin-bottom: 6px; }
.section.compact h3 { font-size: 14px; }

details.section.compact > summary {
  list-style: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.section.compact > summary::-webkit-details-marker { display: none; }
details.section.compact > summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--control);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1;
  color: var(--text-dim);
}
details.section.compact[open] > summary::before { content: "−"; }
details.section.compact[open] > summary { margin-bottom: 8px; }

/* --------------------------------------------------------------- Controles - */

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label, .field > span { font-size: 12px; color: var(--text-dim); }

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--border) 55%, var(--text-mute)); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

input[type="file"] { padding: 5px 8px; }
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--control);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.btn:hover { background: var(--control-hover); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.07); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
.btn.small { height: 26px; padding: 0 9px; font-size: 11.5px; border-radius: 4px; }

.check, .radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.check input, .radio input { accent-color: var(--accent); margin: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--card-alt);
  white-space: nowrap;
  vertical-align: middle;
}
.pill strong { font-weight: 600; color: var(--text); }
.pill.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); background: color-mix(in srgb, var(--green) 12%, transparent); }
.pill.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: color-mix(in srgb, var(--amber) 12%, transparent); }
.pill.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); background: color-mix(in srgb, var(--red) 12%, transparent); }
.pill.type-pill { background: var(--bg-input); }

.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.mono { font-family: "Cascadia Code", ui-monospace, Consolas, monospace; font-size: 12px; }
.empty { color: var(--text-mute); font-size: 12.5px; padding: 5px 0; }
.muted { color: var(--text-mute); }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------- Tablas ---- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 12.8px; }

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--text-mute);
  font-weight: 600;
  border-bottom-color: var(--border);
  white-space: nowrap;
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.028); }
tr:last-child td { border-bottom: 0; }
tr.is-paused { opacity: 0.55; }

td code { background: var(--bg-input); border: 1px solid var(--border-soft); }

.queue-table { min-width: 860px; }
.queue-table td:nth-child(2) { min-width: 340px; max-width: 820px; }
.queue-table td:nth-child(3) { min-width: 130px; }
.queue-table td:last-child,
.queue-table th:last-child { width: 1%; min-width: 190px; }

.queue-table thead th {
  background: var(--card);
}

.queue-item { display: flex; gap: 10px; align-items: flex-start; }
.queue-body { min-width: 0; }

.queue-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  white-space: pre-wrap;
}

.queue-media { margin-top: 3px; font-size: 11px; color: var(--text-mute); overflow-wrap: anywhere; }

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  flex: 0 0 auto;
}

img.thumb { cursor: zoom-in; }

.actions { gap: 2px; }
.icon-actions { display: flex; gap: 2px; flex-wrap: nowrap; justify-content: flex-end; }
td .actions .btn { white-space: nowrap; }

.queue-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }

/* ---------------------------------------------------------------- Alertas -- */

.alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--card-alt);
}

.alert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.alert p { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.55; overflow-wrap: anywhere; }

.alert-bad {
  border-color: color-mix(in srgb, var(--red) 45%, var(--border));
  background: color-mix(in srgb, var(--red) 9%, var(--card));
}
.alert-bad .alert-title { color: var(--red); }

.alert-warn {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--border));
  background: color-mix(in srgb, var(--amber) 9%, var(--card));
}
.alert-warn .alert-title { color: var(--amber); }

/* ------------------------------------------------------ Seguridad / info -- */

.safety-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 8px;
}

.safety-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.safety-label { font-size: 12px; font-weight: 600; }
.safety-help { font-size: 10.5px; color: var(--text-mute); line-height: 1.4; }
.safety-item input { min-height: 30px; padding: 4px 8px; }

.safety-foot { margin-top: 12px; display: grid; gap: 4px; }
.usage-line { font-size: 11.5px; color: var(--text-dim); }
.usage-line strong { color: var(--text); font-weight: 600; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}
.info-item span { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-mute); font-weight: 600; }
.info-item strong { font-size: 12.5px; font-weight: 500; overflow-wrap: anywhere; }
#callbackState, #webhookState { font-size: 11.5px; font-weight: 500; line-height: 1.5; }

/* --------------------------------------------------------- Cómo funciona -- */

.flow-section { background: var(--card); }

.flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.flow-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.flow-num {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
}

.flow-step strong { font-size: 12.8px; }
.flow-step p { margin: 3px 0 0; font-size: 11.5px; color: var(--text-mute); line-height: 1.5; }
.flow-step b { color: var(--text); font-weight: 600; }
.flow-ej { display: block; margin-top: 2px; font-size: 11px; color: var(--text-dim); }

.step-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-right: 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: 1px;
}

/* ------------------------------------------------------------- Reglas ------ */

.rule-card {
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.rule-card .rule-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rule-card .name { width: 180px; font-weight: 600; }

.rule-labels { margin: 10px 0 6px; }
.rule-card > .rule-labels:first-child { margin-top: 0; }
.rule-labels span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.chip-list { display: flex; flex-direction: column; gap: 6px; }
.chip-row { display: flex; gap: 6px; }
.chip-row input { font-family: "Cascadia Code", ui-monospace, monospace; font-size: 12px; }

#rulesList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 10px;
  align-items: start;
}
#rulesList .rule-card { margin-bottom: 0; }
#rulesList .rule-head .grow { max-width: 420px; }
#ignoreList .chip-row { max-width: 520px; }

/* ------------------------------------------------------------ Resultados --- */

.result {
  margin-top: 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 11px 14px;
}
.result.skip { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.result.none { border-color: var(--border); background: var(--card-alt); }
.result .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-mute); margin-bottom: 3px; font-weight: 600; }
.result .v { margin-bottom: 9px; white-space: pre-wrap; }
.result .v:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- Logs ----- */

pre {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line { padding: 2px 0; font-size: 12px; }
.log-line .ts { color: var(--text-mute); }
.log-line .lvl { font-weight: 700; margin: 0 6px; }
.log-line.warn .lvl { color: var(--amber); }
.log-line.error .lvl { color: var(--red); }
.log-line.info .lvl { color: var(--accent); }

/* --------------------------------------------------------------- Toast ----- */

.toast {
  position: fixed;
  bottom: calc(var(--status-h) + 16px);
  right: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
  max-width: 380px;
  font-size: 12.5px;
  z-index: 100;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-left-color: var(--red); }

/* ------------------------------------------------------------ Carrusel ----- */

.sticky-actions {
  position: sticky;
  bottom: calc(var(--status-h) + 8px);
  background: linear-gradient(to top, var(--bg) 68%, transparent);
  padding: 14px 0 6px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  z-index: 10;
}

/* ------------------------------------------------------------- Modales ----- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal-box {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
}
.modal-head { border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 18px; display: grid; gap: 12px; }
.modal-foot { border-top: 1px solid var(--border-soft); }
.modal-foot .hint { color: var(--text-mute); font-size: 12px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: min(92vw, 900px);
  max-height: 88vh;
  border-radius: 6px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

/* ---------------------------------------------------- Cargadas / memes ----- */

.preview {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
}

textarea.preview.editable {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  line-height: 1.5;
}
textarea.preview.editable:focus { border-color: var(--accent); }

.banter-image {
  display: block;
  max-width: 340px;
  max-height: 340px;
  margin-top: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

#banterDraft {
  margin-top: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

#banterPages { grid-template-columns: repeat(auto-fill, minmax(290px, 330px)); }

/* ----------------------------------------------------------- Muestras ------ */

.swatches { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.swatch:hover { transform: scale(1.07); }
.swatch.is-active { border-color: var(--accent); transform: scale(1.07); }
.swatch-none { background: transparent; border: 1px dashed var(--border); color: var(--text-mute); }
.swatch-none.is-active { border-color: var(--accent); color: var(--text); }

/* -------------------------------------------------- Explorador de carpetas - */

.folder-browser {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}

.folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 12.8px;
  cursor: pointer;
}
.folder-row:hover { background: var(--control-hover); }
.folder-up { color: var(--text-mute); border-bottom: 1px solid var(--border-soft); border-radius: 0; }
.folder-file { cursor: default; color: var(--text-mute); }
.folder-file:hover { background: transparent; }

/* ---------------------------------------------- Adelanto estilo Facebook -- */

#pubPreview { margin-top: 12px; }

.fb-post {
  max-width: 460px;
  background: #fff;
  color: #050505;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, sans-serif;
}
.fb-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px 8px; }
.fb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1877f2, #0f5fd6);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.fb-name { font-weight: 600; font-size: 14px; }
.fb-time { font-size: 12px; color: #65676b; }
.fb-text { padding: 2px 14px 10px; font-size: 14px; line-height: 1.35; white-space: pre-wrap; word-break: break-word; }
.fb-post img, .fb-post video { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.fb-bar {
  display: flex;
  justify-content: space-around;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #65676b;
  border-top: 1px solid #e4e6eb;
}
.fb-bar span { padding: 6px 10px; border-radius: 6px; cursor: default; }
.fb-bar span:hover { background: #f0f2f5; }

/* -------------------------------------------------- Menú de fila (⋯) ------- */

.row-menu { position: relative; display: inline-block; }
.row-menu > summary {
  list-style: none;
  cursor: pointer;
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--control);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  user-select: none;
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { border-color: var(--accent); }
.row-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 20;
  min-width: 175px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.row-menu-list button {
  text-align: left;
  background: transparent;
  border: 0;
  padding: 7px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
}
.row-menu-list button:hover { background: var(--control-hover); }
.row-menu-list button.danger { color: var(--red); }

#feedsBody a { color: inherit; text-decoration: none; }
#feedsBody a:hover { color: var(--accent); }

/* -------------------------------------------------------- Barra de estado -- */

.status-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--status-h);
  padding: 0 12px;
  background: var(--bg-nav);
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}

.status-bar[hidden] { display: none; }

.sb-item { display: inline-flex; align-items: center; gap: 6px; }
.sb-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); flex: none; }
.sb-item .dot.on { background: var(--green); }
.sb-item .dot.off { background: var(--red); }
.sb-sep { width: 1px; height: 12px; background: var(--border); }
.sb-grow { flex: 1; }

/* ---------------------------------------------------------------- Mobile --- */

@media (max-width: 900px) {
  #app { display: flex; flex-direction: column; padding-bottom: 0; }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .brand { padding: 0 10px 0 2px; }
  .brand-text span, .nav-label, .sidebar-footer { display: none; }
  .nav-btn { width: auto; height: 34px; white-space: nowrap; padding: 0 9px; }
  .nav-btn::before { display: none; }
  .sidebar .spacer { display: none; }

  .main-col { margin-left: 0; min-height: 0; }
  .app-bar { padding: 0 12px; }
  .app-bar-sub { display: none; }
  .main { padding: 16px 12px 40px; }

  .page-head { flex-direction: column; gap: 10px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  #rulesList { grid-template-columns: 1fr; }
  .status-bar { display: none; }
  .toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
