/* ═══════════════════════════════════════════════
   Control de Acceso – Custom Styles
   ═══════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────── */
:root {
  --sidebar-w: 230px;
  --topbar-h: 60px;
  --brand-bg: #0f172a;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #3b82f6;
  --sidebar-text: #94a3b8;
  --topbar-bg: #ffffff;
  --main-bg: #f1f5f9;
  --primary: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --transition: 0.2s ease;
}

/* ── Reset & base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; }

/* ═══════════════════════════════════════════════
   ADMIN PANEL LAYOUT
   ═══════════════════════════════════════════════ */

.admin-body { background: var(--main-bg); }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  transition: transform var(--transition);
  z-index: 1040;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  background: var(--brand-bg);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  border-bottom: 1px solid #0f172a;
}
.sidebar-brand .fas { color: #3b82f6; font-size: 1.2rem; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: #475569;
  padding: 14px 20px 6px;
  list-style: none;
  text-transform: uppercase;
}

.sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 10px 20px;
  border-radius: 8px;
  margin: 2px 8px;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}
.sidebar .nav-link .fas { width: 18px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid #334155;
  padding: 10px 8px;
}
.sidebar-footer .nav-link {
  font-size: .84rem;
  padding: 8px 14px;
  color: var(--sidebar-text) !important;
}
.sidebar-footer .nav-link.text-danger {
  color: #f87171 !important;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: #1e293b; }
.btn-topbar {
  background: transparent;
  border: 1px solid #e2e8f0;
  color: #64748b;
  padding: 5px 10px;
}

/* Main content */
.main-bg { background: var(--main-bg); }

/* Mobile sidebar */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
}

/* ── Cards ──────────────────────────────────────── */
.stat-card {
  border: none;
  border-radius: 14px;
  padding: 22px 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  position: absolute; right: 20px; top: 50%;
  transform: translateY(-50%);
  font-size: 2.8rem;
  opacity: .18;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .82rem; opacity: .8; margin-top: 6px; }
.stat-card.blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-card.green  { background: linear-gradient(135deg, #22c55e, #15803d); }
.stat-card.red    { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.stat-card.purple { background: linear-gradient(135deg, #a855f7, #7e22ce); }

.card { border: none; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.card-header { background: #fff; border-bottom: 1px solid #f1f5f9; font-weight: 600; padding: 16px 20px; }

/* ── Tables ──────────────────────────────────────── */
.table-custom thead th {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  border-bottom: 2px solid #f1f5f9;
  padding: 12px 16px;
}
.table-custom td { padding: 12px 16px; vertical-align: middle; }
.table-custom tbody tr:hover { background: #f8fafc; }

/* Avatares */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
}
.avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
}
.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  color: #94a3b8;
  font-weight: 700;
  font-size: .85rem;
}

/* Badges */
.badge-entrada      { background: #dcfce7; color: #15803d; }
.badge-salida       { background: #fee2e2; color: #b91c1c; }
.badge-pausa_inicio { background: #fef3c7; color: #b45309; }
.badge-pausa_fin    { background: #dbeafe; color: #1d4ed8; }

/* ── Face capture thumbnails ─────────────────────── */
.face-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.face-thumb {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #22c55e;
  animation: thumbIn .3s ease;
}
.face-thumb img { width: 100%; height: 100%; object-fit: cover; }
.face-thumb .thumb-num {
  position: absolute; bottom: 2px; right: 4px;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: .65rem;
  padding: 0 4px;
  border-radius: 4px;
}
@keyframes thumbIn {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* ── Login page ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 25px 60px rgba(0,0,0,.4);
}
.login-logo { font-size: 2.8rem; color: #3b82f6; margin-bottom: 8px; }
.login-title { color: #fff; font-weight: 700; font-size: 1.5rem; }
.login-sub   { color: #94a3b8; font-size: .9rem; }
.login-card .form-label { color: #cbd5e1; font-size: .85rem; }
.login-card .form-control {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
}
.login-card .form-control::placeholder { color: #475569; }
.login-card .form-control:focus {
  background: rgba(255,255,255,.12);
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
  color: #fff;
}

/* ═══════════════════════════════════════════════
   KIOSCO / TABLET
   ═══════════════════════════════════════════════ */
.kiosk-body {
  background: #0a0f1e;
  min-height: 100vh;
  color: #e2e8f0;
  overflow: hidden;
}
.kiosk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.kiosk-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #e2e8f0;
}
.kiosk-brand .fas { color: #3b82f6; }
.kiosk-clock { font-size: 1.6rem; font-weight: 300; letter-spacing: .05em; color: #94a3b8; }
.kiosk-date  { font-size: .8rem; color: #475569; text-align: right; }

/* Camera area */
.camera-wrapper {
  position: relative;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(59,130,246,.3), 0 20px 60px rgba(0,0,0,.6);
  background: #000;
  aspect-ratio: 4/3;
}
.camera-wrapper.scanning { box-shadow: 0 0 0 3px rgba(59,130,246,.5), 0 20px 60px rgba(0,0,0,.6); }
.camera-wrapper.detected { box-shadow: 0 0 0 3px rgba(34,197,94,.7), 0 20px 60px rgba(0,0,0,.6); animation: pulseGreen 1s ease infinite; }
.camera-wrapper.denied   { box-shadow: 0 0 0 3px rgba(239,68,68,.7), 0 20px 60px rgba(0,0,0,.6); }

@keyframes pulseGreen {
  0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.7), 0 20px 60px rgba(0,0,0,.6); }
  50%     { box-shadow: 0 0 0 8px rgba(34,197,94,.3), 0 20px 60px rgba(0,0,0,.6); }
}

#kioskVideo, #kioskCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
#kioskCanvas { pointer-events: none; }

/* Status bar */
.kiosk-status {
  text-align: center;
  margin-top: 20px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1rem;
  color: #64748b;
  transition: all .3s ease;
}
.kiosk-status .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  animation: blink 1.4s ease infinite;
}
.kiosk-status.scanning .dot { background: #3b82f6; }
.kiosk-status.detected .dot { background: #22c55e; animation: none; }
.kiosk-status.denied   .dot { background: #ef4444; animation: none; }
.kiosk-status.cooldown .dot { background: #f59e0b; animation: none; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Overlay sobre la cámara (selección + confirmación) ── */
#resultCard {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 28, 0.90);
  backdrop-filter: blur(6px);
  animation: overlayIn .25s ease;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Confirmación de acceso registrado */
.kiosk-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  text-align: center;
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.result-photo {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--res-color, #22c55e);
  box-shadow: 0 0 24px var(--res-color, #22c55e);
}
.result-name  { font-size: 1.3rem; font-weight: 700; color: #f1f5f9; }
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .95rem;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 30px;
}
.result-badge.entrada      { background: rgba(34,197,94,.2);  color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.result-badge.salida       { background: rgba(239,68,68,.2);   color: #f87171; border: 1px solid rgba(239,68,68,.3); }
.result-badge.pausa_inicio { background: rgba(245,158,11,.2);  color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }
.result-badge.pausa_fin    { background: rgba(59,130,246,.2);  color: #60a5fa; border: 1px solid rgba(59,130,246,.3); }
.result-time { font-size: .82rem; color: #64748b; }

/* Loading overlay */
.kiosk-loading {
  position: fixed; inset: 0;
  background: #0a0f1e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
  transition: opacity .5s ease;
}
.kiosk-loading.hidden { opacity: 0; pointer-events: none; }
.kiosk-loading .spinner {
  width: 50px; height: 50px;
  border: 4px solid rgba(59,130,246,.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.kiosk-loading .load-msg { color: #64748b; font-size: .9rem; }

/* Admin link on kiosk */
.kiosk-admin-link {
  position: fixed;
  bottom: 16px; right: 16px;
  opacity: .2;
  transition: opacity .3s;
  z-index: 10;
}
.kiosk-admin-link:hover { opacity: .6; }

/* ── Tarjeta de selección entrada/salida ─────────── */
.kiosk-select {
  width: 100%;
  max-width: 440px;
  padding: 20px 24px 16px;
  text-align: center;
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
.select-photo {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,.3);
  margin-bottom: 8px;
}
.select-name  { font-size: 1.2rem; font-weight: 700; color: #f1f5f9; }
.select-cargo { font-size: .8rem; color: #64748b; margin-bottom: 14px; }

.select-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.btn-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-select:active { transform: scale(.95); }
.btn-select .btn-icon { font-size: 1.6rem; }

.btn-select.entrada {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  box-shadow: 0 6px 20px rgba(22,163,74,.35);
}
.btn-select.entrada:hover { box-shadow: 0 8px 28px rgba(22,163,74,.5); }

.btn-select.salida {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 6px 20px rgba(220,38,38,.35);
}
.btn-select.salida:hover { box-shadow: 0 8px 28px rgba(220,38,38,.5); }

.btn-select.pausa_inicio {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  box-shadow: 0 6px 20px rgba(217,119,6,.35);
}
.btn-select.pausa_inicio:hover { box-shadow: 0 8px 28px rgba(217,119,6,.5); }

.btn-select.pausa_fin {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 6px 20px rgba(37,99,235,.35);
}
.btn-select.pausa_fin:hover { box-shadow: 0 8px 28px rgba(37,99,235,.5); }

.btn-nosoyyo {
  background: none;
  border: 1px solid rgba(255,255,255,.12);
  color: #64748b;
  font-size: .8rem;
  border-radius: 8px;
  padding: 6px 16px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: color .15s, border-color .15s;
}
.btn-nosoyyo:hover { color: #94a3b8; border-color: rgba(255,255,255,.22); }

/* Barra de countdown */
.countdown-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.countdown-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,.1);
  border-radius: 2px;
  overflow: hidden;
}
.countdown-bar-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 2px;
  transition: width 1s linear;
}
.countdown-text { font-size: .75rem; color: #475569; white-space: nowrap; }
.countdown-cancel {
  background: none;
  border: none;
  color: #475569;
  font-size: .75rem;
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
}
.countdown-cancel:hover { color: #94a3b8; }

/* ── Misc helpers ─────────────────────────────────── */
.btn-action { padding: 5px 12px; font-size: .8rem; }
.section-title { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin-bottom: 12px; }
