/* =========================================================
   Control Residencial – Estilos Globales
   Ribera de la Laguna VII
   ========================================================= */

/* ── Variables CSS (Design Tokens de Próxima Generación) ───────── */
:root {
  /* Paleta principal de lujo */
  --cr-navy:        #0b1329;
  --cr-blue-dark:   #111c44;
  --cr-blue:        #2563eb;
  --cr-blue-mid:    #3b82f6;
  --cr-blue-light:  #60a5fa;
  --cr-blue-pale:   #eff6ff;
  --cr-green:       #10b981;
  --cr-green-light: #d1fae5;
  --cr-red:         #ef4444;
  --cr-red-light:   #fee2e2;
  --cr-yellow:      #f59e0b;
  --cr-yellow-light:#fef3c7;
  --cr-purple:      #8b5cf6;
  --cr-indigo:      #6366f1;

  /* Neutros */
  --cr-white:       #ffffff;
  --cr-gray-50:     #f8fafc;
  --cr-gray-100:    #f1f5f9;
  --cr-gray-200:    #e2e8f0;
  --cr-gray-300:    #cbd5e1;
  --cr-gray-400:    #94a3b8;
  --cr-gray-500:    #64748b;
  --cr-gray-600:    #475569;
  --cr-gray-700:    #334155;
  --cr-gray-800:    #1e293b;
  --cr-gray-900:    #0f172a;

  /* Layout */
  --sidebar-width:    260px;
  --navbar-height:    66px;
  --sidebar-collapsed: 70px;

  /* Sombras y Brillos Neón */
  --shadow-sm:   0 2px 4px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
  --shadow-md:   0 8px 24px rgba(15,23,42,.08), 0 2px 8px rgba(15,23,42,.04);
  --shadow-lg:   0 16px 40px rgba(15,23,42,.12), 0 4px 16px rgba(15,23,42,.06);
  --shadow-xl:   0 25px 60px rgba(0,0,0,.18);
  --shadow-blue: 0 10px 30px rgba(37,99,235,.25);

  /* Bordes */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-full: 9999px;

  /* Transiciones suavizadas */
  --transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  /* Semánticos (tema claro glass) */
  --bg-app:       #f4f6fb;
  --bg-card:      rgba(255, 255, 255, 0.85);
  --bg-sidebar:   var(--cr-navy);
  --text-primary: #0f172a;
  --text-muted:   #64748b;
  --border-color: rgba(226, 232, 240, 0.8);
}

/* ── Modo Oscuro Lujoso con Glassmorphism ───────────────── */
[data-bs-theme="dark"] {
  --bg-app:       #070a12;
  --bg-card:      rgba(15, 23, 42, 0.75);
  --bg-sidebar:   #030712;
  --text-primary: #f8fafc;
  --text-muted:   #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);
  --cr-gray-100:  #111827;
  --cr-gray-200:  #1f2937;
  --cr-gray-300:  #374151;
  --shadow-md:    0 8px 30px rgba(0,0,0,.5);
  --shadow-lg:    0 20px 50px rgba(0,0,0,.6);
}

/* ── Reset y Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(at 10% 10%, rgba(37, 99, 235, 0.04) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* ── Layout principal ───────────────────────────────────── */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
  padding-top: var(--navbar-height);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px 36px 48px;
  min-height: calc(100vh - var(--navbar-height));
  transition: margin-left var(--transition-slow);
}

/* ── Navbar Superior Traslúcida Glass ───────────────────── */
.navbar-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-height);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 calc(var(--sidebar-width) + 24px);
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.03);
  transition: padding-left var(--transition-slow), background var(--transition-slow);
}

.navbar-top-left,
.navbar-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--cr-blue);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Botón menú hamburguesa */
.btn-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.btn-menu-toggle:hover { background: var(--cr-gray-100); }

.btn-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* Botones icono navbar */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--cr-gray-100);
  color: var(--cr-blue);
}

/* Badge notificaciones */
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--cr-red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Avatar de usuario */
.btn-avatar {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-full);
}

.avatar-img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--cr-blue-light);
}

.avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--cr-blue-mid), var(--cr-purple));
  color: white;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cr-blue-light);
}

/* Dropdown de usuario */
.user-dropdown {
  min-width: 200px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.user-info {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-info strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-info span {
  font-size: 11px;
  color: var(--text-muted);
}

/* Dropdown de notificaciones */
.notif-dropdown {
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 13px;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  cursor: pointer;
}

.notif-item:hover { background: var(--cr-gray-50); }
.notif-item.no-leida { background: var(--cr-blue-pale); }
.notif-item-titulo { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.notif-item-msg { font-size: 11px; color: var(--text-muted); }
.notif-item-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--cr-navy);
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transition: transform var(--transition-slow), width var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* Header del sidebar */
.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--cr-blue-mid), var(--cr-blue-light));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,130,246,.4);
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-title {
  font-size: 15px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-residencial {
  font-size: 10px;
  color: rgba(255,255,255,.45);
  padding: 4px 0 0;
}

/* Perfil en sidebar */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-avatar,
.sidebar-avatar-placeholder {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidebar-avatar { object-fit: cover; border: 2px solid rgba(255,255,255,.2); }

.sidebar-avatar-placeholder {
  background: linear-gradient(135deg, var(--cr-blue-mid), var(--cr-purple));
  color: white;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-role-admin     { color: #fbbf24 !important; }
.badge-role-residente { color: #34d399 !important; }
.badge-role-guardia   { color: #60a5fa !important; }

/* Navegación del sidebar */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(37,99,235,.35), rgba(59,130,246,.2));
  color: #93c5fd;
  font-weight: 600;
}

.sidebar-link-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-active-indicator {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--cr-blue-light);
  border-radius: 2px 0 0 2px;
}

/* Footer sidebar */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,100,100,.8);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.sidebar-logout:hover {
  background: rgba(239,68,68,.15);
  color: #f87171;
}

.sidebar-version {
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,.2);
  margin-top: 8px;
}

/* Overlay móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1050;
  backdrop-filter: blur(2px);
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Tarjetas (Cards) con Glassmorphism y Sombras Ambientales ────── */
.cr-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-slow), transform var(--transition-slow), border-color var(--transition);
  overflow: hidden;
  position: relative;
}

.cr-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cr-blue-light), transparent);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.cr-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
}

.cr-card:hover::after {
  opacity: 1;
}

.cr-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.cr-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.2px;
}

.cr-card-body { padding: 20px; }

/* ── Stat Cards Luminosas ───────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--stat-color, var(--cr-blue));
  border-radius: 4px 0 0 4px;
}

.stat-card:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12), 0 0 20px var(--stat-bg);
  transform: translateY(-3px) scale(1.01);
  border-color: var(--stat-color);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--stat-bg, var(--cr-blue-pale));
  color: var(--stat-color, var(--cr-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--stat-bg);
  transition: transform var(--transition);
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(4deg);
}

.stat-info { flex: 1; min-width: 0; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-change {
  font-size: 11px;
  margin-top: 4px;
}

.stat-change.up   { color: var(--cr-green); }
.stat-change.down { color: var(--cr-red); }

/* Variantes de color para stat cards */
.stat-blue   { --stat-color: #3b82f6; --stat-bg: #eff6ff; }
.stat-green  { --stat-color: #10b981; --stat-bg: #d1fae5; }
.stat-red    { --stat-color: #ef4444; --stat-bg: #fee2e2; }
.stat-yellow { --stat-color: #f59e0b; --stat-bg: #fef3c7; }
.stat-purple { --stat-color: #8b5cf6; --stat-bg: #f5f3ff; }
.stat-navy   { --stat-color: #1e3a5f; --stat-bg: #e0eaff; }
.stat-teal   { --stat-color: #14b8a6; --stat-bg: #ccfbf1; }
.stat-orange { --stat-color: #f97316; --stat-bg: #ffedd5; }

/* ── Botones personalizados ─────────────────────────────── */
.btn-cr {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-cr-primary {
  background: linear-gradient(135deg, var(--cr-blue-mid), var(--cr-blue-light));
  color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.btn-cr-primary:hover {
  background: linear-gradient(135deg, var(--cr-blue), var(--cr-blue-mid));
  box-shadow: 0 6px 20px rgba(37,99,235,.4);
  transform: translateY(-1px);
  color: white;
}

.btn-cr-success {
  background: linear-gradient(135deg, #059669, var(--cr-green));
  color: white;
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
}

.btn-cr-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16,185,129,.4);
  color: white;
}

.btn-cr-danger {
  background: linear-gradient(135deg, #dc2626, var(--cr-red));
  color: white;
  box-shadow: 0 4px 12px rgba(239,68,68,.3);
}

.btn-cr-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239,68,68,.4);
  color: white;
}

.btn-cr-outline {
  background: transparent;
  color: var(--cr-blue-mid);
  border: 1.5px solid var(--cr-blue-mid);
}

.btn-cr-outline:hover {
  background: var(--cr-blue-pale);
  color: var(--cr-blue);
}

/* ── Tablas ─────────────────────────────────────────────── */
.table-cr {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-cr thead th {
  background: var(--cr-gray-50);
  color: var(--cr-gray-600);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

[data-bs-theme="dark"] .table-cr thead th {
  background: var(--cr-gray-200);
  color: var(--text-muted);
}

.table-cr tbody tr {
  transition: background var(--transition);
}

.table-cr tbody tr:hover {
  background: var(--cr-gray-50);
}

[data-bs-theme="dark"] .table-cr tbody tr:hover {
  background: var(--cr-gray-200);
}

.table-cr tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text-primary);
}

/* ── Formularios ────────────────────────────────────────── */
.form-cr .form-control,
.form-cr .form-select {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13.5px;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all var(--transition);
}

.form-cr .form-control:focus,
.form-cr .form-select:focus {
  border-color: var(--cr-blue-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  outline: none;
}

.form-cr .form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cr-gray-600);
  margin-bottom: 5px;
}

/* ── Zona de subida de fotos (Dropzone) ─────────────────── */
.foto-upload-zone {
  border: 2px dashed var(--cr-blue-light);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  background: var(--cr-blue-pale);
  cursor: pointer;
  transition: all var(--transition);
  display: block;
}

[data-bs-theme="dark"] .foto-upload-zone {
  background: rgba(59, 130, 246, 0.08);
  border-color: #3b82f6;
}

.foto-upload-zone:hover,
.foto-upload-zone.drag-over {
  border-color: var(--cr-blue-mid);
  background: #dbeafe;
}

[data-bs-theme="dark"] .foto-upload-zone:hover,
[data-bs-theme="dark"] .foto-upload-zone.drag-over {
  background: rgba(59, 130, 246, 0.18);
}

.foto-upload-zone * {
  pointer-events: none;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge-cr {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ── Foto de visitante (scanner) ────────────────────────── */
.foto-visitante {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 4px solid var(--cr-blue-light);
  box-shadow: var(--shadow-md);
}

/* ── QR Preview ─────────────────────────────────────────── */
.qr-preview {
  background: white;
  padding: 16px;
  border-radius: var(--radius-md);
  display: inline-block;
  box-shadow: var(--shadow-md);
}

.qr-preview img {
  max-width: 200px;
  display: block;
}

/* ── Scanner de QR ──────────────────────────────────────── */
#reader {
  width: 100%;
  max-width: 450px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px dashed var(--cr-blue-light);
}

/* ── Panel resultado scanner ────────────────────────────── */
.scan-result-card {
  border-radius: var(--radius-xl);
  border: none;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.scan-result-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.scan-result-foto {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 3px solid rgba(255,255,255,.5);
}

.scan-result-info h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.scan-result-info p {
  font-size: 13px;
  margin: 4px 0 0;
  opacity: .8;
}

/* ── Solicitudes guardia (tiempo real) ──────────────────── */
.solicitud-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 16px 18px;
  transition: all var(--transition);
  animation: slideInCard .3s ease;
  position: relative;
  overflow: hidden;
}

.solicitud-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
}

.solicitud-card.nueva { animation: pulseCard .6s ease 3; }
.solicitud-card.tipo-invitado::before   { background: var(--cr-blue); }
.solicitud-card.tipo-repartidor::before { background: var(--cr-yellow); }
.solicitud-card.tipo-proveedor::before  { background: var(--cr-purple); }
.solicitud-card.tipo-empleado::before   { background: var(--cr-green); }

@keyframes slideInCard {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulseCard {
  0%, 100% { box-shadow: var(--shadow-sm); }
  50%       { box-shadow: 0 0 0 4px rgba(59,130,246,.3), var(--shadow-md); }
}

/* ── Avatares en tabla ──────────────────────────────────── */
.table-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.table-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--cr-blue-mid), var(--cr-purple));
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  background: var(--bg-card);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 18px 24px;
}

.modal-title {
  font-weight: 700;
  font-size: 16px;
}

.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 14px 24px; }

/* ── Zona upload de foto ────────────────────────────────── */
.foto-upload-zone {
  border: 2px dashed var(--cr-gray-300);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--cr-gray-50);
}

.foto-upload-zone:hover {
  border-color: var(--cr-blue-light);
  background: var(--cr-blue-pale);
}

.foto-upload-zone.drag-over {
  border-color: var(--cr-blue);
  background: var(--cr-blue-pale);
  transform: scale(1.01);
}

.foto-preview-container {
  position: relative;
  display: inline-block;
}

.foto-preview {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 3px solid var(--cr-blue-light);
}

/* ── Loading / Skeleton ─────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--cr-gray-100) 25%, var(--cr-gray-200) 50%, var(--cr-gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Alertas y estados ──────────────────────────────────── */
.alert-cr {
  border-radius: var(--radius-md);
  border: none;
  padding: 14px 18px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Paginación DataTables ──────────────────────────────── */
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--cr-blue-mid) !important;
  color: white !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
}

/* ── Charts ─────────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 260px;
}

/* ── Login page ─────────────────────────────────────────── */
body.login-page {
  background: linear-gradient(135deg, var(--cr-navy) 0%, var(--cr-blue-dark) 50%, var(--cr-blue) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.login-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-box {
  background: rgba(255,255,255,.97);
  border-radius: var(--radius-xl);
  padding: 40px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.4);
  position: relative;
  z-index: 1;
  animation: loginFadeIn .5s ease;
}

[data-bs-theme="dark"] .login-box {
  background: rgba(22,27,34,.97);
  border: 1px solid var(--border-color);
}

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

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--cr-blue-mid), var(--cr-blue-light));
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(37,99,235,.4);
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--cr-navy);
  margin: 0;
  letter-spacing: -0.5px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ── Responsive Avanzado para Celulares y Tablets ───────────────────── */

/* Tablets y pantallas medianas (<= 991px) */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
    z-index: 1050;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
  }

  .navbar-top {
    padding-left: 16px;
    padding-right: 16px;
  }

  .btn-menu-toggle {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px 32px;
  }

  .brand-sub { display: none; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }

  .page-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-actions .btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }
}

/* Celulares grandes y Tablets pequeñas (<= 767.98px) */
@media (max-width: 767.98px) {
  html { font-size: 14px; }

  .navbar-top-left .brand-name {
    font-size: 15px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .navbar-top-right {
    gap: 8px;
  }

  .btn-icon, .btn-avatar {
    width: 40px;
    height: 40px;
  }

  /* Grid de Estadísticas en Móvil: 2 columnas compactas */
  .grid-stats, .row-cols-mobile-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .stat-card {
    padding: 12px 14px;
    gap: 10px;
    border-radius: var(--radius-md);
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 16px;
    border-radius: var(--radius-md);
  }

  .stat-value {
    font-size: 20px;
    font-weight: 800;
  }

  .stat-label {
    font-size: 11px;
    line-height: 1.2;
  }

  /* Tablas adaptables */
  .table-responsive {
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
  }

  .table th, .table td {
    padding: 10px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* DataTables en móvil */
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length {
    float: none !important;
    text-align: left !important;
    margin-bottom: 12px;
    width: 100%;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
    min-height: 42px;
  }

  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: center !important;
    margin-top: 14px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Formularios e inputs táctiles */
  .form-control, .form-select {
    font-size: 16px !important; /* Previene auto-zoom en iPhone */
    min-height: 44px;
    border-radius: var(--radius-md);
  }

  .btn {
    min-height: 44px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Modales estilo Bottom-Sheet en móvil */
  .modal-dialog {
    margin: 10px;
  }

  .modal-content {
    border-radius: var(--radius-lg);
  }
}

/* Celulares pequeños (<= 575.98px) */
@media (max-width: 575.98px) {
  .main-content {
    padding: 14px 10px 24px;
  }

  .page-title {
    font-size: 18px;
  }

  .page-subtitle {
    font-size: 12px;
  }

  .card-custom {
    border-radius: var(--radius-md);
    padding: 14px !important;
  }

  .card-header-custom {
    padding: 12px 14px;
  }

  /* Visor de escáner en móvil */
  #interactive.viewport video, #reader video {
    width: 100% !important;
    height: auto !important;
    max-height: 320px;
    border-radius: var(--radius-md);
    object-fit: cover;
  }

  /* Imagen QR en modales */
  .qr-modal-img {
    max-width: 200px !important;
    height: auto !important;
  }

  /* Botones de acción desplegados a ancho completo */
  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0 !important;
  }

  .login-box {
    padding: 24px 18px;
    border-radius: var(--radius-lg);
  }
}

/* ── Animaciones generales ──────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

.fade-in  { animation: fadeIn .3s ease; }
.slide-up { animation: slideUp .3s ease; }

/* ── DataTables personalizado ───────────────────────────── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--text-primary);
}

.dataTables_wrapper .dataTables_info {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Elementos Innovadores y Micro-Animaciones ───────────────────── */

/* Punto vivo latente (Live Pulse Dot) */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
  margin-right: 6px;
  vertical-align: middle;
}

.pulse-dot-amber {
  background-color: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulseAmber 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulseAmber {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Botón con Destello Luminoso al Pasar el Mouse */
.btn-primary, .btn-success, .btn-cr-primary {
  position: relative;
  overflow: hidden;
}

.btn-primary::after, .btn-success::after, .btn-cr-primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: rotate(30deg);
  transition: all 0.6s ease;
  pointer-events: none;
}

.btn-primary:hover::after, .btn-success:hover::after, .btn-cr-primary:hover::after {
  left: 100%;
}

/* Badges con Brillo sutil */
.badge-glow-green {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #10b981 !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.badge-glow-blue {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #3b82f6 !important;
  border: 1px solid rgba(59, 130, 246, 0.3) !important;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

/* ── Utilities ──────────────────────────────────────────── */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.cursor-pointer { cursor: pointer; }

/* ── SweetAlert personalizado ───────────────────────────── */
.swal2-popup {
  border-radius: var(--radius-lg) !important;
  font-family: 'Inter', sans-serif !important;
}

.swal2-title { font-size: 18px !important; font-weight: 700 !important; }
.swal2-html-container { font-size: 14px !important; }

/* ── Scrollbar global ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cr-gray-300); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--cr-gray-400); }
