/* ============================================================
   GESTIÓN RH — Sistema de Administración de Empleados
   main.css  |  Design tokens · Reset · App shell · Login
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Brand – Blue corporate */
  --c-brand-50:  #eff6ff;
  --c-brand-100: #dbeafe;
  --c-brand-200: #bfdbfe;
  --c-brand-300: #93c5fd;
  --c-brand-400: #60a5fa;
  --c-brand-500: #3b82f6;
  --c-brand-600: #2563eb;
  --c-brand-700: #1d4ed8;
  --c-brand-800: #1e40af;
  --c-brand-900: #1e3a8a;
  --c-brand-950: #172554;

  /* Neutrals */
  --c-gray-50:  #f8fafc;
  --c-gray-100: #f1f5f9;
  --c-gray-200: #e2e8f0;
  --c-gray-300: #cbd5e1;
  --c-gray-400: #94a3b8;
  --c-gray-500: #64748b;
  --c-gray-600: #475569;
  --c-gray-700: #334155;
  --c-gray-800: #1e293b;
  --c-gray-900: #0f172a;

  /* Status */
  --c-success-50:  #f0fdf4;
  --c-success-100: #dcfce7;
  --c-success-600: #16a34a;
  --c-success-700: #15803d;
  --c-warning-50:  #fffbeb;
  --c-warning-100: #fef3c7;
  --c-warning-600: #d97706;
  --c-error-50:  #fef2f2;
  --c-error-100: #fee2e2;
  --c-error-600: #dc2626;
  --c-error-700: #b91c1c;

  /* Spacing scale */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Border radius */
  --r-sm:   0.25rem;
  --r-md:   0.375rem;
  --r-lg:   0.5rem;
  --r-xl:   0.75rem;
  --r-2xl:  1rem;
  --r-full: 9999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgb(0 0 0 / .05);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / .10), 0 1px 2px rgb(0 0 0 / .06);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .10), 0 2px 4px -2px rgb(0 0 0 / .10);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .10), 0 4px 6px -4px rgb(0 0 0 / .10);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / .10), 0 8px 10px -6px rgb(0 0 0 / .10);

  /* App shell */
  --sidebar-w: 15.5rem;
  --topbar-h:  3.75rem;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Motion */
  --t-fast: 120ms ease;
  --t-base: 200ms ease;
}

/* ── Reduced Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── CSS Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--c-gray-800);
  background: var(--c-gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; line-height: inherit; }
button { cursor: pointer; touch-action: manipulation; border: none; background: none; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; }

/* ── Skip Link ──────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -4rem;
  z-index: 9999;
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-brand-700);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--r-md);
  transition: top var(--t-fast);
}
.skip-link:focus { top: var(--sp-3); }

/* ── App Shell ──────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.app-sidebar {
  grid-row: 1 / -1;
  background: var(--c-gray-900);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* Brand */
.sidebar-brand {
  padding: var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 2.25rem;
  height: 2.25rem;
  background: var(--c-brand-600);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-text { min-width: 0; }
.sidebar-brand-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-sub {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.4);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
}
.nav-section {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: var(--sp-4) var(--sp-2) var(--sp-1);
}
.nav-section:first-child { padding-top: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 1px;
}
.nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-link.is-active { background: var(--c-brand-700); color: #fff; }
.nav-link:focus-visible { outline: 2px solid var(--c-brand-400); outline-offset: 1px; }
.nav-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav-link.is-active .nav-icon { opacity: 1; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar footer / user */
.sidebar-footer {
  padding: var(--sp-4);
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: var(--sp-3); }
.sidebar-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-full);
  background: var(--c-brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-role {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Top Bar ────────────────────────────────────────────────── */
.app-topbar {
  grid-column: 2;
  background: #fff;
  border-bottom: 1px solid var(--c-gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-8);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-xs);
  gap: var(--sp-4);
}
.topbar-left { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.8125rem;
  color: var(--c-gray-500);
  flex-wrap: wrap;
}
.bc-sep { color: var(--c-gray-300); }
.bc-link { color: var(--c-brand-600); transition: color var(--t-fast); }
.bc-link:hover { color: var(--c-brand-800); text-decoration: underline; }
.bc-link:focus-visible { outline: 2px solid var(--c-brand-500); border-radius: var(--r-sm); }
.bc-current { color: var(--c-gray-700); font-weight: 500; }

/* Demo role picker */
.demo-badge {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-brand-50);
  border: 1px solid var(--c-brand-200);
  border-radius: var(--r-md);
  padding: var(--sp-1) var(--sp-3);
}
.demo-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-brand-600);
  white-space: nowrap;
}
.demo-select {
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-brand-800);
  cursor: pointer;
  padding: 0;
}
.demo-select:focus-visible { outline: 2px solid var(--c-brand-500); border-radius: var(--r-sm); }

/* ── Main ───────────────────────────────────────────────────── */
.app-main {
  grid-column: 2;
  padding: var(--sp-8);
  min-height: 0;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--c-gray-900);
  text-wrap: balance;
  line-height: 1.3;
}
.page-desc {
  font-size: 0.875rem;
  color: var(--c-gray-500);
  margin-top: var(--sp-1);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── Login Layout ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--c-brand-950) 0%, var(--c-brand-900) 40%, var(--c-brand-800) 100%);
  padding: var(--sp-6);
}
.login-card {
  width: 100%;
  max-width: 22rem;
  background: #fff;
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-10);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
}
.login-logo-box {
  width: 2.75rem;
  height: 2.75rem;
  background: var(--c-brand-600);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-brand-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--c-gray-900);
  line-height: 1.2;
}
.login-brand-sub { font-size: 0.75rem; color: var(--c-gray-500); }
.login-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-gray-900);
  margin-bottom: var(--sp-2);
}
.login-sub { font-size: 0.875rem; color: var(--c-gray-500); margin-bottom: var(--sp-6); }

.login-footer {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--c-gray-100);
  text-align: center;
}
.login-footer-label {
  font-size: 0.75rem;
  color: var(--c-gray-500);
  margin-bottom: var(--sp-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.quick-roles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}
.quick-role-btn {
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--c-gray-200);
  border-radius: var(--r-full);
  color: var(--c-gray-700);
  background: #fff;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  touch-action: manipulation;
}
.quick-role-btn:hover { background: var(--c-brand-50); border-color: var(--c-brand-200); color: var(--c-brand-700); }
.quick-role-btn:focus-visible { outline: 2px solid var(--c-brand-500); outline-offset: 2px; }

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-gray-800);
  color: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  max-width: 22rem;
  pointer-events: all;
  animation: toast-in 0.2s ease forwards;
}
.toast--success { background: var(--c-success-600); }
.toast--error   { background: var(--c-error-600); }
.toast--warning { background: var(--c-warning-600); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Utilities ──────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}
[hidden] { display: none !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-mono { font-family: 'SF Mono', 'Cascadia Code', Consolas, 'Courier New', monospace; font-variant-numeric: tabular-nums; }
.tabular-nums { font-variant-numeric: tabular-nums; }
