/* =============================================================================
   PARKQRO · Estacionamiento del Municipio de Querétaro
   Sistema visual centralizado (tokens de marca extraídos de PARKQRO.pdf).
   ============================================================================= */

:root {
  /* ===== Identidad PARKQRO — colores extraídos del PDF de marca =====
     (si no hubiera especificación oficial, estos son los valores tomados
     de la referencia PARKQRO.pdf). */
  --qro-primary:   #0075C9;   /* azul principal — acciones y elementos destacados */
  --qro-navy:      #00205C;   /* azul marino — títulos, navegación y énfasis */
  --qro-turquoise: #00BFD7;   /* turquesa — acentos y elementos secundarios */
  --qro-indigo:    #1F1646;   /* índigo profundo — fondo de logo del manual */
  --qro-red: #ce3a2b;

  /* Alias que conserva el sistema existente (mapeados a la marca) */
  --qro-blue-dark:  var(--qro-navy);
  --qro-blue:       var(--qro-primary);
  --qro-blue-light: var(--qro-turquoise);

  --qro-white: #ffffff;
  --qro-bg: #eef3fa;          /* base neutra fría */
  --qro-surface: #ffffff;
  --qro-border: #d5e1f0;

  --qro-text-primary: #16233b;
  --qro-text-secondary: #55627a;
  --qro-text-muted: #8793a8;

  /* Semánticos (acompáñalos SIEMPRE de icono/texto, nunca solo color) */
  --qro-success: #188a5b;     /* éxito / disponibilidad */
  --qro-warning: #d99000;     /* advertencia */
  --qro-danger: #ce3a2b;      /* error */
  --qro-info: var(--qro-turquoise);

  --qro-radius-sm: 8px;
  --qro-radius-md: 12px;
  --qro-radius-lg: 16px;

  --qro-shadow-sm: 0 2px 8px rgba(0, 32, 92, 0.08);
  --qro-shadow-md: 0 12px 30px -14px rgba(0, 32, 92, 0.22);

  /* Estados interactivos (foco visible accesible) */
  --qro-focus: 0 0 0 3px rgba(0, 117, 201, 0.32);
  --qro-focus-ring: #0075C9;

  --sidebar-w: 264px;
  --header-h: 64px;
}

/* Foco visible consistente para navegación por teclado (accesibilidad). */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--qro-focus-ring);
  outline-offset: 2px;
}

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  color: var(--qro-text-primary);
  background: var(--qro-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--qro-blue); text-decoration: none; }
a:hover { color: var(--qro-blue-dark); }

h1, h2, h3, h4 { color: var(--qro-blue-dark); line-height: 1.2; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 24px; font-weight: 700; }
h3 { font-size: 20px; font-weight: 700; color: var(--qro-text-primary); }
h4 { font-size: 18px; font-weight: 600; color: var(--qro-text-primary); }

/* =============================================================================
   Layout administrativo: header + sidebar + contenido
   ============================================================================= */
.app { min-height: 100vh; }

.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: linear-gradient(100deg, #00205C 0%, #003c82 58%, #0075C9 125%);
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 16px; padding: 0 20px; z-index: 50;
  box-shadow: 0 2px 16px rgba(0,32,92,.30);
}
.app-header .brand { display: flex; align-items: center; gap: 12px; min-width: var(--sidebar-w); transition: min-width .22s ease; }
#menuToggle {
  border: none; background: rgba(255,255,255,.08); color: #fff; width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer;
  transition: background .15s; flex: 0 0 auto;
}
#menuToggle:hover { background: rgba(255,255,255,.18); }
.app-header .brand > img { border-radius: 8px; }
.app-header .brand .logo {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--qro-blue-dark); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.app-header .brand .brand-text { line-height: 1.1; white-space: nowrap; overflow: hidden; transition: opacity .18s, width .22s; }
.app-header .brand .brand-text strong { display: block; font-size: 14px; color: #fff; font-weight: 800; }
.app-header .brand .brand-text span { font-size: 13px; color: #fff; font-weight: 700; letter-spacing: -.01em; }

.app-header .header-title { font-size: 15px; font-weight: 600; color: rgba(255,255,255,.9); }
.app-header .header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--qro-blue-light), var(--qro-blue));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.22);
}
.user-chip .u-info { line-height: 1.15; text-align: right; }
.user-chip .u-info strong { font-size: 13px; display: block; color: #fff; }
.user-chip .u-info span { font-size: 11px; color: rgba(255,255,255,.72); }

/* ---- Sidebar -------------------------------------------------------------- */
.app-sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, #001A4D 0%, #00205C 55%, #033569 100%);
  color: #fff; overflow-y: auto; overflow-x: hidden; padding: 12px 0 18px; z-index: 40;
  border-right: 1px solid rgba(255,255,255,.06); transition: width .22s ease;
}
.app-sidebar::-webkit-scrollbar { width: 8px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
.app-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.24); }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent; }

.app-sidebar .nav-group { padding: 4px 14px; }
.app-sidebar .nav-group .group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.42); padding: 13px 10px 5px; font-weight: 700; white-space: nowrap;
}
.app-sidebar a.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 3px 0;
  border-radius: 11px; color: rgba(255,255,255,.82);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s;
}
.app-sidebar a.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-sidebar a.nav-link.active {
  background: linear-gradient(90deg, rgba(0,191,215,.30), rgba(0,191,215,.08));
  color: #fff; font-weight: 700;
}
.app-sidebar a.nav-link.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--qro-blue-light);
  box-shadow: 0 0 12px rgba(0,191,215,.7);
}
.app-sidebar a.nav-link .ico {
  width: 32px; height: 32px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.92);
  transition: background .15s, color .15s, box-shadow .15s;
}
.app-sidebar a.nav-link .ico i { font-size: 15px; line-height: 1; }
.app-sidebar a.nav-link:hover .ico { background: rgba(255,255,255,.13); }
.app-sidebar a.nav-link.active .ico { background: var(--qro-blue-light); color: #fff; box-shadow: 0 5px 14px -3px rgba(0,191,215,.7); }

/* Menú colapsado (riel de iconos) — solo escritorio */
@media (min-width: 901px) {
  html.sb-collapsed { --sidebar-w: 76px; }
  html.sb-collapsed .app-sidebar a.nav-link { justify-content: center; gap: 0; padding: 9px 0; }
  html.sb-collapsed .app-sidebar a.nav-link > span:not(.ico) { display: none; }
  html.sb-collapsed .app-sidebar a.nav-link.active::before { left: 0; }
  html.sb-collapsed .app-sidebar .nav-group { padding: 4px 12px; }
  html.sb-collapsed .app-sidebar .group-label {
    color: transparent; height: 1px; padding: 0; margin: 12px 14px; overflow: hidden; background: rgba(255,255,255,.10);
  }
  html.sb-collapsed .app-header .brand .brand-text { opacity: 0; width: 0; }
}

/* ---- Área de contenido ---------------------------------------------------- */
.app-main {
  margin-left: var(--sidebar-w); padding: calc(var(--header-h) + 28px) 32px 40px; transition: margin-left .22s ease;
}
.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 4px; }
.page-head .subtitle { color: var(--qro-text-secondary); font-size: 14px; }

/* =============================================================================
   Componentes
   ============================================================================= */

/* ---- Botones -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  border-radius: var(--qro-radius-md); padding: 11px 18px; border: 1px solid transparent;
  transition: background .15s, border-color .15s; min-height: 42px;
}
.btn-primary { background: var(--qro-blue-dark); color: #fff; }
.btn-primary:hover { background: var(--qro-blue); color: #fff; }
.btn-secondary { background: #fff; color: var(--qro-blue-dark); border-color: var(--qro-blue-dark); }
.btn-secondary:hover { background: #f0f5fc; }
.btn-danger { background: var(--qro-red); color: #fff; }
.btn-danger:hover { background: #b53023; }
.btn:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; border-color: transparent; }
.btn-block { width: 100%; }

/* ---- Tarjetas ------------------------------------------------------------- */
.card {
  background: var(--qro-surface); border: 1px solid var(--qro-border);
  border-radius: var(--qro-radius-lg); box-shadow: var(--qro-shadow-sm); padding: 20px;
}
.card + .card { margin-top: 16px; }

/* ---- Grid de KPIs --------------------------------------------------------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.kpi {
  background: var(--qro-surface); border: 1px solid var(--qro-border);
  border-radius: var(--qro-radius-lg); box-shadow: var(--qro-shadow-sm);
  padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between;
}
.kpi .kpi-label { font-size: 12px; color: var(--qro-text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .kpi-value { font-size: 32px; font-weight: 800; color: var(--qro-blue-dark); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .kpi-icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: rgba(0, 117, 201, 0.10); color: var(--qro-blue);
}
.kpi.kpi-warning .kpi-value { color: var(--qro-warning); }
.kpi.kpi-warning .kpi-icon { background: rgba(217,144,0,.12); color: var(--qro-warning); }
.kpi.kpi-danger .kpi-value { color: var(--qro-danger); }
.kpi.kpi-danger .kpi-icon { background: rgba(206,58,43,.1); color: var(--qro-danger); }

/* ---- Formularios ---------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600; color: var(--qro-blue-dark);
  margin-bottom: 6px;
}
.form-group label .req { color: var(--qro-danger); }
.input {
  width: 100%; border: 1px solid var(--qro-border); border-radius: var(--qro-radius-md);
  padding: 12px 14px; font-family: inherit; font-size: 15px; background: #fff; color: var(--qro-text-primary);
}
.input:focus {
  outline: none; border-color: var(--qro-blue);
  box-shadow: 0 0 0 3px rgba(0, 117, 201, 0.22);
}
.field-error { color: var(--qro-danger); font-size: 12px; margin-top: 5px; }

/* ---- Tablas --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--qro-radius-md); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  color: var(--qro-blue-dark); font-weight: 700; background: #eef5fc; text-align: left;
  padding: 12px 14px; white-space: nowrap;
}
.table td { color: var(--qro-text-primary); border-bottom: 1px solid var(--qro-border); padding: 12px 14px; }
.table tbody tr:hover { background: #f8fafd; }

/* ---- Badges --------------------------------------------------------------- */
.badge { border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.badge-success { background: rgba(24,138,91,.12); color: var(--qro-success); }
.badge-info    { background: rgba(0,191,215,.12); color: var(--qro-blue); }
.badge-warning { background: rgba(217,144,0,.14); color: var(--qro-warning); }
.badge-danger  { background: rgba(206,58,43,.1); color: var(--qro-danger); }
.badge-muted   { background: #eef1f6; color: var(--qro-text-muted); }

/* ---- Alertas / flash ------------------------------------------------------ */
.alert { border-radius: var(--qro-radius-md); padding: 12px 16px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }

/* ---- Estado vacío / en construcción --------------------------------------- */
.empty-state {
  text-align: center; padding: 56px 24px; background: var(--qro-surface);
  border: 1px dashed var(--qro-border); border-radius: var(--qro-radius-lg);
}
.empty-state .es-icon {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 18px;
  background: rgba(0,191,215,.1); color: var(--qro-blue); display: grid; place-items: center;
}
.empty-state h3 { color: var(--qro-blue-dark); margin-bottom: 8px; }
.empty-state p { color: var(--qro-text-secondary); max-width: 520px; margin: 0 auto; font-size: 14px; line-height: 1.5; }

/* =============================================================================
   Login
   ============================================================================= */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, var(--qro-blue-dark) 0%, var(--qro-blue) 100%);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 20px;
  box-shadow: var(--qro-shadow-md); padding: 36px 32px;
}
.login-card .login-logo { text-align: center; margin-bottom: 22px; }
.login-card .login-logo .logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 12px;
  background: var(--qro-blue-dark); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 26px;
}
.login-card .login-logo strong { display: block; color: var(--qro-blue-dark); font-size: 17px; font-weight: 800; }
.login-card .login-logo span { font-size: 12px; color: var(--qro-text-muted); }

/* =============================================================================
   Responsive
   ============================================================================= */
/* El botón de menú: en escritorio colapsa el riel; en móvil abre el cajón. */

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .app-sidebar { transform: translateX(-100%); transition: transform .2s; width: 264px; z-index: 60; }
  .app-sidebar.open { transform: translateX(0); width: 264px; box-shadow: 0 0 30px rgba(0,0,0,.4); }
  .app-main { margin-left: 0; padding-left: 18px; padding-right: 18px; }
  .app-header .brand { min-width: auto; }
  .app-header .header-title { display: none; }

  /* Fondo oscuro al abrir el menú. */
  .sidebar-backdrop { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0,0,0,.4); z-index: 55; }
}

/* =============================================================================
   Pantallas "turbo moderno" (scoped a .scr) — dashboard, monitoreo, salud, placas.
   No afecta el resto del admin: todo cuelga de .scr.
   ============================================================================= */
@keyframes scrpulse { 0%{box-shadow:0 0 0 0 rgba(37,224,164,.6)} 70%{box-shadow:0 0 0 10px rgba(37,224,164,0)} 100%{box-shadow:0 0 0 0 rgba(37,224,164,0)} }
@keyframes scrrise { from{opacity:0; transform:translateY(12px)} to{opacity:1; transform:translateY(0)} }

/* ---- Hero de página --------------------------------------------------------- */
.scr-hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 24px 28px; margin-bottom: 22px; color: #fff;
  background: linear-gradient(120deg, #00205C 0%, #004a97 55%, #0075C9 100%);
  box-shadow: 0 22px 46px -24px rgba(0,32,92,.7);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.scr-hero::before { content:''; position:absolute; inset:0; z-index:0; pointer-events:none; opacity:.5;
  background-image: radial-gradient(rgba(255,255,255,.16) 1px, transparent 1.4px); background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(120% 100% at 90% 0%, #000, transparent 70%);
  mask-image: radial-gradient(120% 100% at 90% 0%, #000, transparent 70%); }
.scr-hero > * { position: relative; z-index: 1; }
.scr-hero .hicon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 23px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.26); flex: 0 0 auto; }
.scr-hero .htxt h1 { font-size: clamp(20px,2.6vw,28px); font-weight: 800; letter-spacing: -.02em; color: #fff; margin: 0; line-height: 1.1; }
.scr-hero .htxt p { font-size: 13.5px; color: rgba(255,255,255,.86); margin: 4px 0 0; max-width: 74ch; }
.scr-hero .h-right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.scr-hero .h-live { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28); padding: 8px 14px; border-radius: 999px; }
.scr-hero .h-live .dot { width: 8px; height: 8px; border-radius: 50%; background: #25e0a4; animation: scrpulse 1.9s infinite; }
.scr-hero .h-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.32); color: #fff; border-radius: 12px;
  padding: 10px 16px; font: inherit; font-weight: 700; font-size: 13.5px; transition: background .15s, transform .12s; }
.scr-hero .h-btn:hover { background: rgba(255,255,255,.26); transform: translateY(-1px); }
.scr-hero .h-btn.solid { background: #fff; color: var(--qro-blue-dark); border-color: #fff; }
.scr-hero .h-btn.solid:hover { background: #eef4ff; }
@media (max-width: 640px) { .scr-hero { padding: 20px; } .scr-hero .h-right { margin-left: 0; width: 100%; } }

/* ---- KPIs turbo ------------------------------------------------------------- */
.scr .kpi-grid { gap: 15px; }
.scr .kpi { position: relative; overflow: hidden; border-radius: 18px; padding: 18px 20px 18px 22px;
  box-shadow: 0 12px 28px -20px rgba(37,65,133,.55); transition: transform .18s ease, box-shadow .18s ease;
  animation: scrrise .45s both; }
.scr .kpi:hover { transform: translateY(-4px); box-shadow: 0 20px 36px -18px rgba(37,65,133,.5); }
.scr .kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(var(--qro-blue-light), var(--qro-blue)); }
.scr .kpi.kpi-warning::after { background: var(--qro-warning); }
.scr .kpi.kpi-danger::after { background: var(--qro-danger); }
.scr .kpi .kpi-value { font-size: 34px; letter-spacing: -.01em; }
.scr .kpi .kpi-icon { width: 44px; height: 44px; border-radius: 13px; font-size: 17px;
  box-shadow: 0 8px 18px -8px rgba(0,191,215,.6); }
.scr .kpi.kpi-warning .kpi-icon { box-shadow: 0 8px 18px -8px rgba(217,144,0,.6); }
.scr .kpi.kpi-danger .kpi-icon { box-shadow: 0 8px 18px -8px rgba(206,58,43,.55); }

/* ---- Cards y tablas --------------------------------------------------------- */
.scr .card { border-radius: 18px; box-shadow: 0 12px 28px -20px rgba(37,65,133,.5); }
.scr .table th { background: #f3f7fd; text-transform: uppercase; font-size: 11px; letter-spacing: .05em;
  color: var(--qro-text-secondary); border-bottom: 1px solid var(--qro-border); }
.scr .table tbody tr { transition: background .12s; }
.scr .table tbody tr:hover { background: #f5f9ff; }

/* Barra de sección con acento */
.scr .scr-sec { display: flex; align-items: center; gap: 11px; margin: 26px 0 14px; }
.scr .scr-sec h2 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; color: var(--qro-text-primary);
  display: flex; align-items: center; gap: 11px; }
.scr .scr-sec h2::before { content: ''; width: 5px; height: 22px; border-radius: 3px;
  background: linear-gradient(var(--qro-blue), var(--qro-blue-light)); }
.scr .scr-sec .muted { margin-left: auto; font-size: 12px; color: var(--qro-text-muted); }

@media (prefers-reduced-motion: reduce) {
  .scr .kpi { animation: none; }
  .scr-hero .h-live .dot { animation: none; }
}
