/* ═══════════════════════════════════════════════
   RRHH Enterprise — Sistema de diseño
   Fuente: DM Sans (body) + DM Mono (números)
   Paleta: azul institucional + grises limpios
   Responsive: móvil (< 768px) / tablet / PC
═══════════════════════════════════════════════ */

/* ─── Variables ──────────────────────────────── */
:root {
  --sidebar-width:      240px;
  --sidebar-collapsed:  68px;
  --header-height:      60px;

  /* Paleta principal */
  --blue-50:    #EFF6FF;
  --blue-100:   #DBEAFE;
  --blue-200:   #BFDBFE;
  --blue-500:   #3B82F6;
  --blue-600:   #2563EB;
  --blue-700:   #1D4ED8;
  --blue-900:   #1E3A5F;

  /* Tonos neutros */
  --gray-50:    #F8FAFC;
  --gray-100:   #F1F5F9;
  --gray-200:   #E2E8F0;
  --gray-300:   #CBD5E1;
  --gray-400:   #94A3B8;
  --gray-500:   #64748B;
  --gray-600:   #475569;
  --gray-700:   #334155;
  --gray-800:   #1E293B;
  --gray-900:   #0F172A;

  /* Semánticos */
  --color-primary:   var(--blue-600);
  --color-primary-h: var(--blue-700);
  --color-bg:        var(--gray-50);
  --color-surface:   #FFFFFF;
  --color-border:    var(--gray-200);
  --color-text:      var(--gray-800);
  --color-muted:     var(--gray-500);
  --color-sidebar-bg:    var(--gray-900);
  --color-sidebar-text:  #94A3B8;
  --color-sidebar-hover: rgba(255,255,255,0.07);
  --color-sidebar-active-bg: rgba(59,130,246,0.15);
  --color-sidebar-active:    var(--blue-400, #60A5FA);

  /* Sombras */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);

  /* Radio */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  /* Transición */
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode */
[data-bs-theme="dark"] {
  --color-bg:       #0F172A;
  --color-surface:  #1E293B;
  --color-border:   #334155;
  --color-text:     #E2E8F0;
  --color-muted:    #94A3B8;
  --color-sidebar-bg:   #020617;
  --color-sidebar-hover: rgba(255,255,255,0.06);
}

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

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  overflow-x: hidden;
}

.font-mono { font-family: 'DM Mono', 'Courier New', monospace; }

/* ─── SIDEBAR ────────────────────────────────── */
.rrhh-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: var(--transition);
  overflow: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--header-height);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: var(--blue-600);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.sidebar-brand-icon svg { width: 17px; height: 17px; }

.sidebar-brand-text {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  letter-spacing: -.3px;
}
.sidebar-brand-text span { color: var(--blue-400, #60A5FA); }

.sidebar-close {
  margin-left: auto;
  background: none; border: none;
  color: var(--color-sidebar-text);
  cursor: pointer; padding: 4px;
}
.sidebar-close:hover { color: #fff; }

/* Navegación */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  padding: 14px 18px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-link span { overflow: hidden; text-overflow: ellipsis; }

.sidebar-link:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}
.sidebar-link.active {
  background: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active);
  font-weight: 500;
}
.sidebar-link.active svg { stroke: var(--color-sidebar-active); }

/* Usuario bottom */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
}
.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #E2E8F0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.72rem;
  color: var(--color-sidebar-text);
  text-transform: capitalize;
}

/* Overlay móvil */
.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; }

/* ─── MAIN CONTENT ───────────────────────────── */
.rrhh-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

/* ─── HEADER ─────────────────────────────────── */
.rrhh-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1030;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-sidebar-toggle {
  background: none; border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: none; /* visible en tablet/móvil */
  transition: var(--transition);
}
.btn-sidebar-toggle:hover { background: var(--gray-100); color: var(--color-text); }
.btn-sidebar-toggle svg  { width: 20px; height: 20px; }

.breadcrumb { font-size: 0.82rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--color-muted); }
.breadcrumb a { color: var(--color-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb-item.active { color: var(--color-text); font-weight: 500; }

.header-date {
  font-size: 0.8rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.header-icon-btn {
  background: none; border: none;
  color: var(--color-muted);
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: var(--transition);
}
.header-icon-btn:hover { background: var(--gray-100); color: var(--color-text); }
.header-icon-btn svg { width: 18px; height: 18px; }

.header-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none; border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}
.header-profile-btn:hover { background: var(--gray-100); }

.header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* Notification panel */
.notification-panel { min-width: 300px; }
.dropdown-header {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--color-text);
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
}
.dropdown-subtext {
  font-size: 0.75rem;
  color: var(--color-muted);
  padding: 0 16px 8px;
}

/* ─── CONTENIDO ──────────────────────────────── */
.rrhh-content {
  flex: 1;
  padding: 24px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  letter-spacing: -.3px;
}
.page-subtitle {
  font-size: 0.83rem;
  color: var(--color-muted);
  margin: 2px 0 0;
}

/* ─── CARDS ──────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--color-border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.card-body { padding: 20px; }

/* Stat cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: var(--blue-50);   color: var(--blue-600); }
.stat-icon.green  { background: #F0FDF4; color: #16A34A; }
.stat-icon.orange { background: #FFF7ED; color: #EA580C; }
.stat-icon.red    { background: #FEF2F2; color: #DC2626; }
.stat-icon.purple { background: #FAF5FF; color: #7C3AED; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--color-text);
  font-family: 'DM Mono', monospace;
  letter-spacing: -.5px;
  line-height: 1;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 2px;
}
.stat-delta {
  font-size: 0.75rem;
  margin-top: 4px;
}
.stat-delta.up   { color: #16A34A; }
.stat-delta.down { color: #DC2626; }

/* ─── TABLAS ─────────────────────────────────── */
.table-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--color-surface);
}
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  margin: 0;
  font-size: 0.865rem;
  color: var(--color-text);
}
.table thead th {
  background: var(--gray-50);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  padding: 11px 14px;
  white-space: nowrap;
}
[data-bs-theme="dark"] .table thead th { background: var(--gray-800); }
.table tbody td { padding: 12px 14px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--gray-50); }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background: rgba(255,255,255,0.03); }

/* ─── FORMULARIOS ────────────────────────────── */
.form-label { font-size: 0.83rem; font-weight: 500; margin-bottom: 5px; color: var(--gray-700); }
.form-control, .form-select {
  border-color: var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  padding: 8px 12px;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue-400, #60A5FA);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  outline: none;
}

/* ─── BOTONES ────────────────────────────────── */
.btn {
  font-size: 0.855rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn-icon svg { width: 15px; height: 15px; }

/* ─── BADGES ─────────────────────────────────── */
.badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 20px;
  letter-spacing: .02em;
}

/* ─── ALERTS ─────────────────────────────────── */
.alert-rrhh {
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.alert-rrhh svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── FOOTER ─────────────────────────────────── */
.rrhh-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 12px 24px;
  font-size: 0.78rem;
  color: var(--color-muted);
}

/* ─── AUTH ───────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--gray-900) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  width: 48px; height: 48px;
  background: var(--blue-600);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: #fff;
}
.auth-logo svg { width: 24px; height: 24px; }

/* ─── RESPONSIVE ─────────────────────────────── */

/* Tablet: 768px – 991px */
@media (max-width: 991px) {
  .btn-sidebar-toggle { display: flex; }

  /* Sidebar sale del flujo, se muestra con overlay */
  .rrhh-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  .rrhh-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .rrhh-main { margin-left: 0; }
}

/* Mobile: < 576px */
@media (max-width: 575px) {
  .rrhh-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { width: 100%; justify-content: center; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.3rem; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-toolbar .btn,
  .table-toolbar .form-control { width: 100%; }
  .auth-card { padding: 28px 20px; }
  .rrhh-footer { padding: 10px 16px; }
}

/* PC grande: sidebar con iconos en modo colapsado */
@media (min-width: 992px) {
  .rrhh-sidebar.collapsed {
    width: var(--sidebar-collapsed);
  }
  .rrhh-sidebar.collapsed .sidebar-brand-text,
  .rrhh-sidebar.collapsed .sidebar-section-label,
  .rrhh-sidebar.collapsed .sidebar-link span,
  .rrhh-sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
  }
  .rrhh-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 10px;
    margin: 1px 6px;
  }
  .rrhh-sidebar.collapsed + .sidebar-overlay + .rrhh-main,
  .rrhh-main.collapsed {
    margin-left: var(--sidebar-collapsed);
  }
  .rrhh-sidebar.collapsed .sidebar-user {
    justify-content: center;
  }
}

/* ─── Utilidades ─────────────────────────────── */
.text-mono { font-family: 'DM Mono', monospace; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.gap-2  { gap: 8px; }
.cursor-pointer { cursor: pointer; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Spinner de carga */
.page-loader {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
  color: var(--color-muted);
  gap: 10px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h5 { font-size: 0.95rem; font-weight: 500; margin-bottom: 4px; }
.empty-state p  { font-size: 0.83rem; margin: 0; }
