/* =========================================================
   Base / reset / design tokens
   Mobile-first, 375px -> 2560px
   ========================================================= */

:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-text: #1a1d21;
    --color-text-muted: #5a6472;
    --color-border: #d9dee3;
    --color-primary: #1a73e8;
    --color-primary-dark: #1557b0;
    --color-primary-contrast: #ffffff;
    --color-danger: #c62828;
    --color-danger-bg: #fdecea;
    --color-success: #1e7e34;
    --color-success-bg: #e6f4ea;
    --color-warning: #b25e00;
    --color-warning-bg: #fff2df;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 24, 30, 0.08), 0 1px 2px rgba(20, 24, 30, 0.06);
    --font-sans: 'Inter', Arial, sans-serif;
    --font-serif: 'Instrument Serif', Georgia, serif;
    --focus-ring: 3px solid #1a73e8;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #14171a;
        --color-surface: #1e2226;
        --color-text: #eef0f2;
        --color-text-muted: #9aa4b0;
        --color-border: #333a41;
        --color-primary: #4f9cff;
        --color-primary-dark: #7ab6ff;
        --color-primary-contrast: #0b0f13;
        --color-danger: #ff6b6b;
        --color-danger-bg: #3a1c1c;
        --color-success: #4ad06d;
        --color-success-bg: #16321f;
        --color-warning: #ffb74d;
        --color-warning-bg: #3a2a10;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    }
}

* , *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 16px;
}

h1, h2, h3 {
    font-family: var(--font-serif);
    line-height: 1.2;
    margin: 0 0 0.5em;
    font-weight: 400;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.7rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

a {
    color: var(--color-primary);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    padding: 0.75rem 1rem;
    z-index: 1000;
    border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
    left: 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: 1rem;
}

@media (min-width: 640px) {
    .container { padding-inline: 1.5rem; }
}

@media (min-width: 1440px) {
    .container { max-width: 1400px; }
}

@media (min-width: 2000px) {
    .container { max-width: 1600px; }
}

/* Layout shell */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding-block: 1.5rem 3rem;
}

/* Barra superior con el logo (o nombre) de la empresa, usada en las
   páginas públicas (p.ej. el autoservicio del empleado). */
.company-topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.85rem 1rem;
    text-align: center;
}

.company-topbar-logo {
    display: inline-block;
    max-height: 48px;
    max-width: 220px;
    width: auto;
    height: auto;
}

.company-topbar-name {
    display: inline-block;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.9rem;
}

/* Cards / surfaces */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

@media (min-width: 640px) {
    .card { padding: 1.75rem; }
}

/* Forms */

.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.field .hint {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="color"],
select,
textarea {
    width: 100%;
    font: inherit;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
}

textarea { resize: vertical; }

.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.checkbox-field input { margin-top: 0.25rem; }

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0 0 1.1rem;
}

legend {
    font-weight: 600;
    padding-inline: 0.4rem;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-weight: 600;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
    line-height: 1.2;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    min-height: 36px;
    font-size: 0.85rem;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Flash messages */

.flash {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.flash-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success); }
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger); }
.flash-info { background: #e8f0fe; color: var(--color-primary-dark); border-color: var(--color-primary); }

@media (prefers-color-scheme: dark) {
    .flash-info { background: #16233a; }
}

/* Tables */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

th, td {
    text-align: left;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.92rem;
    vertical-align: top;
}

th {
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

/* Columna de acciones en tablas: rejilla fija de 2 columnas para que los
   botones no se descoloquen según lo que ocupen el resto de columnas de esa fila. */
.table-actions {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 0.4rem;
    align-items: stretch;
}

.table-actions form {
    display: contents;
}

.table-actions .btn {
    width: 100%;
}

/* Utility */

.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--color-border);
}
.badge-on { background: var(--color-success-bg); color: var(--color-success); }
.badge-off { background: var(--color-danger-bg); color: var(--color-danger); }

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Selector de sedes: recuadro contenedor con dos columnas (seleccionadas /
   disponibles), una franja central con flechas, y arrastrar-soltar. */

.sede-picker {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    padding: 1rem;
}

.sede-picker-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .sede-picker-body {
        grid-template-columns: 1fr auto 1fr;
        align-items: stretch;
    }
}

.sede-picker-col {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.85rem;
    min-height: 150px;
}

.sede-picker-title {
    margin: 0 0 0.15rem;
    font-size: 0.9rem;
    font-weight: 700;
}

.sede-picker-hint {
    margin: 0 0 0.65rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.sede-picker-divider {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    padding: 0.25rem 0;
    border-top: 1px dashed var(--color-border);
}

@media (min-width: 640px) {
    .sede-picker-divider {
        flex-direction: column;
        justify-content: center;
        padding: 0 0.35rem;
        border-top: none;
        border-left: 1px dashed var(--color-border);
        border-right: 1px dashed var(--color-border);
    }
}

.sede-picker-arrow {
    min-width: 40px;
    min-height: 40px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text);
}

.sede-picker-arrow:hover {
    border-color: var(--color-primary);
    color: var(--color-primary-contrast);
    background: var(--color-primary);
}

.sede-pick-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 2.5rem;
}

.sede-pick-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.4rem 0.55rem;
    cursor: grab;
}

.sede-pick-item.is-dragging {
    opacity: 0.4;
}

.sede-pick-item[aria-selected="true"] {
    border-color: var(--color-primary);
    background: #e8f0fe;
    box-shadow: 0 0 0 1px var(--color-primary);
}

@media (prefers-color-scheme: dark) {
    .sede-pick-item[aria-selected="true"] {
        background: #16233a;
    }
}

.sede-pick-handle {
    color: var(--color-text-muted);
    user-select: none;
}

.sede-pick-name {
    flex: 1;
    font-size: 0.88rem;
    word-break: break-word;
}

.sede-pick-move {
    display: flex;
    gap: 0.2rem;
}

/* Reordenar solo tiene sentido dentro de "seleccionadas": estos botones se
   ocultan automáticamente en "disponibles" y reaparecen solos si la sede
   se mueve a "seleccionadas" (arrastrando o con las flechas centrales). */
[data-sede-list="disponibles"] .sede-pick-move {
    display: none;
}

.sede-pick-move button {
    min-height: 28px;
    min-width: 28px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    color: var(--color-text);
}

.sede-pick-move button:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.sede-pick-empty-msg {
    font-size: 0.85rem;
    margin: 0.5rem 0 0;
}
