/* ==========================================================================
   Dashboard Presidencia — Estilos
   ==========================================================================
   IDENTIDAD VISUAL: todo lo que hay que cambiar para aplicar la marca de la
   empresa está en el bloque :root de abajo. No hace falta tocar nada más.
   ========================================================================== */

:root {
  /* --- Colores de marca ------*/
  --brand-primary: #2563eb;   /* color de acento: foco, botones activos     */
  --brand-bg:      #0b1220;   /* fondo general de la pantalla               */
  --brand-surface: #121a2b;   /* fondo de cada celda y del encabezado       */
  --brand-border:  #1f2a3d;   /* bordes y separadores                       */
  --brand-fg:      #e8edf7;   /* texto principal                            */
  --brand-muted:   #8fa0bd;   /* texto secundario                           */
  --brand-danger:  #f0616d;   /* errores                                    */

  /* --- Medidas ---------------------------------------------------------- */
  --header-height: 56px;
  --cell-gap:      12px;
  --cell-radius:   14px;
  --celltitle-height: 30px;

  /* --- Tipografía ------------------------------------------------------- */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Oculta las barras de título de cada celda si showCellTitles = false */
body.no-cell-titles { --celltitle-height: 0px; }

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--brand-bg);
  color: var(--brand-fg);
  font-family: var(--font);
  overflow: hidden;               /* en el videowall no debe haber scroll    */
  -webkit-font-smoothing: antialiased;
}

/* Oculta el cursor tras unos segundos de inactividad (modo kiosco) */
body.cursor-hidden, body.cursor-hidden * { cursor: none !important; }

/* --------------------------------------------------------------------------
   Encabezado
   -------------------------------------------------------------------------- */

.header {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-height);
  flex: 0 0 var(--header-height);
  padding: 0 16px;
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header__logo { display: block; height: 32px; width: auto; }

.header__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.header__status { flex: 1 1 auto; min-width: 0; }

.status {
  font-size: 0.8125rem;
  color: var(--brand-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  color: var(--brand-muted);
  margin-right: 4px;
}

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  background: transparent;
  color: var(--brand-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background-color .15s;
}

.btn:hover { color: var(--brand-fg); border-color: var(--brand-primary); }

.btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn--text {
  width: auto;
  height: auto;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.875rem;
}

/* Animación del botón actualizar mientras recarga */
.btn.is-busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Grilla 3 x 2
   -------------------------------------------------------------------------- */

.grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: var(--cell-gap);
  padding: var(--cell-gap);
  min-height: 0;                  /* imprescindible para que las filas encojan */
}

/* --------------------------------------------------------------------------
   Celda
   -------------------------------------------------------------------------- */

.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--cell-radius);
  overflow: hidden;
}

/* ⚠️ EXPANSIÓN A PANTALLA COMPLETA — leer antes de modificar.
   Se hace SOLO agregando esta clase al mismo elemento. Mover el <iframe>
   a otro contenedor (portal, appendChild, innerHTML) lo recarga, y con
   autoAuth una recarga significa rehacer el inicio de sesión: varios
   segundos en blanco. Nunca reubicar la celda en el DOM. */
.cell.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 50;
  border-radius: 0;
  border: none;
}

.cell__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--celltitle-height);
  flex: 0 0 var(--celltitle-height);
  padding: 0 10px;
  border-bottom: 1px solid var(--brand-border);
  overflow: hidden;
}

body.no-cell-titles .cell__bar { display: none; }

.cell__company {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-fg);
  white-space: nowrap;
}

.cell__title {
  font-size: 0.75rem;
  color: var(--brand-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell__index {
  margin-left: auto;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--brand-muted);
  opacity: .6;
}

.cell__expand {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--brand-muted);
  cursor: pointer;
}

.cell__expand:hover { color: var(--brand-fg); background: rgba(255,255,255,.06); }

.cell__expand:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
}

.cell__expand svg {
  width: 13px; height: 13px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.cell__body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.cell__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --------------------------------------------------------------------------
   Estados de carga y error de cada celda
   -------------------------------------------------------------------------- */

.cell__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: var(--brand-surface);
  transition: opacity .4s ease;
}

.cell__overlay[hidden] { display: none; }

.cell__overlay.is-fading { opacity: 0; pointer-events: none; }

.cell__spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--brand-border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.cell__overlay-text {
  font-size: 0.8125rem;
  color: var(--brand-muted);
  max-width: 34ch;
  line-height: 1.5;
}

.cell__overlay-text strong { color: var(--brand-fg); font-weight: 600; }

.cell__overlay--warn .cell__overlay-text strong { color: var(--brand-danger); }

@media (prefers-reduced-motion: reduce) {
  .cell__spinner, .btn.is-busy svg { animation: none; }
  .cell__overlay { transition: none; }
}

/* --------------------------------------------------------------------------
   Aviso de cookies bloqueadas
   -------------------------------------------------------------------------- */

.cookie-warning {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 480px;
  padding: 14px 18px;
  background: var(--brand-surface);
  border: 1px solid var(--brand-danger);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  font-size: 0.875rem;
  line-height: 1.5;
}

.cookie-warning[hidden] { display: none; }
.cookie-warning p { margin: 6px 0 10px; color: var(--brand-muted); }
.cookie-warning code {
  font-size: 0.8125em;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,.07);
}

/* --------------------------------------------------------------------------
   Adaptación a otras pantallas
   -------------------------------------------------------------------------- */

/* Pantallas muy grandes (videowall 4K): más aire y tipografía mayor */
@media (min-width: 2560px) {
  :root {
    --header-height: 76px;
    --cell-gap: 18px;
    --cell-radius: 18px;
    --celltitle-height: 40px;
  }
  .header__title { font-size: 1.375rem; }
  .header__logo  { height: 44px; }
  .clock         { font-size: 1.25rem; }
  .status        { font-size: 1rem; }
  .btn           { width: 44px; height: 44px; }
  .btn svg       { width: 22px; height: 22px; }
  .cell__company, .cell__title { font-size: 0.9375rem; }
}

/* Laptop y tablet horizontal: 2 columnas x 3 filas */
@media (max-width: 1280px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
}

/* Celular y tablet vertical: una sola columna, con scroll vertical */
@media (max-width: 820px) {
  body { overflow: auto; }

  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
  }

  .cell { height: 78vh; }

  .header__status { display: none; }   /* el espacio no alcanza */
  .header__title  { font-size: 0.9375rem; }
}

/* En pantallas táctiles el cursor nunca se oculta */
@media (hover: none) {
  body.cursor-hidden, body.cursor-hidden * { cursor: auto !important; }
}
