/* ==========================================================================
   HR Dashboard · base.css
   Paleta, layout, responsive (desktop / tablet / mobile)
   ========================================================================== */

/* ── Variables de paleta ─────────────────────────────────────────────────── */
:root {
  --bg:         #f4faf4;
  --surface:    #ffffff;
  --hdr:        #2E7D32;
  --hdr2:       #4CAF50;
  --accent:     #4CAF50;
  --accent-bg:  #E8F5E9;
  --border:     #C8E6C9;
  --text:       #1B5E20;
  --text2:      #2E7D32;
  --text3:      #6b7280;

  --c-burger:   #2563eb;
  --c-cool:     #2E7D32;
  --c-dean:     #7c3aed;
  --c-green:    #d97706;

  --up:         #1B5E20;
  --dn:         #991b1b;
  --warn:       #f59e0b;

  /* Layout */
  --sidebar-w:  220px;
  --topbar-h:   56px;
  --bottomnav-h: 0px;   /* activa en mobile */

  /* Tipografía */
  --font: 'General Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── Reset mínimo ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── Google Fonts ─────────────────────────────────────────────────────────  */
/* ── General Sans — fuente local ─────────────────────────────────────────── */
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Regular.otf') format('opentype'); font-weight:400; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Italic.otf') format('opentype'); font-weight:400; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Light.otf') format('opentype'); font-weight:300; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-LightItalic.otf') format('opentype'); font-weight:300; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Medium.otf') format('opentype'); font-weight:500; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-MediumItalic.otf') format('opentype'); font-weight:500; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Semibold.otf') format('opentype'); font-weight:600; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-SemiboldItalic.otf') format('opentype'); font-weight:600; font-style:italic; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-Bold.otf') format('opentype'); font-weight:700; font-style:normal; }
@font-face { font-family:'General Sans'; src:url('../fonts/GeneralSans-BoldItalic.otf') format('opentype'); font-weight:700; font-style:italic; }

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--hdr);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.25s ease, width 0.2s ease;
}

.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.logo-box {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'General Sans', sans-serif;
  font-weight: 600; font-size: 13px; color: #fff;
  flex-shrink: 0;
}
.logo-text {
  font-family: 'General Sans', sans-serif;
  font-weight: 600; font-size: 12px; color: #fff;
  line-height: 1.3; overflow: hidden;
}
.logo-sub { font-size: 10px; color: rgba(255,255,255,0.45); font-weight: 400; }
.sidebar-close { display: none; color: rgba(255,255,255,0.6); margin-left: auto; padding: 4px; }

/* Nav items */
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }
.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; margin: 1px 8px;
  border-radius: 7px;
  font-size: 13px; color: rgba(255,255,255,0.7);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover  { background: rgba(255,255,255,0.09); color: #fff; }
.nav-item.active { background: rgba(61,175,114,0.28); color: #fff; font-weight: 500; }
.nav-ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* Razones sociales */
.sidebar-razones {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.razones-label {
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,0.32);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.razon-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 11px;
  color: rgba(255,255,255,0.55);
}
.razon-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 190;
}

/* ==========================================================================
   MAIN WRAPPER
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: var(--bottomnav-h);
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.hamburger {
  display: none;
  flex-direction: column; gap: 4px;
  padding: 6px; border-radius: 6px;
  flex-shrink: 0;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--hdr); border-radius: 1px;
}
.hamburger:hover { background: var(--accent-bg); }

.topbar-title {
  font-family: 'General Sans', sans-serif;
  font-weight: 600; font-size: 15px;
  color: var(--text); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.btn-upload {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 7px;
  background: var(--accent-bg); color: var(--hdr2);
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  transition: background 0.12s;
}
.btn-upload:hover { background: var(--accent); color: #fff; }

.cc-toggle {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text3); font-size: 11px; font-weight: 500;
  font-family: var(--font); cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.cc-toggle:hover  { border-color: var(--accent); color: var(--hdr2); }
.cc-toggle.active { background: var(--hdr); color: #fff; border-color: var(--hdr); }
.cc-toggle.active svg { opacity: 1; }
.cc-label { font-size: 11px; }
@media (max-width: 767px) { .cc-label { display: none; } }

.topbar-rol-badge {
  font-size: 11px; font-weight: 500;
  background: var(--accent-bg); color: var(--hdr2);
  padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--border);
  text-transform: capitalize;
}

/* User menu */
.user-menu { position: relative; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--hdr); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.user-dropdown {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 300;
}
.user-menu:focus-within .user-dropdown,
.user-menu:hover .user-dropdown { display: block; }
.user-name  { padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text); }
.user-email { padding: 0 14px 6px; font-size: 11px; color: var(--text3); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-item {
  display: block; padding: 7px 14px; font-size: 13px; color: var(--text2);
  transition: background 0.1s;
}
.dropdown-item:hover { background: var(--accent-bg); color: var(--hdr2); }

/* Flash messages */
.flash-container { padding: 8px 20px 0; }
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 6px;
}
.flash-error   { background: #fee2e2; color: #991b1b; }
.flash-success { background: #d1f0de; color: #1a5c38; }
.flash-warning { background: #fef3c7; color: #92400e; }
.flash-close   { font-size: 16px; background: none; border: none; cursor: pointer; color: inherit; }

/* Page content */
.page-content { flex: 1; padding: 20px; overflow-x: hidden; }

/* ==========================================================================
   COMPONENTES COMUNES
   ========================================================================== */

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.kpi-label  { font-size: 11px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing:.05em; margin-bottom:5px; }
.kpi-value  { font-family:'General Sans',sans-serif; font-size:26px; font-weight:600; color:var(--text); line-height:1; margin-bottom:3px; }
.kpi-delta  { font-size:12px; }
.delta-up   { color:var(--up); }
.delta-dn   { color:var(--dn); }
.kpi-sub    { font-size:10px; color:var(--text3); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.card-title {
  font-family: 'General Sans', sans-serif;
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-link { font-size:11px; color:var(--accent); font-weight:400; font-family:var(--font); }

/* Filter bar */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { height: 3px; }
.filter-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.filter-label { font-size:12px; color:var(--text3); font-weight:500; white-space:nowrap; flex-shrink:0; }
.filter-btn {
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface); font-size:12px; color:var(--text2);
  white-space: nowrap; flex-shrink: 0;
  font-family: var(--font);
  transition: background 0.12s, border-color 0.12s;
}
.filter-btn:hover { background:var(--accent-bg); border-color:var(--accent); }
.filter-btn.active { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:500; }

/* Badges / pills */
.pill {
  display: inline-block; padding:2px 8px; border-radius:10px;
  font-size:10px; font-weight:600;
}
.pill-up   { background:#dcfce7; color:var(--up); }
.pill-dn   { background:#fee2e2; color:var(--dn); }
.pill-warn { background:#fef3c7; color:#92400e; }
.pill-info { background:#dbeafe; color:#1e40af; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width:100%; border-collapse:collapse; font-size:13px; }
.data-table th {
  text-align:left; color:var(--text3); font-size:11px; font-weight:500;
  padding:0 10px 8px; border-bottom:1px solid var(--border);
  white-space:nowrap;
}
.data-table td {
  padding:9px 10px; border-bottom:1px solid var(--border); color:var(--text2);
}
.data-table tr:last-child td { border-bottom:none; }
.data-table tr:hover td { background:var(--accent-bg); }

/* Buttons */
.btn-primary {
  padding:8px 18px; border-radius:8px;
  background:var(--accent); color:#fff;
  font-size:13px; font-weight:500; font-family:var(--font);
  transition:background 0.12s;
}
.btn-primary:hover { background:var(--hdr2); }
.btn-secondary {
  padding:8px 16px; border-radius:8px;
  background:var(--surface); color:var(--text2);
  border:1px solid var(--border);
  font-size:13px; font-family:var(--font);
}
.btn-secondary:hover { background:var(--accent-bg); }
.btn-danger {
  padding:6px 14px; border-radius:7px;
  background:#fee2e2; color:var(--dn);
  border:1px solid #fecaca;
  font-size:12px; font-family:var(--font);
}

/* Forms */
.form-label { display:block; font-size:12px; font-weight:500; color:var(--text2); margin-bottom:5px; }
.form-input, .form-select {
  width:100%; padding:8px 12px;
  border:1px solid var(--border); border-radius:7px;
  font-size:13px; font-family:var(--font); color:var(--text);
  background:var(--surface);
}
.form-input:focus, .form-select:focus {
  outline:none; border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(61,175,114,0.15);
}
.form-file {
  width:100%; padding:6px;
  border:1px dashed var(--border); border-radius:7px;
  font-size:12px; color:var(--text2);
  background:var(--accent-bg);
}

/* Modal */
.modal-backdrop {
  position:fixed; inset:0;
  background:rgba(0,0,0,0.4);
  z-index:500;
  display:flex; align-items:center; justify-content:center;
  padding:16px;
}
.modal {
  background:var(--surface);
  border-radius:12px;
  width:100%; max-width:440px;
  overflow:hidden;
}
.modal-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid var(--border);
}
.modal-title { font-family:'General Sans',sans-serif; font-weight:600; font-size:15px; }
.modal-close { font-size:20px; color:var(--text3); padding:2px 6px; }
.modal-close:hover { color:var(--text); }
.modal-body   { padding:16px 20px; }
.modal-footer { padding:12px 20px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:8px; }
.upload-msg   { margin-top:10px; font-size:12px; padding:8px 12px; border-radius:7px; }
.upload-msg.ok  { background:#d1f0de; color:#1a5c38; }
.upload-msg.err { background:#fee2e2; color:#991b1b; }

/* Bottom nav — hidden by default */
.bottom-nav { display:none; }

/* ==========================================================================
   RESPONSIVE — TABLET  (768px – 1023px)
   ========================================================================== */
@media (max-width: 1023px) {

  :root { --sidebar-w: 52px; }

  .nav-label,
  .nav-section-label,
  .logo-text,
  .sidebar-razones { display:none; }

  .nav-item { justify-content:center; padding:10px; margin:2px 6px; }
  .nav-ico  { opacity:1; }

  .sidebar-logo { justify-content:center; padding:0; }
  .logo-box     { width:28px; height:28px; font-size:11px; }

  .hamburger { display:flex; }

  .kpi-grid { grid-template-columns:repeat(2, minmax(0,1fr)); }

  .btn-upload .btn-label { display:none; }
  .btn-upload { padding:6px 8px; }
}

/* ==========================================================================
   RESPONSIVE — MOBILE  (<768px)
   ========================================================================== */
@media (max-width: 767px) {

  :root {
    --sidebar-w:    260px;
    --bottomnav-h:  60px;
  }

  /* Sidebar se convierte en drawer lateral */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    height: 100%;
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display:block; }

  /* En mobile el sidebar muestra etiquetas completas */
  .nav-label,
  .nav-section-label,
  .logo-text,
  .sidebar-razones { display: revert; }
  .nav-item { justify-content:flex-start; padding:8px 12px; margin:1px 8px; }
  .sidebar-logo { justify-content:flex-start; padding:0 16px; }
  .logo-box { width:32px; height:32px; font-size:13px; }
  .sidebar-close { display:flex; }

  /* Topbar */
  .hamburger { display:flex; }
  .topbar-rol-badge { display:none; }
  .topbar { padding:0 14px; }

  /* KPIs */
  .kpi-grid { grid-template-columns:repeat(2, minmax(0,1fr)); gap:8px; }
  .kpi-value { font-size:22px; }

  /* Content */
  .page-content { padding:14px; }

  /* Bottom nav */
  .bottom-nav {
    display:flex;
    position:fixed; bottom:0; left:0; right:0;
    height:var(--bottomnav-h);
    background:var(--surface);
    border-top:1px solid var(--border);
    z-index:150;
    align-items:stretch;
  }
  .bn-item {
    flex:1; display:flex; flex-direction:column;
    align-items:center; justify-content:center; gap:3px;
    font-size:10px; color:var(--text3);
    background:none; border:none;
    font-family:var(--font);
    padding:0;
    transition:color 0.12s;
  }
  .bn-item.active, .bn-item:hover { color:var(--accent); }

  /* Tables scroll horizontal */
  .table-wrap { margin:0 -14px; padding:0 14px; }
}

/* ==========================================================================
   PANTALLAS MUY PEQUEÑAS  (<380px)
   ========================================================================== */
@media (max-width: 379px) {
  .kpi-grid { grid-template-columns:1fr; }
  .kpi-value { font-size:20px; }
}
