/* ====================================================
   AsistenciaEmpresa — Main Stylesheet
   ==================================================== */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 60px;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
  --sidebar-bg: #1e1b4b;
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: rgba(255,255,255,.15);
  --sidebar-text: rgba(255,255,255,.85);
  --sidebar-text-muted: rgba(255,255,255,.45);
  --topbar-bg: #fff;
  --topbar-border: #e5e7eb;
  --body-bg: #f3f4f6;
  --card-bg: #fff;
  --card-border: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --radius: .75rem;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.1);
}

[data-bs-theme="dark"] {
  --topbar-bg: #1f2937;
  --topbar-border: #374151;
  --body-bg: #111827;
  --card-bg: #1f2937;
  --card-border: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --sidebar-bg: #111827;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: .9rem;
  background: var(--body-bg);
  color: var(--text-primary);
  margin: 0;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1040;
  transition: width .25s ease, transform .25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand {
  display: flex; align-items: center; gap: .5rem;
  color: #fff; text-decoration: none;
  font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px;
  white-space: nowrap;
}

.sidebar-user {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem;
  margin: .5rem;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
}

.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; overflow: hidden; flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { overflow: hidden; }
.user-name { color: #fff; font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; }

.sidebar-nav { padding: .5rem; }

.nav-section-label {
  font-size: .65rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sidebar-text-muted);
  padding: .75rem .75rem .25rem;
}

.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; border-radius: .5rem; margin-bottom: 2px;
  color: var(--sidebar-text); text-decoration: none; font-size: .875rem;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav .nav-link i { font-size: 1rem; flex-shrink: 0; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-nav .nav-link .badge { margin-left: auto; }

/* ── MAIN WRAPPER ─────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s ease;
}

/* ── TOPBAR ───────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 1030;
  box-shadow: var(--shadow-sm);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .5rem; }

.topbar-toggle { color: var(--text-primary); padding: .4rem; border-radius: .4rem; }
.topbar-toggle:hover { background: var(--body-bg); }

.topbar-btn { color: var(--text-primary); padding: .4rem .5rem; position: relative; }
.topbar-btn:hover { color: var(--primary); }

.topbar-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.topbar-avatar-placeholder {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
}

.notif-badge {
  position: absolute; top: 2px; right: 2px;
  font-size: .6rem; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; padding: 0 3px;
}
.notif-dropdown { width: 300px; max-height: 400px; overflow-y: auto; }
.notif-header { background: var(--card-bg); }
.notif-item { color: inherit; text-decoration: none; }
.notif-item:hover { background: var(--body-bg); }
.notif-unread { background: rgba(79,70,229,.04); }

/* ── BREADCRUMB ───────────────────────────────────── */
.breadcrumb { font-size: .8rem; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

/* ── CONTENT ──────────────────────────────────────── */
.main-content { flex: 1; padding: 1.5rem; }
.main-footer { padding: .75rem 1.5rem; border-top: 1px solid var(--card-border); text-align: right; }

/* ── CARDS ────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

/* ── STAT CARDS ───────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; right: 0; width: 80px; height: 80px;
  border-radius: 0 var(--radius) 0 80px;
  opacity: .08;
}
.stat-card-primary::before { background: #4f46e5; }
.stat-card-success::before { background: #16a34a; }
.stat-card-danger::before  { background: #dc2626; }
.stat-card-warning::before { background: #d97706; }
.stat-card-info::before    { background: #0284c7; }
.stat-card-orange::before  { background: #ea580c; }
.stat-card-purple::before  { background: #7c3aed; }
.stat-card-teal::before    { background: #0d9488; }

.stat-icon {
  width: 44px; height: 44px; border-radius: .6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; margin-bottom: .75rem;
}
.stat-card-primary .stat-icon { background: rgba(79,70,229,.12); color: #4f46e5; }
.stat-card-success .stat-icon { background: rgba(22,163,74,.12); color: #16a34a; }
.stat-card-danger .stat-icon  { background: rgba(220,38,38,.12); color: #dc2626; }
.stat-card-warning .stat-icon { background: rgba(217,119,6,.12); color: #d97706; }
.stat-card-info .stat-icon    { background: rgba(2,132,199,.12); color: #0284c7; }
.stat-card-orange .stat-icon  { background: rgba(234,88,12,.12); color: #ea580c; }
.stat-card-purple .stat-icon  { background: rgba(124,58,237,.12); color: #7c3aed; }
.stat-card-teal .stat-icon    { background: rgba(13,148,136,.12); color: #0d9488; }

.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; margin-bottom: .25rem; }
.stat-label { font-size: .8rem; color: var(--text-secondary); }
.stat-link  { font-size: .75rem; color: var(--primary); text-decoration: none; display: block; margin-top: .5rem; }

/* ── PAGE HEADER ──────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-title  { font-size: 1.3rem; font-weight: 700; margin: 0; }

/* ── TABLES ───────────────────────────────────────── */
.table { --bs-table-bg: var(--card-bg); font-size: .875rem; }
.table th { font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); border-bottom-width: 1px; white-space: nowrap; }
.table-hover tbody tr:hover td { background: rgba(79,70,229,.04); }

/* ── FORMS ────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .4rem; }
.form-control, .form-select {
  border-radius: .5rem; border-color: var(--card-border);
  font-size: .875rem; background: var(--card-bg); color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

/* ── BUTTONS ──────────────────────────────────────── */
.btn { border-radius: .5rem; font-weight: 500; font-size: .875rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* ── BADGES ───────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: .01em; padding: .35em .65em; }

/* ── AUTH ─────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #4f46e5 0%, #1e1b4b 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1rem;
}
.auth-card {
  background: #fff; border-radius: 1rem;
  padding: 2rem; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }

/* ── PORTAL ───────────────────────────────────────── */
.portal-body { background: var(--body-bg); padding-bottom: 60px; }
.portal-navbar { background: linear-gradient(135deg, #4f46e5 0%, #1e1b4b 100%); }
.portal-navbar .navbar-brand, .portal-navbar * { color: #fff !important; }
.portal-bottom-nav {
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.portal-nav-btn {
  display: flex; flex-direction: column; align-items: center;
  font-size: .65rem; color: var(--text-secondary); text-decoration: none;
  padding: .4rem .5rem; border-radius: .4rem; min-width: 56px;
}
.portal-nav-btn i { font-size: 1.2rem; margin-bottom: 2px; }
.portal-nav-btn.active, .portal-nav-btn:hover { color: var(--primary); }

/* ── MARCACIÓN / QR ───────────────────────────────── */
.marcar-card {
  max-width: 480px; margin: 0 auto;
  border-radius: 1.25rem; overflow: hidden;
}
.marcar-status {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .8rem; border-radius: 2rem; font-size: .8rem;
}
.marcar-btn {
  width: 100%; padding: .9rem; font-size: 1rem;
  border-radius: .75rem; font-weight: 600;
}

/* ── ATTENDANCE STATUS ─────────────────────────────── */
.attend-row-presente  { border-left: 3px solid #16a34a; }
.attend-row-tardanza  { border-left: 3px solid #d97706; }
.attend-row-falta     { border-left: 3px solid #dc2626; }
.attend-row-permiso   { border-left: 3px solid #0284c7; }
.attend-row-vacaciones{ border-left: 3px solid #7c3aed; }

/* ── AVATAR ───────────────────────────────────────── */
.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: #e5e7eb; display: inline-flex; align-items: center; justify-content: center;
}

/* ── COLLAPSED SIDEBAR ─────────────────────────────── */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-section-label,
body.sidebar-collapsed .sidebar .nav-link span,
body.sidebar-collapsed .sidebar .user-info { display: none; }
body.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: .6rem; }
body.sidebar-collapsed .sidebar .nav-link i { width: auto; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }
body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-collapsed); }

/* ── RESPONSIVE ───────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1039;
  }
  .sidebar-overlay.show { display: block; }
}

/* ── UTILITIES ────────────────────────────────────── */
.text-truncate-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cursor-pointer { cursor: pointer; }
.gap-2px { gap: 2px; }

/* ── SCROLL ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ====================================================
   COMPLEMENTOS Y MEJORAS v1.1
   ==================================================== */

/* ── ESTADO ASISTENCIA (colores línea izquierda) ─────── */
.attend-row-presente   td:first-child { border-left: 3px solid #16a34a; padding-left: 12px; }
.attend-row-tardanza   td:first-child { border-left: 3px solid #d97706; padding-left: 12px; }
.attend-row-falta      td:first-child { border-left: 3px solid #dc2626; padding-left: 12px; }
.attend-row-permiso    td:first-child { border-left: 3px solid #0284c7; padding-left: 12px; }
.attend-row-vacaciones td:first-child { border-left: 3px solid #7c3aed; padding-left: 12px; }

/* ── SIDEBAR OVERLAY FIX ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── SIDEBAR TOGGLE BTN ──────────────────────────────── */
.sidebar-toggle-btn { color: rgba(255,255,255,.7); border: none; background: none; padding: .25rem; }
.sidebar-toggle-btn:hover { color: #fff; }

/* ── TOPBAR FIXES ────────────────────────────────────── */
.topbar-btn { color: var(--text-primary); padding: .4rem .5rem; border: none; background: none; border-radius: .4rem; }
.topbar-btn:hover { background: var(--body-bg); color: var(--primary); }

/* ── CARD HOVER EFFECTS ──────────────────────────────── */
.card { transition: box-shadow .15s ease; }
a.card:hover { box-shadow: var(--shadow) !important; transform: translateY(-2px); }

/* ── FORM IMPROVEMENTS ───────────────────────────────── */
.form-control:disabled, .form-control[readonly] {
  background: var(--body-bg);
  cursor: not-allowed;
  opacity: .7;
}
.input-group-text {
  background: var(--body-bg);
  border-color: var(--card-border);
  color: var(--text-secondary);
}

/* ── TABLE IMPROVEMENTS ──────────────────────────────── */
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.table > :not(caption) > * > * { padding: .65rem .85rem; }
.table thead tr th { padding: .75rem .85rem; }

/* ── ALERT IMPROVEMENTS ──────────────────────────────── */
.alert { border-radius: .6rem; border: none; }
.alert-success  { background: rgba(22,163,74,.1);  color: #15803d; }
.alert-danger   { background: rgba(220,38,38,.1);  color: #b91c1c; }
.alert-warning  { background: rgba(217,119,6,.1);  color: #92400e; }
.alert-info     { background: rgba(2,132,199,.1);  color: #0369a1; }
[data-bs-theme="dark"] .alert-success  { background: rgba(22,163,74,.15);  color: #4ade80; }
[data-bs-theme="dark"] .alert-danger   { background: rgba(220,38,38,.15);  color: #f87171; }
[data-bs-theme="dark"] .alert-warning  { background: rgba(217,119,6,.15);  color: #fbbf24; }
[data-bs-theme="dark"] .alert-info     { background: rgba(2,132,199,.15);  color: #38bdf8; }

/* ── BADGE IMPROVEMENTS ──────────────────────────────── */
.bg-primary-subtle { background: rgba(79,70,229,.1) !important; }
.bg-success-subtle { background: rgba(22,163,74,.1) !important; }
.bg-danger-subtle  { background: rgba(220,38,38,.1) !important; }
.bg-warning-subtle { background: rgba(217,119,6,.1) !important; }
.bg-info-subtle    { background: rgba(2,132,199,.1) !important; }
.text-primary { color: var(--primary) !important; }

/* ── PROGRESS BAR ────────────────────────────────────── */
.progress { background: var(--card-border); border-radius: 4px; }
.progress-bar { border-radius: 4px; transition: width .4s ease; }

/* ── PAGINATION ──────────────────────────────────────── */
.pagination { gap: 2px; }
.page-link {
  border-radius: .4rem !important;
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: .3rem .65rem;
  font-size: .8rem;
  background: var(--card-bg);
}
.page-link:hover  { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── MODAL IMPROVEMENTS ──────────────────────────────── */
.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-header { border-bottom: 1px solid var(--card-border); padding: 1rem 1.25rem; }
.modal-footer { border-top: 1px solid var(--card-border); padding: 1rem 1.25rem; }

/* ── DROPDOWN MENU ───────────────────────────────────── */
.dropdown-menu {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: .6rem;
  box-shadow: var(--shadow);
  padding: .4rem;
}
.dropdown-item {
  border-radius: .4rem;
  padding: .45rem .8rem;
  font-size: .875rem;
  color: var(--text-primary);
}
.dropdown-item:hover { background: var(--body-bg); color: var(--primary); }
.dropdown-divider { border-color: var(--card-border); }

/* ── LIST GROUP ──────────────────────────────────────── */
.list-group-item {
  background: var(--card-bg);
  border-color: var(--card-border);
  color: var(--text-primary);
}
.list-group-item-action:hover { background: var(--body-bg); }

/* ── BREADCRUMB ──────────────────────────────────────── */
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-secondary); }

/* ── PORTAL CARD ACCESO RÁPIDO ───────────────────────── */
.card.text-decoration-none:hover .bi { transform: scale(1.1); transition: transform .2s; }

/* ── SPINNER OVERLAY ─────────────────────────────────── */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

/* ── AVATAR SIZES ────────────────────────────────────── */
.avatar-xs { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #e5e7eb; display: inline-flex; align-items: center; justify-content: center; }
.avatar-md { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }

/* ── CODE BLOCKS ─────────────────────────────────────── */
code {
  background: var(--body-bg);
  padding: .2rem .4rem;
  border-radius: .3rem;
  font-size: .8em;
  color: #e11d48;
}
[data-bs-theme="dark"] code { color: #fb7185; }

/* ── KIOSCO IMPROVEMENTS ─────────────────────────────── */
.kiosko-btn-main {
  height: 80px;
  font-size: 1.1rem;
  border-radius: 1rem;
  font-weight: 600;
  letter-spacing: .3px;
  transition: transform .1s, box-shadow .1s;
}
.kiosko-btn-main:active { transform: scale(.97); }

/* ── PRINT STYLES ────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .main-footer,
  .btn, .no-print, nav.navbar { display: none !important; }
  .main-wrapper { margin: 0 !important; }
  .main-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── DARK MODE SIDEBAR ───────────────────────────────── */
[data-bs-theme="dark"] .sidebar { background: #0f172a; }
[data-bs-theme="dark"] .topbar  { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] code     { background: #1e293b; }

/* ── LOADING BUTTON ──────────────────────────────────── */
.btn-loading { position: relative; pointer-events: none; }
.btn-loading::after {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE TABLE FIX ────────────────────────────── */
@media (max-width: 576px) {
  .table-responsive table { min-width: 600px; }
  .main-content { padding: 1rem .75rem; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.4rem; }
}

/* ── SMOOTH TRANSITIONS ──────────────────────────────── */
.nav-link, .btn, .card, .badge, .list-group-item-action {
  transition: all .15s ease;
}
