@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

:root {
  --primary: #050505;
  --secondary: #1c120b;
  --accent: #f47a22;
  --accent-dark: #c95712;
  --gold: #f3b84a;
  --cream: #fff7ec;
  --wine: #7a1f2b;

  --bg: #f4f7fb;
  --card: #ffffff;

  --text: #1f2937;
  --text-light: #6b7280;

  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  font-family: 'Poppins', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-top: 86px;
  background: var(--bg);
  color: var(--text);
}

/* =====================================
   NAVBAR
===================================== */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1050;
  background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
  box-shadow: var(--shadow);
  padding: 14px 22px 24px;
  border-bottom: 3px solid var(--accent);
}

.navbar-logo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

/* =====================================
   SIDEBAR
===================================== */

.sidebar-mobile {
  background: linear-gradient(180deg, var(--primary), #17110d);
  box-shadow: var(--shadow);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-desktop {
  width: 250px;
  min-width: 250px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.3s;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85) !important;
}

.nav-link i {
  font-size: 18px;
}

.nav-link:hover {
  background: rgba(244, 122, 34, 0.18);
  color: white !important;
  padding-left: 22px;
  transform: translateX(4px);
}

.offcanvas {
  background: linear-gradient(180deg, var(--primary), #17110d);
  width: 260px;
}

/* =====================================
   LAYOUT
===================================== */

.main-content {
  width: 100%;
  display: flex;
  flex-direction: column;
}

#dashboard {
  order: 10;
}

#dashboard_graficos {
  order: 20;
}

#modulo_asistencia {
  order: 30;
}

#asistencias {
  order: 40;
}

#eventos {
  order: 50;
}

#modulo_personas {
  order: 60;
}

#modulo_pagos {
  order: 70;
}

#finanzas {
  order: 80;
}

#multas {
  order: 90;
}

@media (min-width: 992px) {
  .sidebar-desktop {
    position: fixed;
    top: 86px;
    left: 0;
    width: 260px;
    height: calc(100vh - 86px);
    overflow-y: auto;
    z-index: 1040;
  }

  .main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
  }
}

@media (max-width: 991.98px) {
  body {
    padding-top: 74px;
  }

  .main-content {
    width: 100%;
  }
}

/* =====================================
   MODULOS Y CARDS
===================================== */

.module-section {
  background: white;
  padding: 35px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 35px;
}

.module-section h2 {
  display: flex;
  align-items: center;
  gap: 12px;
}

.module-section + .module-section {
  margin-top: 40px;
}

.card {
  border: none;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: 0.3s;
  cursor: default;
}

.card:hover {
  transform: translateY(-3px);
}

.card-body {
  padding: 24px;
}

.card-body h2 {
  font-size: 38px;
  font-weight: 700;
  margin-top: 12px;
}

.card-title {
  font-size: 15px;
  opacity: 0.85;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-grid > [class*="col-"] {
  width: auto;
  max-width: none;
  padding: 0;
}

.dashboard-grid .card {
  height: 100%;
  min-height: 124px;
}

.dashboard-grid .card-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 124px;
  padding: 18px;
}

.dashboard-grid .card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 2.3em;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.dashboard-grid .card-body h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.dashboard-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.attendance-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.attendance-stat {
  background: white;
  border-left: 5px solid var(--accent);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.attendance-stat > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.attendance-stat-label {
  color: var(--text-light);
  font-weight: 600;
}

.attendance-stat strong {
  color: var(--primary);
  font-size: 1.8rem;
  line-height: 1;
}

.attendance-stat small {
  color: var(--text-light);
}

.dashboard-chart-grid > [class*="col-"] {
  width: auto;
  max-width: none;
  padding: 0;
  margin: 0 !important;
}

h2 {
  font-size: 34px;
  font-weight: 700;
  color: #1d130c;
  margin-bottom: 28px;
}

/* =====================================
   GRAFICOS
===================================== */

.chart-container {
  position: relative;
  min-height: 320px;
}

canvas {
  max-width: 100% !important;
}

/* =====================================
   TABLAS
===================================== */

.table {
  background: white;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 0;
}

.table thead {
  background: var(--primary);
  color: white;
}

.table tbody tr {
  transition: 0.2s;
}

.table tbody tr:hover {
  background: rgba(244, 122, 34, 0.07);
}

.table td,
.table th {
  border-color: rgba(0, 0, 0, 0.05);
}

.table-responsive {
  border-radius: 18px;
  overflow-x: auto;
}

/* =====================================
   FORMULARIOS Y BOTONES
===================================== */

.form-control,
.form-select {
  border-radius: 14px;
  min-height: 48px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(244, 122, 34, 0.15);
}

.btn {
  border-radius: 12px;
  font-weight: 500;
  transition: 0.25s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary,
.btn-success {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.btn-primary:hover,
.btn-success:hover {
  background-color: var(--accent-dark) !important;
  border-color: var(--accent-dark) !important;
}

.qr-attendance-panel {
  background: #f8fafc;
  border: 1px solid rgba(47, 128, 237, 0.18);
  border-radius: 18px;
  padding: 18px;
}

.qr-attendance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.qr-scanner-wrapper {
  position: relative;
  background: #0f172a;
  border-radius: 16px;
  margin-top: 16px;
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.qr-scanner-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scanner-wrapper::after {
  content: '';
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  box-shadow:
    0 0 0 999px rgba(15, 23, 42, 0.18),
    0 0 22px rgba(244, 122, 34, 0.28);
  pointer-events: none;
}

.qr-attendance-status {
  font-size: 0.95rem;
}

/* =====================================
   Logo cliente configurado
===================================== */

.cliente-logo,
img[data-config-img="cliente.logo"] {
  width: 44px;
  height: 44px;
  max-width: 44px;
  max-height: 44px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  flex: 0 0 auto;
}

/* =====================================
   FOOTER
===================================== */

.app-footer {
  background: var(--primary);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

/* =====================================
   RESPONSIVE
===================================== */

/* =====================================
   PESTAÑAS PRINCIPALES
===================================== */

.app-tabs-wrapper {
  position: sticky;
  top: 86px;
  z-index: 1000;
  background: white;
  border-bottom: 2px solid rgba(0,0,0,0.07);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  padding-top: 16px;
}

@media (max-width: 991.98px) {
  .app-tabs-wrapper {
    top: 74px;
    padding-top: 20px;
  }
}

.app-tabs {
  border-bottom: none;
  padding: 8px 16px 0;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.app-tabs::-webkit-scrollbar {
  display: none;
}

.app-tabs .nav-link {
  color: #000 !important;
  background: var(--accent);
  border-radius: 10px 10px 0 0;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--accent-dark);
  border-bottom: none;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  transform: none !important;
}

.app-tabs .nav-link:hover {
  color: var(--accent) !important;
  background: #000 !important;
  padding-left: 16px !important;
  border-color: #000;
}

.app-tabs .nav-link.active {
  color: var(--accent) !important;
  background: #000 !important;
  border-color: #000;
  font-weight: 700;
}

.app-tabs .nav-link i {
  font-size: 15px;
}

@media (max-width: 420px) {
  .tab-label { display: none; }
  .app-tabs .nav-link { padding: 10px 13px; }
}

.app-tab-content {
  padding: 24px 16px 48px;
}

@media (min-width: 768px) {
  .app-tab-content { padding: 32px 28px 60px; }
}

/* =====================================
   SUB-TABS (pills)
===================================== */

.subtabs {
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.subtabs .nav-link {
  color: var(--text) !important;
  background: rgba(0,0,0,0.05);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.84rem;
  font-weight: 500;
  border: none;
  transform: none !important;
  transition: 0.2s;
}

.subtabs .nav-link:hover {
  background: rgba(244, 122, 34, 0.14);
  color: var(--accent) !important;
  padding-left: 16px !important;
}

.subtabs .nav-link.active {
  background: var(--accent) !important;
  color: white !important;
}

/* =====================================
   TABLAS CON SCROLL LIMITADO
===================================== */

.tabla-scroll {
  max-height: 460px;
  overflow-y: auto;
  border-radius: 18px;
}

.tabla-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Fila separadora de bloque */
.tabla-bloque-header td {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.5px;
  padding: 8px 12px;
}

/* =====================================
   MÓDULO ASISTENCIA — SCAN-IT STYLE
===================================== */

/* Asistencia ocupa todo el espacio disponible sin padding del tab */
#tab_asistencia {
  padding: 0 !important;
}

.scanner-centrado {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 74px - 52px); /* móvil: navbar + tabs */
}

@media (min-width: 992px) {
  .scanner-centrado {
    min-height: calc(100vh - 86px - 52px); /* escritorio: navbar + tabs */
  }
}

.scanner-centrado > .mb-3 {
  padding: 16px 16px 0;
}

.scanner-panel {
  background: #16213e;
  border-radius: 0;
  padding: 16px;
  color: white;
  flex: 1;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .scanner-centrado > .mb-3 {
    padding: 20px 28px 0;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  .scanner-panel {
    padding: 20px 28px 28px;
    align-items: center;
  }

  .scanner-panel > * {
    width: 100%;
    max-width: 520px;
  }
}

/* Botón selector de evento (móvil) */
.btn-evento-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: #0f3460;
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  text-align: left;
}

.btn-evento-selector:hover,
.btn-evento-selector:focus {
  background: #1a4a80;
  outline: none;
}

.btn-evento-selector > i:first-child {
  color: var(--accent);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Video wrapper */
.scanner-video-wrapper {
  position: relative;
  background: #0a0a1a;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  width: 100%;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.scanner-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2); /* coincide con QR_ZOOM_CROP 0.5 — lo que se ve = lo que se escanea */
  transform-origin: center;
}

/* Marco de enfoque */
.scanner-video-wrapper::before {
  content: '';
  position: absolute;
  inset: 12%;
  border: 2px solid rgba(255,255,255,0.65);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.28);
  pointer-events: none;
  z-index: 1;
}

/* Línea roja animada */
.scanner-line {
  position: absolute;
  left: 12%;
  right: 12%;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239,68,68,0.9), 0 0 20px rgba(239,68,68,0.4);
  animation: scanLine 2s ease-in-out infinite;
  border-radius: 2px;
  z-index: 2;
}

@keyframes scanLine {
  0%, 100% { top: 14%; }
  50%       { top: 83%; }
}

/* Status text */
.scanner-status {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.7);
  min-height: 1.4em;
  margin-bottom: 14px;
}

/* Botones scan/stop */
.scanner-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-scan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: 0.2s;
  width: 100%;
}

.btn-scan:hover:not(:disabled) { background: var(--accent-dark); }

.btn-scan:disabled {
  background: #3a3a5c;
  cursor: not-allowed;
  color: rgba(255,255,255,0.45);
}

.btn-stop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  width: 100%;
}

.btn-stop:hover { background: rgba(255,255,255,0.18); }

/* Input manual */
.manual-input .form-control {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: white;
  border-radius: 12px 0 0 12px;
  min-height: 50px;
  font-size: 1rem;
}

.manual-input .form-control::placeholder { color: rgba(255,255,255,0.38); }

.manual-input .form-control:focus {
  background: rgba(255,255,255,0.13);
  border-color: var(--accent);
  color: white;
  box-shadow: none;
}

.btn-accent {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0 22px;
  border-radius: 0 12px 12px 0;
  font-size: 1.1rem;
  min-height: 50px;
  cursor: pointer;
  transition: 0.2s;
}

.btn-accent:hover { background: var(--accent-dark); color: white; }

/* Modal eventos */
.modal-eventos-content { border-radius: 20px; overflow: hidden; }

.modal-eventos-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
}

#lista_eventos_modal .btn-evento-item {
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 500;
  text-align: left;
  color: var(--text);
  transition: 0.2s;
}

#lista_eventos_modal .btn-evento-item:hover {
  background: rgba(244,122,34,0.08);
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .sidebar-mobile {
    min-height: auto !important;
    padding: 15px !important;
  }

  .btn-mobile-full {
    width: 100%;
  }

  .card-body h2 {
    font-size: 28px;
  }

  .main-content {
    width: 100% !important;
    margin-left: 0 !important;
    padding: 18px !important;
  }

  .module-section {
    padding: 20px;
    border-radius: 20px;
  }

  h2 {
    font-size: 28px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .dashboard-grid .card {
    min-height: 104px;
    border-radius: 16px;
  }

  .dashboard-grid .card-body {
    min-height: 104px;
    padding: 14px;
  }

  .dashboard-grid .card-title {
    min-height: 2.4em;
    font-size: 0.72rem;
  }

  .dashboard-grid .card-body h2 {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
  }

  .dashboard-chart-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .attendance-stat-grid {
    grid-template-columns: 1fr;
  }

  .chart-container {
    min-height: 280px;
  }

  .table {
    font-size: 0.86rem;
  }

  .table td,
  .table th {
    padding: 0.6rem 0.7rem;
  }

  .table .btn-group-sm .btn {
    min-width: 2rem;
    min-height: 1.9rem;
  }

  /* =====================================
   Logo cliente configurado
  ===================================== */

  .cliente-logo,
  img[data-config-img="cliente.logo"] {
    width: 34px;
    height: 34px;
    max-width: 34px;
    max-height: 34px;
  }

}

/* ── Reloj en vivo ── */
.scanner-reloj {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem 0.25rem;
  color: var(--accent);
}
#reloj_hora {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}
#reloj_fecha {
  font-size: 0.8rem;
  opacity: 0.75;
  text-transform: capitalize;
  margin-top: 0.15rem;
}

/* ── Últimos registros de asistencia ── */
.ultimos-registros-wrapper {
  margin: 1rem 1rem 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 0.75rem;
}
.ultimos-registros-titulo {
  color: rgba(255,255,255,0.5);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.ultimos-registros-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.ultimos-registros-tabla td {
  padding: 4px 6px;
  color: rgba(255,255,255,0.85);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ultimos-registros-tabla td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* ── Logo institucional en panel scanner ── */
.scanner-logo-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}
.scanner-logo-img {
  width: min(180px, 45vw);
  border-radius: 50%;
  opacity: 0.18;
  pointer-events: none;
  user-select: none;
}

