/* ─── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg2: #f7f8fa;
  --bg3: #eef0f3;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e2e5ea;
  --border2: #cbd0d8;
  --green: #4CAF8A;
  --blue: #5B8DD9;
  --orange: #E5834A;
  --purple: #9B6DD6;
  --red: #e05c5c;
  --radius: 8px;
  --radius-lg: 12px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       font-size: 14px; color: var(--text); background: var(--bg2); }

a { color: inherit; text-decoration: none; }

/* ─── Login ─────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: var(--bg2); }
.login-card { background: var(--bg); border: 1px solid var(--border);
              border-radius: var(--radius-lg); padding: 40px; width: 100%;
              max-width: 380px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.login-card h1 { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 28px; }
.btn-login { width: 100%; background: var(--text); color: white; border: none;
             border-radius: var(--radius); padding: 10px; font-size: 14px;
             font-weight: 500; cursor: pointer; margin-top: 8px; }
.btn-login:hover { opacity: 0.88; }

/* ─── Navbar ─────────────────────────────────────────────── */
.navbar { background: var(--bg); border-bottom: 1px solid var(--border);
          display: flex; align-items: center; gap: 24px; padding: 0 24px;
          height: 52px; position: sticky; top: 0; z-index: 100; }
.nav-brand { display: flex; align-items: center; gap: 8px;
             font-weight: 600; font-size: 15px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link { padding: 6px 12px; border-radius: var(--radius); color: var(--muted);
            font-size: 13px; transition: background 0.1s; }
.nav-link:hover { background: var(--bg2); color: var(--text); }
.nav-link.active { background: var(--bg2); color: var(--text); font-weight: 500; }
.nav-user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav-username { font-size: 13px; color: var(--muted); }
.nav-logout { font-size: 13px; color: var(--muted); padding: 5px 10px;
              border: 1px solid var(--border); border-radius: var(--radius); }
.nav-logout:hover { background: var(--bg2); }

/* ─── Layout ─────────────────────────────────────────────── */
.page-content { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ─── Toolbar ────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
           flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-center { display: flex; gap: 8px; flex: 1; justify-content: center; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.month-title { font-size: 17px; font-weight: 600; min-width: 180px; text-align: center; }

.btn-icon { background: none; border: 1px solid var(--border); border-radius: var(--radius);
            width: 32px; height: 32px; cursor: pointer; font-size: 18px; color: var(--text);
            display: flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--bg2); }

.select-filter { border: 1px solid var(--border); border-radius: var(--radius);
                 padding: 6px 10px; font-size: 13px; background: var(--bg);
                 color: var(--text); cursor: pointer; }

.btn-view { background: none; border: 1px solid var(--border); border-radius: var(--radius);
            padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.btn-view.active, .btn-view:hover { background: var(--bg2); color: var(--text); }

.btn-primary { background: var(--text); color: white; border: none;
               border-radius: var(--radius); padding: 7px 14px; font-size: 13px;
               font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: none; border: 1px solid var(--border2); border-radius: var(--radius);
                 padding: 7px 14px; font-size: 13px; cursor: pointer; color: var(--text); }
.btn-secondary:hover { background: var(--bg2); }
.btn-danger { background: var(--red); color: white; border: none;
              border-radius: var(--radius); padding: 7px 14px; font-size: 13px; cursor: pointer; }

/* ─── Stats ──────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--bg); border: 1px solid var(--border);
             border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-val { font-size: 24px; font-weight: 600; }
.accent-green { color: var(--green); }
.accent-orange { color: var(--orange); }
.accent-red { color: var(--red); }

/* ─── Calendario ─────────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-head { text-align: center; font-size: 12px; font-weight: 500; color: var(--muted);
            padding: 6px 0; }
.cal-day { min-height: 90px; background: var(--bg); border: 1px solid var(--border);
           border-radius: var(--radius); padding: 6px 7px; cursor: pointer; transition: border-color 0.1s; }
.cal-day:hover { border-color: var(--border2); }
.cal-day.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day.weekend { background: #d7dce4  ; border-color: var(--bg3); }
.cal-day.weekend .day-num { color: #97999e ; }
.cal-day.today { border-color: var(--green); }
.day-num { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.day-chips { display: flex; flex-direction: column; gap: 2px; }
.chip { font-size: 10px; padding: 2px 5px; border-radius: 4px; font-weight: 500;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-vacaciones { background: #e8f7f1; color: #2d8a65; }
.chip-libre      { background: #e8eef9; color: #3a5fa0; }
.chip-permiso    { background: #efe6fb; color: #7c3aed; }
.chip-baja       { background: #fdf0e8; color: #a05020; }
.chip-festivo    { background: #f4e3b8; color: #8a6516; }
/* Medio día: se subraya para distinguirlo del día entero */
.chip-medio      { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 1px; }
.cal-day.festivo { background: #fcf4e4; border-color: #f0e2c0; }
.cal-day.festivo .day-num { color: #a07818; }

/* ─── Resumen table ──────────────────────────────────────── */
.resumen-table { width: 100%; border-collapse: collapse; background: var(--bg); }
.resumen-table th { background: var(--bg2); font-size: 12px; font-weight: 500;
                    color: var(--muted); padding: 10px 14px; text-align: left;
                    border-bottom: 1px solid var(--border); }
.resumen-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.resumen-table tr:last-child td { border-bottom: none; }
.resumen-table tr:hover td { background: var(--bg2); }

/* Contenedor con scroll — encabezado fijo, máximo ~10 filas visibles */
.table-scroll { max-height: 450px; overflow-y: auto;
                border: 1px solid var(--border); border-radius: var(--radius-lg); }
.table-scroll .resumen-table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--bg2);
  box-shadow: inset 0 -1px 0 var(--border); border-bottom: none; }

.bar-bg { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden;
          width: 80px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--green); }

.emp-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block;
           margin-right: 7px; vertical-align: middle; flex-shrink: 0; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.4);
            display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: var(--bg); border-radius: var(--radius-lg);
         border: 1px solid var(--border); width: 100%; max-width: 440px;
         box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.modal-sm { max-width: 360px; }
.modal-wide { max-width: 920px; }
.modal-wide .modal-body { max-height: 75vh; overflow-y: auto; }

/* ─── Ficha empleado ─────────────────────────────────────── */
.ficha-meta { font-size: 13px; color: var(--muted); }
.ficha-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ficha-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px;
                color: var(--muted); align-items: center; }
.ficha-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.lg-box { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* Calendario anual mini */
.year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.mini-month { }
.mini-month h4 { font-size: 12px; font-weight: 600; margin-bottom: 6px; text-align: center; }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mini-dow { font-size: 9px; color: var(--muted); text-align: center; padding: 2px 0; }
.mini-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
            font-size: 10px; border-radius: 4px; color: var(--text);
            border: 1px solid transparent; }
.mini-day.empty { visibility: hidden; }
.mini-day.clickable { cursor: pointer; }
.mini-day.clickable:hover { outline: 2px solid var(--text); outline-offset: -2px; filter: brightness(0.97); }
.mini-day.off { color: var(--border2); background: var(--bg2); }      /* finde / festivo */
.mini-day.today { outline: 2px solid var(--text); outline-offset: -2px; }
/* Disfrutado = sólido / Pendiente = borde */
.md-vacaciones.done    { background: var(--green);  color: #fff; }
.md-vacaciones.pending { border-color: var(--green);  color: #2d8a65; background: #e8f7f1; }
.md-libre.done         { background: var(--blue);   color: #fff; }
.md-libre.pending      { border-color: var(--blue);   color: #3a5fa0; background: #e8eef9; }
.md-permiso.done       { background: #7c3aed;       color: #fff; }
.md-permiso.pending    { border-color: #7c3aed;       color: #7c3aed; background: #efe6fb; }
.md-baja.done          { background: var(--red);    color: #fff; }
.md-baja.pending       { border-color: var(--red);    color: #a05020; background: #fdf0e8; }
/* Medio día libre: subrayado para distinguirlo del día entero */
.mini-day.md-medio     { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 1px; }

@media (max-width: 760px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
  .ficha-stats { grid-template-columns: repeat(2, 1fr); }
}
.modal-header { display: flex; align-items: center; justify-content: space-between;
                padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 16px; cursor: pointer;
               color: var(--muted); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg2); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border);
                display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Form fields ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input, .field select, .select-full {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-size: 13px; color: var(--text);
  background: var(--bg); width: 100%; }
.field input:focus, .field select:focus { outline: none; border-color: var(--border2); }
.select-full { border: 1px solid var(--border); border-radius: var(--radius);
               padding: 8px 10px; font-size: 13px; width: 100%; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ─── Legends ────────────────────────────────────────────── */
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.leg-swatch { width: 12px; height: 12px; border-radius: 3px; }

/* ─── Leyenda colores tipo ───────────────────────────────── */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-vacaciones { background: #e8f7f1; color: #2d8a65; }
.tag-libre      { background: #e8eef9; color: #3a5fa0; }
.tag-permiso    { background: #efe6fb; color: #7c3aed; }
.tag-baja       { background: #fdf0e8; color: #a05020; }

/* ─── Multiselect departamentos ──────────────────────────── */
.ms-dropdown { position: relative; display: inline-block; }
.ms-toggle { display: inline-flex; align-items: center; justify-content: space-between;
             gap: 8px; min-width: 210px; cursor: pointer; background: var(--bg); text-align: left; }
.ms-caret { color: var(--muted); font-size: 10px; }
.ms-menu { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 150;
           background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
           box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; min-width: 250px;
           max-height: 340px; overflow-y: auto; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px;
          border-radius: 6px; font-size: 13px; cursor: pointer; }
.ms-opt:hover { background: var(--bg2); }
.ms-opt input { width: 15px; height: 15px; cursor: pointer; flex: none; }
.ms-group { font-weight: 600; }
.ms-sep { height: 1px; background: var(--border); margin: 5px 2px; }

@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { margin-left: 0; }
}

/* ─── Multiselect departamentos ──────────────────────────── */
.ms-dropdown { position: relative; display: inline-block; }
.ms-toggle { display: inline-flex; align-items: center; justify-content: space-between;
             gap: 8px; min-width: 210px; cursor: pointer; background: var(--bg); text-align: left; }
.ms-caret { color: var(--muted); font-size: 10px; }
.ms-menu { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 150;
           background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
           box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; min-width: 250px;
           max-height: 340px; overflow-y: auto; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px;
          border-radius: 6px; font-size: 13px; cursor: pointer; }
.ms-opt:hover { background: var(--bg2); }
.ms-opt input { width: 15px; height: 15px; cursor: pointer; flex: none; }
.ms-group { font-weight: 600; }
.ms-sep { height: 1px; background: var(--border); margin: 5px 2px; }
