@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --text: #1F2937;
    --text-strong: #111827;
    --text-muted: #6B7280;
    --accent: #4F46E5;
    --accent-hover: #4338CA;
    --accent-soft: #EEF2FF;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

[x-cloak] { display: none !important; }

/* ---- Login ---- */
.login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    width: 320px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}

.login-box h1 { margin: 0; font-size: 1.6rem; color: var(--text-strong); }
.login-box .subtitle { margin: 0 0 1.5rem; color: var(--text-muted); font-size: .85rem; }
.login-box label { display: block; margin-top: 1rem; font-size: .8rem; color: var(--text-muted); }
.login-box input {
    width: 100%;
    padding: .55rem .6rem;
    margin-top: .3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
}
.login-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-box button {
    width: 100%;
    margin-top: 1.5rem;
    padding: .65rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: .95rem;
    cursor: pointer;
}
.login-box button:disabled { opacity: .6; cursor: default; }
.login-box .error { color: #d64545; font-size: .8rem; margin-top: .8rem; }

/* ---- App layout ---- */
.app-layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--surface);
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 1.2rem;
    font-weight: 700;
    color: var(--text-strong);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}
.sidebar-brand img { display: block; max-width: 100%; }

.sidebar nav { display: flex; flex-direction: column; padding: .5rem 0; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem 1.2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .9rem;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; }
.nav-icon svg { width: 100%; height: 100%; }

.nav-item:hover { background: var(--bg); color: var(--text-strong); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); }

.nav-item.sub { padding-left: 2.6rem; font-size: .85rem; }
.nav-item.disabled { opacity: .55; cursor: default; }
.nav-item.disabled:hover { background: none; color: var(--text-muted); }

.nav-group-header {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem 1.2rem;
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: color .15s ease;
}
.nav-group-header:hover { color: var(--text-strong); }
.nav-group-chevron {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform .15s ease;
}
.nav-group-chevron.open { transform: rotate(90deg); }

.nav-soon {
    margin-left: auto;
    font-size: .68rem;
    font-weight: 600;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: #F3F4F6;
    color: var(--text-muted);
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
    height: 64px;
    padding: 0 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .9rem;
}

.topbar-brand { display: flex; align-items: center; gap: .7rem; }
.topbar-brand img { display: block; }
.topbar-brand-sep {
    font-weight: 600;
    color: var(--text-strong);
    padding-left: .7rem;
    border-left: 1px solid var(--border);
}

.company-selector select {
    padding: .4rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: .9rem;
}

.content { padding: 1.5rem; overflow-y: scroll; scrollbar-gutter: stable; flex: 1; }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .88rem; }
.data-table th, .data-table td {
    text-align: left;
    padding: .65rem .9rem;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.empty-row { text-align: center; color: var(--text-muted); padding: 1.5rem; }

.table-search {
    max-width: 320px;
    margin-bottom: 1rem;
}

.row-actions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.row-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.row-actions a:hover { background: var(--accent-soft); color: var(--accent); }
.row-actions a.action-danger:hover { background: #FEE2E2; color: #B91C1C; }
.row-actions a.action-success:hover { background: #DCFCE7; color: #15803D; }
.action-icon { width: 16px; height: 16px; flex-shrink: 0; display: inline-flex; pointer-events: none; }
.action-icon svg { width: 100%; height: 100%; }
.action-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: .55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: default; transform: none; }
.btn-primary.disabled { opacity: .5; cursor: default; pointer-events: none; }

.form-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
}

.form-panel fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.2rem;
    padding: 1rem 1.2rem 1.4rem;
}
.form-panel legend { padding: 0 .4rem; font-weight: 600; color: var(--text-strong); font-size: .95rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.field label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .3rem; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; }
.field-wide { grid-column: 1 / -1; }
.field-error { color: #d64545; font-size: .75rem; margin: .3rem 0 0; }
.field-hint { color: var(--text-muted); font-size: .78rem; margin: .35rem 0 0; }
.field-hint strong { color: var(--text-strong); }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    align-items: center;
}

/* ---- Vista transitions ---- */
.view-fade-enter { transition: opacity .25s ease, transform .25s ease; }
.view-fade-enter-start { opacity: 0; transform: translateY(6px); }
.view-fade-enter-end { opacity: 1; transform: translateY(0); }

/* ---- KPIs ---- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: .3rem;
    transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15, 23, 42, .06); }

.kpi-value { font-size: 2rem; font-weight: 700; color: var(--text-strong); }
.kpi-label { font-size: .85rem; color: var(--text-muted); }

/* ---- Charts ---- */
.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    box-shadow: var(--shadow-card);
}
.chart-card h3 { margin: 0 0 .8rem; font-size: .95rem; color: var(--text-strong); }

/* ---- Status badges ---- */
.badge {
    display: inline-block;
    padding: .25rem .7rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-on_leave { background: #fef3c7; color: #92400e; }
.badge-terminated { background: #e5e7eb; color: #4b5563; }

/* ---- Badges de estatus de nomina ---- */
.badge-draft { background: #e5e7eb; color: #4b5563; }
.badge-calculated { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dbeafe; color: #1e40af; }
.badge-paid { background: #dcfce7; color: #166534; }

/* ---- Badges de estatus de permisos y vacaciones ---- */
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-aprobado { background: #dcfce7; color: #166534; }
.badge-rechazado { background: #fee2e2; color: #991b1b; }
.badge-cancelado { background: #e5e7eb; color: #4b5563; }

/* ---- Badges de estatus de asistencia ---- */
.badge-a_tiempo { background: #dcfce7; color: #166534; }
.badge-retardo { background: #fef3c7; color: #92400e; }
.badge-falta { background: #fee2e2; color: #991b1b; }

/* ---- Badges de estatus de vacantes ---- */
.badge-abierta { background: #dcfce7; color: #166534; }
.badge-pausada { background: #fef3c7; color: #92400e; }
.badge-cerrada { background: #e5e7eb; color: #4b5563; }

/* ---- Badges de estatus de postulaciones ---- */
.badge-en_revision { background: #e5e7eb; color: #4b5563; }
.badge-entrevista { background: #dbeafe; color: #1e40af; }
.badge-psicometricos { background: #ede9fe; color: #5b21b6; }
.badge-entrevista_psicologica { background: #ede9fe; color: #5b21b6; }
.badge-oferta { background: #fef3c7; color: #92400e; }
.badge-contratado { background: #dcfce7; color: #166534; }

/* ---- Badges de estatus de onboarding ---- */
.badge-en_proceso { background: #fef3c7; color: #92400e; }
.badge-completo { background: #dcfce7; color: #166534; }

/* ---- Badges de estatus de inscripciones a capacitacion ---- */
.badge-no_iniciado { background: #e5e7eb; color: #4b5563; }
.badge-en_curso { background: #fef3c7; color: #92400e; }
.badge-completado { background: #dcfce7; color: #166534; }

/* ---- Aviso de nomina (aproximacion ISR/IMSS) ---- */
.disclaimer-banner {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-sm);
    padding: .9rem 1.1rem;
    font-size: .88rem;
    margin-bottom: 1.2rem;
}
.disclaimer-banner.disclaimer-compact { font-size: .8rem; padding: .6rem .9rem; margin-bottom: 1rem; }

/* ---- Modal expediente ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 620px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .15);
}
.modal-panel-wide { max-width: 900px; }

.upload-row {
    display: flex;
    gap: .6rem;
    margin-bottom: 1rem;
}
.upload-row select { flex: 0 0 200px; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.upload-row input[type="file"] { flex: 1; font-size: .85rem; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
}
.doc-list li:last-child { border-bottom: none; }
.doc-meta { display: block; font-size: .78rem; color: var(--text-muted); }
.doc-actions { display: flex; gap: .3rem; }
.doc-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background .12s ease, color .12s ease;
}
.doc-actions a:hover { background: var(--accent-soft); color: var(--accent); }
.doc-actions a.action-danger:hover { background: #FEE2E2; color: #B91C1C; }
.doc-empty { color: var(--text-muted); font-size: .88rem; justify-content: center; }

/* ---- Skeleton loaders ---- */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #edf2f7 37%, #e2e8f0 63%);
    background-size: 400% 100%;
    animation: skeleton-pulse 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
.skeleton-line { height: 14px; margin-bottom: .6rem; }
.skeleton-row { height: 42px; margin-bottom: .5rem; border-radius: var(--radius-md); }
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Chips de filtro rapido ---- */
.chip-row { margin-bottom: 1rem; }
.chip {
    display: inline-block;
    padding: .35rem .9rem;
    margin-right: .5rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    background: #F3F4F6;
    color: var(--text);
    cursor: pointer;
    border: none;
    transition: background .15s ease, color .15s ease;
}
.chip.active { background: var(--accent); color: #fff; }

/* ---- Selector de dias (turnos) ---- */
.day-picker { display: flex; gap: .4rem; flex-wrap: wrap; }
.day-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: #F3F4F6;
    color: var(--text);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}
.day-chip input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.day-chip.active { background: var(--accent); color: #fff; }

.config-summary {
    margin: .3rem 0 0;
    font-size: .85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
}
.config-summary strong { color: var(--text); }
.config-summary a { display: inline-flex; align-items: center; gap: .3rem; color: var(--accent); }
.config-summary a:hover { color: var(--accent-hover); }

/* ---- Sub-panel de contratos dentro del perfil ---- */
.sub-panel { margin-top: 1.5rem; }
.sub-panel .view-header { margin-bottom: .8rem; }
.sub-panel h3 { margin: 0; font-size: 1rem; color: var(--text-strong); }

/* ---- Organigrama (arbol solo-CSS, tecnica clasica con conector padre-hijos) ---- */
.org-tree-wrap { overflow-x: auto; padding: 1rem 0 .5rem; }
.org-tree, .org-tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}
.org-tree ul { padding-top: 20px; position: relative; }
.org-tree li {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 20px 10px 0 10px;
}
/* barra horizontal entre hermanos + linea vertical propia hacia su tarjeta */
.org-tree li::before, .org-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    width: 50%;
    height: 20px;
    border-top: 2px solid var(--border);
}
.org-tree li::before { right: 50%; }
.org-tree li::after { left: 50%; border-left: 2px solid var(--border); }
.org-tree li:only-child::before, .org-tree li:only-child::after { display: none; }
.org-tree li:only-child { padding-top: 0; }
.org-tree li:first-child::before, .org-tree li:last-child::after { border: 0 none; }
.org-tree li:last-child::before { border-right: 2px solid var(--border); border-radius: 0 6px 0 0; }
.org-tree li:first-child::after { border-radius: 6px 0 0 0; }
/* linea vertical del padre bajando hacia la barra de sus hijos */
.org-tree ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 20px;
    border-left: 2px solid var(--border);
}
/* la raiz del arbol no necesita ninguno de estos conectores */
.org-tree > li::before, .org-tree > li::after { display: none; }
.org-tree > li { padding-top: 0; }
.org-node {
    display: inline-flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: .55rem .85rem;
    box-shadow: var(--shadow-card);
    min-width: 150px;
    white-space: nowrap;
    cursor: pointer;
    transition: box-shadow .12s ease, border-color .12s ease;
}
.org-node:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(79,70,229,.12); }
.org-node strong { color: var(--text-strong); font-size: .85rem; }
.org-node span { color: var(--text-muted); font-size: .74rem; }
.org-node.org-node-circular { cursor: default; border-color: #DC2626; }
.org-node.org-node-circular:hover { box-shadow: none; }
.org-node.org-node-circular span { color: #DC2626; }
