/* ════════════════════════════════════════════════════════════════════════
   INK Admin Tool — app.css  (rewrite)
   Dark theme, grid + detail views. Pure CSS, Chromium/Electron.
   ──────────────────────────────────────────────────────────────────────────
   Changelog vs. previous:
   · All status tints, radii, shadows, mono font → CSS tokens (see :root).
   · Hard-coded rgba()/#hex colors removed in favour of --*-bg tokens.
   · Consistent border-radius scale (--radius-sm / --radius / --radius-lg).
   · Added entrance + interaction transitions (cards, sections, detail,
     modal, overlay, buttons, inputs) — all reduced-motion safe.
   · Visual hierarchy: nav active bar, grid card left-accent, section titles.
   ════════════════════════════════════════════════════════════════════════ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ── Surfaces / text ── */
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2128;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-strong: #79bbff;   /* hover */
  --accent-press: #3f8ae0;    /* active */
  --accent-dim: #1f3a5f;
  --accent-shadow: rgba(88, 166, 255, 0.28);
  --text: #e6edf3;
  --text-muted: #7d8590;
  --text-dim: #484f58;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;

  /* ── Status background tints (was hard-coded rgba/hex) ── */
  --danger-bg: rgba(248, 81, 73, 0.1);
  --warning-bg: rgba(210, 153, 34, 0.1);
  --success-bg: rgba(63, 185, 80, 0.1);
  --accent-bg: rgba(88, 166, 255, 0.1);

  /* ── Focus ring ── */
  --focus-ring: 0 0 0 3px rgba(88, 166, 255, 0.15);

  /* ── Radii ── */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  /* ── Transitions ── */
  --transition-fast: 0.1s ease;
  --transition-base: 0.18s ease;
  --transition-slow: 0.28s ease;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* ── Mono font (standardised) ── */
  --font-mono: 'Courier New', 'Consolas', monospace;

  /* ── Layout ── */
  --titlebar-height: 40px;

  /* ── Legacy aliases ──
     These resolve the tokens referenced by inline styles inside wizard.js
     (makeCodeEditor) and by older selectors, unifying them with --bg / --text
     so nothing renders against an undefined custom property. */
  --bg-secondary: var(--bg);
  --bg-tertiary: var(--surface);
  --text-primary: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ── Titlebar ── */
.titlebar {
  height: var(--titlebar-height);
  background: var(--surface);
  /* sutil materialidad — luz desde arriba */
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.015), transparent);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px 0 16px;
  -webkit-app-region: drag;
  flex-shrink: 0;
}

.titlebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.titlebar-brand span.accent {
  color: var(--accent);
}

.titlebar-brand span.cupps {
  color: #ffffff;
}

.brand-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.titlebar-station {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  -webkit-app-region: no-drag;
}

.titlebar-station-label {
  font-size: 11px;
  color: var(--text-muted, #7d8590);
  user-select: none;
}

.titlebar-controls {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.titlebar-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.titlebar-btn.close:hover {
  background: var(--danger);
  color: #fff;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  background: var(--surface);
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.012), transparent 220px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 16px 0 0;
  overflow: hidden;
  transition: width 0.22s ease;
  will-change: width;
  transform: translateZ(0);
}
.sidebar.collapsed { width: 52px; }
.sidebar.collapsed .nav-text { opacity: 0; pointer-events: none; max-width: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 8px; gap: 0; }
.sidebar.collapsed .nav-icon { width: 18px; height: 18px; }
.sidebar.collapsed .nav-label { height: 0; padding: 0; margin: 6px 4px; border-top: 1px solid var(--border); overflow: hidden; }
.sidebar.collapsed .nav-section { padding: 0 4px; }
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  padding: 6px 12px;
}
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 6px 4px; }
.sidebar-toggle {
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 8px 0 6px; border-radius: var(--radius);
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 12px; white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base);
}
.sidebar-toggle:hover { background: var(--surface-hover); color: var(--text); }
.sidebar.collapsed .sidebar-toggle { padding: 0; width: 28px; justify-content: center; }
.sidebar-chevron { transition: transform 0.22s ease; flex-shrink: 0; }
.sidebar.collapsed .sidebar-chevron { transform: rotate(180deg); }

.nav-section {
  padding: 0 12px;
  margin-bottom: 4px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 8px 8px 6px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 36px;          /* kiosk: targets cómodos */
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  overflow: hidden;
  transition: background var(--transition-base), color var(--transition-base);
}
.nav-text { white-space: nowrap; overflow: hidden; max-width: 200px; transition: opacity 0.2s ease, max-width 0.22s ease; }

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

/* Active nav: 3px left indicator bar in addition to the filled background. */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent);
}

.nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Main content ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateZ(0);
}

/* ── Page header ── */
.page-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.page-title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;  /* títulos más apretados / modernos */
  color: var(--text);
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.db-interval-select {
  height: 34px;
  padding: 0 28px 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8590' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition-base), color var(--transition-base);
}
.db-interval-select:hover { border-color: var(--text-dim); color: var(--text); }

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  min-height: 34px;          /* kiosk: targets cómodos */
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base),
              box-shadow var(--transition-base), transform var(--transition-fast),
              color var(--transition-base);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  /* outline marcado por color \u2014 sin volumen ni sombra */
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-bg);
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

.btn-primary:active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.detail-delete-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.detail-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}
.btn:disabled .spin-active {
  opacity: 1;
}

/* ── Toolbar ── */
.toolbar {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px 8px 34px;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.user-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── User grid ── */
.user-grid-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 4px 24px 24px;
  /* Section change: fade + horizontal slide each time the grid is shown. */
  animation: sectionIn var(--transition-slow) backwards;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-base), background var(--transition-base),
              transform var(--transition-fast), box-shadow var(--transition-base);
  /* Staggered entrance — see nth-child delays below. */
  animation: cardIn var(--transition-slow) backwards;
}

.user-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  transform: translateY(-2px);
  /* 3px left accent bar via inset shadow (no layout reflow). */
  box-shadow: inset 3px 0 0 0 var(--accent), var(--shadow-md);
}

.user-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 0 var(--accent);
}

/* Stagger: incremental animation-delay across the first cards in the grid. */
.user-card:nth-child(1)  { animation-delay: 0.00s; }
.user-card:nth-child(2)  { animation-delay: 0.03s; }
.user-card:nth-child(3)  { animation-delay: 0.06s; }
.user-card:nth-child(4)  { animation-delay: 0.09s; }
.user-card:nth-child(5)  { animation-delay: 0.12s; }
.user-card:nth-child(6)  { animation-delay: 0.15s; }
.user-card:nth-child(7)  { animation-delay: 0.18s; }
.user-card:nth-child(8)  { animation-delay: 0.21s; }
.user-card:nth-child(9)  { animation-delay: 0.24s; }
.user-card:nth-child(10) { animation-delay: 0.27s; }
.user-card:nth-child(11) { animation-delay: 0.30s; }
.user-card:nth-child(12) { animation-delay: 0.33s; }
.user-card:nth-child(13) { animation-delay: 0.36s; }
.user-card:nth-child(14) { animation-delay: 0.39s; }
.user-card:nth-child(15) { animation-delay: 0.42s; }
.user-card:nth-child(16) { animation-delay: 0.45s; }
.user-card:nth-child(n+17) { animation-delay: 0.48s; }

.user-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg);
  transition: border-color var(--transition-base);
}

.user-card.selected .user-avatar {
  border-color: var(--accent);
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

.user-username {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ── States ── */
.state-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  animation: fadeIn var(--transition-base) backwards;
}

.state-icon {
  font-size: 40px;
  opacity: 0.4;
}

.state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

.state-sub {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  max-width: 300px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* One-shot spin for the Refresh icon (re-triggered on each click). */
.spinning {
  animation: spin 0.6s linear;
  transform-origin: 50% 50%;
}
/* Continuous spin while an async operation is in progress. */
.spin-active {
  animation: spin 0.7s linear infinite;
  transform-origin: 50% 50%;
}

/* ── Back button ── */
.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-base), color var(--transition-base);
  margin-right: 4px;
}

.btn-back:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ── Airline card ── */
.iata-code {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}

.iata-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  letter-spacing: 0.5px;
}

.iata-badge.id-badge {
  background: var(--surface-hover);
  color: var(--text-muted);
}

/* ── Detail view ── */
.detail-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  /* Detail opens with a slide from the right. */
  animation: detailIn var(--transition-slow) backwards;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.detail-header-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-id {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.detail-username {
  font-size: 12px;
  color: var(--text-dim);
}

.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

/* More separation between a section's title and its content. */
.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

/* ── Margins ── */
.margins-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.margin-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.margin-group-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.margin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.margin-row code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

/* ── Apps ── */
.apps-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-card.app-card-deleted {
  opacity: 0.6;
  border-style: dashed;
}

.app-deleted-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-lg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Soft delete → warning palette token. */
.app-deleted-badge.soft {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
}

/* Full delete → danger palette token. */
.app-deleted-badge.full {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}

.app-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.app-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.app-launcher {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-all;
}

.app-kills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.kill-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-family: var(--font-mono);
}

/* Cifras alineadas en datos / monoespaciados. */
.iata-code,
.user-username,
.app-launcher,
.margin-row code,
.user-count {
  font-variant-numeric: tabular-nums;
}

/* ── Margin toggles ── */
.margin-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.margin-toggle-label {
  font-size: 12px;
  color: var(--text-muted);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background var(--transition-base);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition-base), background var(--transition-base);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent-dim);
}

.toggle input:checked + .toggle-slider::before {
  background: var(--accent);
  transform: translateX(14px);
}

.toggle input:focus-visible + .toggle-slider {
  box-shadow: var(--focus-ring);
}

.margin-source-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  margin-left: auto;
}

.margin-source-badge.native {
  background: var(--success-bg);
  color: var(--success);
}

.margin-source-badge.platform {
  background: var(--accent-bg);
  color: var(--accent);
}

/* ── Custom modal ── */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  /* Fade the scrim in. */
  animation: overlayIn var(--transition-base) backwards;
}

.app-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 320px;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  /* Scale + fade in. */
  animation: modalIn var(--transition-base) backwards;
}

.app-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.app-modal-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ── Detail view inline add-app form ── */
.detail-add-app-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn var(--transition-base) backwards;
}

/* ── Delete loading overlay (markup is inline-styled in index.html) ── */
#delete-overlay {
  animation: overlayIn var(--transition-base) backwards;
}

/* ════════════════════════════════════════════════════════════════════════
   Keyframes
   ════════════════════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes sectionIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes detailIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ════════════════════════════════════════════════════════════════════════
   Reduced motion — disable entrance animations, looping spinners slowed,
   transitions collapsed. Applies to wizard.css rules too (loaded after).
   ════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ════════════════════════════════════════════════════════════════════════
   Componentes nuevos (detail apps, picker de existing, cards de usuario)
   ════════════════════════════════════════════════════════════════════════ */

/* Filas key-value reutilizables (detail / cards) */
.kv-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  font-size: 13px;
  align-items: baseline;
}
.kv-row:first-child { border-top: none; }
.detail-section-title + .kv-row { border-top: none; }
.kv-k {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kv-v { color: var(--text); word-break: break-word; }
.kv-v.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kv-v.muted { color: var(--text-muted); }

/* Icono cuadrado de entidad (usuario / app) */
.entity-ico {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-mono);
  overflow: hidden;
}
.entity-ico img { width: 100%; height: 100%; object-fit: contain; }
.entity-row { display: flex; align-items: center; gap: 12px; }
.entity-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.entity-name { font-size: 13px; font-weight: 500; color: var(--text); }
.entity-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
}
.entity-sub .k {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Picker "Use existing app" — lista clara en vez de chips difusos */
.existing-picker {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.existing-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.existing-picker-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.existing-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}
.existing-option:first-of-type { border-top: none; }
.existing-option:hover { background: var(--surface-hover); }
.existing-option .name { flex: 1; font-weight: 500; }
.existing-option .folder { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
.existing-option .arrow { color: var(--accent); font-size: 16px; line-height: 1; }

/* App grid card — matches user-card sizing */
.app-grid-card {
  cursor: pointer;
}

/* ── Messages section ──────────────────────────────────────────────────────── */
#messages-view { flex: 1; overflow: hidden; }

.msg-layout {
  display: flex;
  gap: 16px;
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;
}

.msg-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-panel-left  { flex: 0 0 300px; }
.msg-panel-right { flex: 1; }

.msg-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-hub-status {
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-dim);
}
.msg-hub-status--connected    { background: rgba(63,185,80,.15); color: #3fb950; }
.msg-hub-status--reconnecting { background: rgba(210,153,34,.15);  color: #d29922; }
.msg-hub-status--disconnected { background: rgba(248,81,73,.15);  color: #f85149; }

.msg-ws-header {
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}

.msg-ws-selectall {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  user-select: none;
}

.msg-ws-list { flex: 1; overflow-y: auto; padding: 6px 0; }

.msg-ws-empty {
  padding: 24px 14px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.msg-group-header {
  padding: 8px 14px 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  opacity: 0.55;
}

.msg-ws-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  cursor: pointer;
  user-select: none;
}
.msg-ws-row:hover { background: var(--bg-hover); }

.msg-ws-name { font-size: 13px; font-family: var(--font-mono); }

.msg-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  flex: 1;
}

.msg-label { font-size: 11px; font-weight: 600; color: var(--text-dim); }

.msg-input {
  width: 100%;
  background: var(--bg-input, var(--bg-hover));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.msg-input:focus { border-color: var(--accent); }

.msg-textarea {
  width: 100%;
  background: var(--bg-input, var(--bg-hover));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.msg-textarea:focus { border-color: var(--accent); }

.msg-actions { display: flex; gap: 8px; margin-top: 4px; }

.msg-level-selector { display: flex; gap: 6px; }

.msg-level-btn {
  flex: 1;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.msg-level-btn.active[data-level="info"]    { background: rgba(74,144,226,.15); color: #4a90e2; border-color: #4a90e2; }
.msg-level-btn.active[data-level="warning"] { background: rgba(210,153,34,.15); color: #d29922; border-color: #d29922; }
.msg-level-btn.active[data-level="error"]   { background: rgba(248,81,73,.15);  color: #f85149; border-color: #f85149; }

.btn-sm { padding: 3px 10px; min-height: 26px; font-size: 12px; }
