/* ════════════════════════════════════════════════════════════
   CENTRAL DE ÁNGELES — APP SHELL / LAYOUT
   Sidebar, topbar, contenedores. Para app autenticada.
   Excepción: .page-loader (al final del archivo) es de página
   completa — lo carga también la landing (ver patrón 14 de app.js).
   ════════════════════════════════════════════════════════════ */

/* ── App shell ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh; /* Safari iOS: 100vh incluye la barra de dirección */
  overflow: hidden;
}

body.app-body {
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  box-shadow: var(--shadow-sm);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.sidebar-logo img {
  height: 40px;
  width: auto;
  max-width: 100%;
  filter: var(--logo-filter);
  transition: filter 0.3s ease;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--electric-light);
  border: 1.5px solid var(--electric);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--electric-text);
  flex-shrink: 0;
}
.user-name { font-size: var(--text-base); font-weight: 600; color: var(--text-1); }
.user-role { font-size: var(--text-xs); color: var(--text-4); }
.client-badge {
  margin-left: auto;
  font-size: var(--text-2xs);
  font-weight: 700;
  background: var(--gps-light);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-section {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 14px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--text-1);
  background: var(--surface-3);
}
.nav-item.active {
  color: var(--electric-text);
  background: var(--electric-light);
  border-left-color: var(--electric);
  font-weight: 600;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon {
  font-size: var(--text-lg);
  width: 18px;
  text-align: center;
  opacity: 0.7;
}
.nav-badge {
  margin-left: auto;
  font-size: var(--text-2xs);
  font-weight: 700;
  background: var(--danger-light);
  color: var(--danger-text);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}
.nav-badge.warn { background: var(--warning-light); color: var(--warning-text); }
.nav-badge.info { background: var(--info-light);    color: var(--info-text); }

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid var(--border-2);
  flex-shrink: 0;
}

/* ── Main area ─────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: var(--sp-3);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: var(--z-sticky);
  transition: background 0.3s ease;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}
.topbar-sub {
  font-size: var(--text-sm);
  color: var(--text-4);
  margin-left: 4px;
}
.topbar-spacer { flex: 1; }

/* Live indicator (.live-chip / .live-dot) → movido a components.css
   porque es un COMPONENTE reusable (lo consume el design-system doc,
   que solo carga tokens + components). Aquí queda solo su comportamiento
   responsivo de topbar (ocultarse en móvil, más abajo en este archivo). */

/* Theme toggle (top-bar variant, small).
   Markup: <button type="button" data-theme-toggle aria-pressed="…"> */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-full);
  padding: 5px 12px 5px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  user-select: none;
  font-family: var(--font-body);
}
.toggle-btn:hover { box-shadow: var(--shadow-md); }
.toggle-track {
  display: inline-block;
  width: 34px;
  height: 18px;
  background: var(--toggle-track);
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.25s ease;
  flex-shrink: 0;
}
[data-theme="dark"] .toggle-track { background: var(--gps); }
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.25s ease;
}
[data-theme="dark"] .toggle-thumb { transform: translateX(16px); }
.toggle-lbl { font-size: var(--text-sm); font-weight: 600; color: var(--text-3); }
.toggle-icon { font-size: var(--text-md); }

/* Date picker / select rápido en topbar */
.date-select {
  background: var(--surface-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ── Content scroll area ───────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
/* Sin esto, el flex column con scroll comprime a los hijos
   (flex-shrink default) y las cards se encimarían entre sí. */
.content > * { flex-shrink: 0; }

/* Page header (dentro de .content) — usado en pantallas de form/tabla */
.page-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
}
.page-sub {
  font-size: var(--text-sm);
  color: var(--text-3);
}

/* ── Two-column generic split (form + tabla, mapa + panel) */
.split-2 {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--sp-3);
  min-height: 340px;
}
.split-2.wider-side { grid-template-columns: 1fr 380px; }

@media (max-width: 1100px) {
  .split-2,
  .split-2.wider-side { grid-template-columns: 1fr; }
}

/* ── Auth shell (login etc.) ───────────────────────────── */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, var(--electric-dim), transparent 40%),
    radial-gradient(circle at 80% 80%, var(--gps-light), transparent 40%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.auth-logo img {
  height: 36px;
  filter: var(--logo-filter);
  transition: filter 0.3s ease;
}

/* ── Responsive shell ──────────────────────────────────── */

/* Botón hamburguesa (solo visible en móvil).
   Markup: <button type="button" class="menu-btn" data-sidebar-toggle aria-label="Abrir menú">☰</button> */
.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--text-xl);
  cursor: pointer;
  padding: 0;
}

/* Overlay que cierra el sidebar en móvil.
   Markup: <div class="sidebar-overlay" data-sidebar-close></div> */
.sidebar-overlay { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.25s ease, background 0.3s ease;
    z-index: var(--z-drawer);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 32, 68, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: var(--z-overlay);
  }
  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* Touch targets más generosos en el nav */
  .nav-item { padding: 12px 16px; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: var(--sp-2); }
  .topbar-title {
    font-size: var(--text-md);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Elementos secundarios que no caben en 375px */
  .topbar-sub,
  .toggle-lbl,
  .live-chip,
  .refresh-live { display: none; }
  .date-select { max-width: 130px; }
  .content { padding: var(--sp-3); }
}

/* ── Barra de carga simulada (patrón 14 de app.js) ────────
   Una por página, justo después de <body>. Fija arriba de todo
   (por encima incluso de modales/popups). Puramente cosmético. */
.page-loader {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease 0.1s;
}
.page-loader.is-active { opacity: 1; transition: opacity 0.1s ease; }
.page-loader-bar {
  height: 100%;
  width: 0%;
  background: var(--electric);
  box-shadow: 0 0 8px var(--electric);
  transition: width 0.4s ease;
}
</content>
