/* ============================================================
 * theme.css — Componentes del design system (paleta neutra)
 *
 * Los tokens (--cf-*) se definen en templates/base.html
 * (:root para light, .dark para dark mode).
 *
 * Regla del proyecto: utilidades Tailwind para layout/espaciado,
 * estas clases para color/superficie/estado. CSS plano a propósito:
 * el Play CDN no procesa @apply en .css externos, y el chrome
 * (hub-header.js / hub-nav.js) inyecta DOM que necesita estilos
 * inmediatos sin esperar al MutationObserver de Tailwind.
 * ============================================================ */

/* El atributo hidden debe ganar siempre, incluso sobre clases con display */
[hidden] { display: none !important; }

/* ---- Cards ---- */
.card {
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card-inset {
  background: var(--cf-surface-2);
  border-radius: 12px;
}

/* ---- Botones ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: var(--cf-primary);
  color: var(--cf-primary-fg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--cf-primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--cf-border);
  border-radius: 10px;
  background: var(--cf-surface);
  color: var(--cf-text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--cf-surface-2); color: var(--cf-text); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--cf-text-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--cf-surface-2); color: var(--cf-text); }
.btn-ghost-danger:hover { background: var(--cf-danger-soft); color: var(--cf-danger); }

/* ---- Pills / badges de estado ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.pill-danger { background: var(--cf-danger-soft); color: var(--cf-danger); }
.pill-success { background: var(--cf-success-soft); color: var(--cf-success); }
.pill-warning { background: var(--cf-warning-soft); color: var(--cf-warning); }
.pill-neutral { background: var(--cf-surface-2); color: var(--cf-text-2); }
.pill-contrast { background: var(--cf-primary); color: var(--cf-primary-fg); }

/* ---- Barras de progreso ---- */
.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--cf-surface-2);
  overflow: hidden;
}
.progress-sm { height: 4px; }
.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--cf-primary);
}
.progress-bar-danger { background: var(--cf-danger); }
.progress-bar-success { background: var(--cf-success); }
.progress-bar-warning { background: var(--cf-warning); }

/* ---- Tabs ---- */
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--cf-text-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--cf-text); }
.tab-btn.active { color: var(--cf-text); border-bottom-color: var(--cf-primary); }

/* ---- Icon tiles (cuadrados pastel con ícono) ---- */
.icon-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}
.icon-tile-blue { background: var(--cf-tile-blue-soft); color: var(--cf-tile-blue); }
.icon-tile-green { background: var(--cf-tile-green-soft); color: var(--cf-tile-green); }
.icon-tile-orange { background: var(--cf-tile-orange-soft); color: var(--cf-tile-orange); }
.icon-tile-pink { background: var(--cf-tile-pink-soft); color: var(--cf-tile-pink); }
.icon-tile-danger { background: var(--cf-danger-soft); color: var(--cf-danger); }

/* ---- Inputs y selects ---- */
.input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--cf-border);
  border-radius: 10px;
  background: var(--cf-surface);
  color: var(--cf-text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--cf-text-3); }
.input:focus {
  outline: none;
  border-color: var(--cf-text-3);
  box-shadow: 0 0 0 3px var(--cf-ring);
}

/* ---- Alerts ---- */
.alert-danger {
  background: var(--cf-danger-soft);
  color: var(--cf-danger);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
}

/* ---- Links de datos (meta line, etc.) ---- */
.link { color: var(--cf-info); text-decoration: underline; }

/* ---- Separador vertical del header ---- */
.divider-v { width: 1px; height: 24px; background: var(--cf-border); }

/* ---- Filas de tabla (usadas por los renderers JS) ---- */
.trow { border-bottom: 1px solid var(--cf-border); }
tbody .trow:last-child { border-bottom: none; }

/* ---- Chevron de tendencia del dashboard (último reporte vs promedio) ---- */
.trend-up { color: var(--cf-danger); }
.trend-down { color: var(--cf-success); }

/* ---- Combobox con búsqueda (searchable select) ---- */
.ss-wrap { position: relative; }
.ss-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: 12px;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}
.ss-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--cf-border);
  color: var(--cf-text);
}
.ss-option:last-child { border-bottom: none; }
.ss-option:hover, .ss-option.active { background: var(--cf-surface-2); }
.ss-option.selected { background: var(--cf-surface-2); color: var(--cf-text); font-weight: 600; }
.ss-option .ss-sub { display: block; font-size: 12px; color: var(--cf-text-2); margin-top: 2px; font-weight: 400; }
.ss-empty { padding: 8px 12px; color: var(--cf-text-2); font-size: 14px; }

/* ---- Chrome del Hub (inyectado por hub-header.js / hub-nav.js) ---- */
.hub-header {
  background: var(--cf-bg);
  border-bottom: 1px solid var(--cf-border);
}
.hub-brand { color: var(--cf-text-2); transition: color 0.15s; }
.hub-brand:hover { color: var(--cf-text); }
/* El hamburger solo existe en mobile; media query propia para no
   depender del orden entre theme.css y el stylesheet del Play CDN */
@media (min-width: 768px) {
  .hub-hamburger { display: none; }
}

.hub-nav {
  background: var(--cf-bg);
  border-right: 1px solid var(--cf-border);
}
.hub-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--cf-text-2);
  transition: background 0.15s, color 0.15s;
}
.hub-nav-item:hover { background: var(--cf-surface-2); color: var(--cf-text); }
.hub-nav-item.active,
.hub-nav-item.active:hover {
  background: var(--cf-primary);
  color: var(--cf-primary-fg);
  font-weight: 600;
}
