/* ============================================================
   SERVILINE — Archivo: assets/css/app.css
   Hoja de estilos principal de la aplicación
   Fuente: Plus Jakarta Sans (Google Fonts)
   ============================================================ */

/* ── RESET Y VARIABLES ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paleta principal */
  --clr-900: #0f172a;
  --clr-800: #1e293b;
  --clr-700: #334155;
  --clr-600: #475569;
  --clr-500: #64748b;
  --clr-400: #94a3b8;
  --clr-300: #cbd5e1;
  --clr-200: #e2e8f0;
  --clr-100: #f1f5f9;
  --clr-50:  #f8fafc;

  /* Acento Serviline */
  --brand:         #2563eb;
  --brand-dark:    #1d4ed8;
  --brand-light:   #eff6ff;
  --brand-border:  #bfdbfe;

  /* Semánticos */
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --success-border:#bbf7d0;
  --warning:       #d97706;
  --warning-light: #fffbeb;
  --warning-border:#fde68a;
  --danger:        #dc2626;
  --danger-light:  #fef2f2;
  --danger-border: #fecaca;
  --info:          #0891b2;
  --info-light:    #ecfeff;
  --info-border:   #a5f3fc;

  /* Tipografía */
  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

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

html, body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--clr-800);
  background: var(--clr-100);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── LAYOUT: SIDEBAR + MAIN ─────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--clr-900);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
  overflow-y: auto;
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── SIDEBAR LOGO ────────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgb(255 255 255 / .08);
}
.logo-mark {
  width: 34px; height: 34px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.logo-text {
  font-size: 16px; font-weight: 700;
  color: #fff; letter-spacing: -.3px;
}

/* ── SIDEBAR NAV ─────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.nav-group--bottom { margin-top: auto; margin-bottom: 0; padding-top: 12px; border-top: 1px solid rgb(255 255 255 / .08); }
.nav-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--clr-500);
  padding: 0 8px;
  margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--clr-400);
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgb(255 255 255 / .06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item.sub { padding-left: 28px; font-size: 13px; color: var(--clr-500); }
.nav-item.sub:hover { color: var(--clr-300); }
.nav-item--logout { color: #f87171; }
.nav-item--logout:hover { background: rgb(220 38 38 / .15); color: #fca5a5; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--clr-200);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle {
  display: none;
  flex-direction: column; justify-content: space-between;
  width: 22px; height: 16px;
  background: none; border: none; padding: 0;
}
.menu-toggle span { display: block; height: 2px; background: var(--clr-600); border-radius: 2px; }
.page-title { font-size: 17px; font-weight: 600; color: var(--clr-900); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--clr-700);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--brand-light);
  color: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.alerta-badge {
  position: relative; cursor: pointer;
  color: var(--clr-500);
}
.alerta-count {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ── FLASH MESSAGES ──────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  font-size: 14px; font-weight: 500;
  border-left: 4px solid;
  animation: slideDown .25s ease;
}
.flash--success { background: var(--success-light); color: var(--success);    border-color: var(--success); }
.flash--error   { background: var(--danger-light);  color: var(--danger);     border-color: var(--danger); }
.flash--warning { background: var(--warning-light); color: var(--warning);    border-color: var(--warning); }
.flash--info    { background: var(--info-light);    color: var(--info);       border-color: var(--info); }
.flash-close { background: none; border: none; font-size: 18px; color: inherit; opacity: .6; }
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── ALERTAS DEL SISTEMA ─────────────────────────────────────── */
.alertas-sistema { padding: 16px 24px 0; display: flex; flex-direction: column; gap: 8px; }
.alerta-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid;
}
.alerta-item--danger  { background: var(--danger-light);  color: #991b1b; border-color: var(--danger-border); }
.alerta-item--warning { background: var(--warning-light); color: #92400e; border-color: var(--warning-border); }
.alerta-item--info    { background: var(--info-light);    color: #164e63; border-color: var(--info-border); }
.alerta-icono { font-size: 16px; }
.alerta-link  { margin-left: auto; font-size: 12px; font-weight: 600; color: inherit; }
.alerta-link:hover { text-decoration: underline; }

/* ── PAGE BODY ───────────────────────────────────────────────── */
.page-body { padding: 24px; flex: 1; }

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--clr-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--clr-100);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--clr-900); }
.card-subtitle { font-size: 13px; color: var(--clr-500); margin-top: 2px; }

/* ── MÉTRICAS (DASHBOARD) ────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: #fff;
  border: 1px solid var(--clr-200);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
}
.metric-card--blue::before    { background: var(--brand); }
.metric-card--green::before   { background: var(--success); }
.metric-card--orange::before  { background: var(--warning); }
.metric-card--red::before     { background: var(--danger); }
.metric-label { font-size: 12px; font-weight: 600; color: var(--clr-500); text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-size: 28px; font-weight: 700; color: var(--clr-900); margin: 6px 0 4px; line-height: 1; }
.metric-sub   { font-size: 12px; color: var(--clr-500); }
.metric-icon  { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); opacity: .07; font-size: 48px; }

/* ── TABLAS ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: var(--clr-50);
  color: var(--clr-600);
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--clr-200);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--clr-100); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--clr-50); }
tbody td { padding: 11px 14px; color: var(--clr-700); vertical-align: middle; }
.td-mono { font-family: var(--font-mono); font-size: 12.5px; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}

/* ── FORMULARIOS ─────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.form-grid--2 { grid-template-columns: repeat(2, 1fr); }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: 13px; font-weight: 600;
  color: var(--clr-600); text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--clr-200);
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--clr-700); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-hint  { font-size: 11.5px; color: var(--clr-400); margin-top: 2px; }
.form-error { font-size: 11.5px; color: var(--danger); margin-top: 2px; font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--clr-300);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font-sans);
  color: var(--clr-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(37 99 235 / .12);
}
input.invalid { border-color: var(--danger); }
input.invalid:focus { box-shadow: 0 0 0 3px rgb(220 38 38 / .12); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea { resize: vertical; min-height: 90px; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-label { font-size: 13px; font-weight: 500; color: var(--clr-700); }
.toggle {
  position: relative;
  width: 42px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--clr-300);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── BOTONES ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; font-family: var(--font-sans);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary   { background: var(--brand);       color: #fff;           border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: #fff;               color: var(--clr-700); border-color: var(--clr-300); }
.btn-secondary:hover { background: var(--clr-50); text-decoration: none; }
.btn-danger    { background: var(--danger-light); color: var(--danger);  border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.btn-success   { background: var(--success);     color: #fff;           border-color: var(--success); }
.btn-success:hover { background: #15803d; text-decoration: none; }
.btn-sm  { padding: 5px 12px; font-size: 12.5px; }
.btn-xs  { padding: 3px 8px;  font-size: 11.5px; }
.btn-icon { padding: 7px; }

/* ── BARRA DE BÚSQUEDA / FILTROS ─────────────────────────────── */
.filtros-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filtros-bar input[type="text"],
.filtros-bar select {
  width: auto; min-width: 180px; max-width: 260px;
}
.search-wrapper { position: relative; }
.search-wrapper svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--clr-400); pointer-events: none;
}
.search-wrapper input { padding-left: 34px; }

/* ── PAGINACIÓN ──────────────────────────────────────────────── */
.paginacion { margin-top: 20px; display: flex; justify-content: center; }
.paginacion ul { display: flex; gap: 4px; list-style: none; }
.paginacion li a, .paginacion li.activa {
  display: flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--clr-200);
  color: var(--clr-600);
  background: #fff;
  text-decoration: none;
  transition: background .1s;
}
.paginacion li a:hover { background: var(--clr-50); text-decoration: none; }
.paginacion li.activa { background: var(--brand); color: #fff; border-color: var(--brand); }
.paginacion li.dots { display: flex; align-items: center; padding: 0 4px; color: var(--clr-400); }

/* ── ESTADO VACÍO ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--clr-500);
}
.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--clr-700); margin-bottom: 6px; }

/* ── MODALES ─────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgb(0 0 0 / .45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--clr-100);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--clr-900); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--clr-400); line-height: 1; }
.modal-close:hover { color: var(--clr-700); }
.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 16px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--clr-100); }

@keyframes modalIn {
  from { transform: translateY(-20px) scale(.97); opacity: 0; }
  to   { transform: translateY(0)      scale(1);   opacity: 1; }
}

/* ── SECCIONES CONDICIONALES (tributario/RRHH) ───────────────── */
.seccion-condicional { display: none; }
.seccion-condicional.visible { display: block; }

/* ── LOGIN PAGE ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--clr-900) 0%, var(--clr-800) 60%, #1e3a8a 100%);
  padding: 24px;
}
.login-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 40px 36px;
  width: 100%; max-width: 420px;
}
.login-logo {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo-mark {
  width: 44px; height: 44px;
  background: var(--brand);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
}
.login-logo-text { font-size: 22px; font-weight: 700; color: var(--clr-900); }
.login-title { font-size: 20px; font-weight: 600; color: var(--clr-900); text-align: center; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--clr-500); text-align: center; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-btn {
  width: 100%; padding: 11px;
  background: var(--brand); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: var(--font-sans);
  cursor: pointer; margin-top: 6px;
  transition: background .15s;
}
.login-btn:hover  { background: var(--brand-dark); }
.login-btn:active { transform: scale(.99); }
.login-footer { text-align: center; margin-top: 18px; font-size: 12px; color: var(--clr-400); }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .menu-toggle {
    display: flex;
  }
  .form-grid--2,
  .form-grid--3 {
    grid-template-columns: 1fr;
  }
  .page-body { padding: 16px; }
}
