/* =========================================================
   UI Kit — design system de la pasada UI/UX (F0)
   Scaffolding de página + componentes compartidos de Components/
   (PageHeader, StatCard, StatusChip, EmptyState, BulkActionBar).
   REGLA: aquí NO se definen colores nuevos; solo se consumen las
   variables de app-theme.css (única fuente de verdad de color).
   ========================================================= */

/* -------------------------------------------------------
   1. Scaffolding de página
   .page envuelve el contenido de cada página: padding
   consistente, columna con gap y entrada animada escalonada.
   ------------------------------------------------------- */
.page {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 28px 90px; /* hueco inferior para la bulk-bar flotante */
    max-width: 1700px;
    width: 100%;
    margin: 0 auto;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.page > * { animation: fade-up .32s ease-out backwards; }
.page > *:nth-child(2) { animation-delay: .05s; }
.page > *:nth-child(3) { animation-delay: .10s; }
.page > *:nth-child(4) { animation-delay: .15s; }
.page > *:nth-child(n+5) { animation-delay: .20s; }

@media (prefers-reduced-motion: reduce) {
    .page > * { animation: none; }
}

/* El contenido de la app respira sobre fondo alterno; las cards
   blancas (grids, formularios) destacan encima. */
.rz-body { background: var(--color-bg-alt); }

/* -------------------------------------------------------
   2. PageHeader — título + eyebrow (sección) + acciones
   ------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-eyebrow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--color-primary);
    margin: 0 0 3px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--color-text);
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 4px 0 0;
    max-width: 720px;
}

.page-header .page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* -------------------------------------------------------
   3. Stat strip — tira de KPIs (clicables como filtros)
   ------------------------------------------------------- */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 12px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 13px 16px 13px 19px;
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

/* Barra de acento por tono (identidad sin teñir el dato) */
.stat-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--color-neutral-light);
}
.stat-card.tone-primary::before { background: var(--color-primary); }
.stat-card.tone-success::before { background: var(--color-success); }
.stat-card.tone-warning::before { background: var(--color-warning); }
.stat-card.tone-danger::before  { background: var(--color-danger); }
.stat-card.tone-pending::before { background: var(--color-pending); }

.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}
.stat-card.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary) inset, var(--shadow-sm);
    background: var(--color-accent-faint);
}

.stat-card .stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}
.stat-card.tone-danger .stat-value  { color: var(--color-danger); }
.stat-card.tone-warning .stat-value { color: var(--color-warning); }

.stat-card .stat-hint {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* -------------------------------------------------------
   4. FilterBar — barra única de filtros de página
   ------------------------------------------------------- */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 16px;
}

.filter-bar .filter-spacer { flex: 1; }

/* -------------------------------------------------------
   5. StatusChip — píldora de estado con punto de color
   Usa los colores semánticos de estado del tema.
   ------------------------------------------------------- */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid;
    white-space: nowrap;
}

.status-chip .chip-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-chip.chip-approved   { color: var(--color-state-approved);   background: var(--color-state-approved-bg);   border-color: var(--color-state-approved-border); }
.status-chip.chip-pending    { color: #9c7a00;                       background: var(--color-state-pending-bg);    border-color: var(--color-state-pending-border); }
.status-chip.chip-rejected   { color: var(--color-state-rejected);   background: var(--color-state-rejected-bg);   border-color: var(--color-state-rejected-border); }
.status-chip.chip-unassigned { color: var(--color-state-unassigned); background: var(--color-state-unassigned-bg); border-color: var(--color-state-unassigned-border); }
.status-chip.chip-neutral    { color: var(--color-state-neutral);    background: var(--color-state-neutral-bg);    border-color: var(--color-state-neutral-border); }
.status-chip.chip-primary    { color: var(--color-primary-dark);     background: var(--color-surface);             border-color: var(--color-accent); }

/* -------------------------------------------------------
   6. EmptyState — estado vacío cuidado
   ------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 48px 24px;
    text-align: center;
}

.empty-state .empty-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--color-bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.empty-state .empty-icon .rzi { font-size: 28px; color: var(--color-placeholder); }
.empty-state .empty-title    { font-size: 15px; font-weight: 600; color: var(--color-text); }
.empty-state .empty-message  { font-size: 13px; color: var(--color-text-muted); max-width: 440px; }
.empty-state .empty-action   { margin-top: 10px; }

/* -------------------------------------------------------
   7. BulkActionBar — barra flotante de acciones masivas
   Pill oscura inferior centrada; el contador usa el acento.
   ------------------------------------------------------- */
.bulk-bar {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-tooltip-bg);
    color: var(--color-text-on-dark);
    border-radius: 999px;
    padding: 8px 10px 8px 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .28);
    animation: bulk-pop .25s cubic-bezier(.2, .9, .3, 1.2) backwards;
}

@keyframes bulk-pop {
    from { opacity: 0; transform: translateX(-50%) translateY(14px); }
}

.bulk-bar .bulk-count { font-size: 13px; font-weight: 600; white-space: nowrap; }
.bulk-bar .bulk-count b { color: var(--color-accent); font-size: 15px; }

/* Botones Radzen dentro de la barra oscura */
.bulk-bar .rz-button.rz-variant-text { color: var(--color-text-on-dark) !important; }
.bulk-bar .rz-button.rz-variant-text:hover { background: rgba(255, 255, 255, .12) !important; }

/* -------------------------------------------------------
   8. Sidebar — grupos por flujo de trabajo + ítem activo
   Activo = barra izquierda primaria + fondo surface + texto
   verde oscuro (sustituye al bloque verde pleno anterior).
   ------------------------------------------------------- */
.nav-group-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 16px 18px 6px;
    user-select: none;
}

.nav-group-label:first-child { padding-top: 10px; }

/* Etiqueta de grupo plegable: clicable, con chevron a la derecha */
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 6px;
    transition: color .12s ease;
}
.nav-group-toggle:hover { color: var(--color-primary-dark); }
.nav-group-toggle .nav-group-chevron { font-size: 15px; opacity: .55; }

/* Separador sutil cuando el sidebar está plegado (sin etiquetas) */
.nav-group-separator {
    height: 1px;
    background: var(--sidebar-border);
    margin: 10px 12px;
}

.rz-sidebar .rz-navigation-item-wrapper {
    border-left: 3px solid transparent;
    transition: background-color .12s ease;
}

.rz-sidebar .rz-navigation-item-wrapper-active {
    border-left-color: var(--color-primary);
    background-color: var(--color-surface);
}

.rz-sidebar .rz-navigation-item-wrapper-active .rz-navigation-item-link,
.rz-sidebar .rz-navigation-item-wrapper-active .rz-navigation-item-link .rzi:not(.rz-navigation-item-icon-children) {
    color: var(--color-primary-dark);
    font-weight: 600;
}

.rz-sidebar .rz-navigation-item-link { font-size: 13.5px; }

/* -------------------------------------------------------
   9. Pulido de grids — cabeceras tipográficas (uppercase)
   ------------------------------------------------------- */
.rz-data-grid .rz-grid-table thead th .rz-column-title,
.rz-data-grid .rz-grid-table thead th .rz-column-title-content {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--color-text-muted);
}

/* -------------------------------------------------------
   10. Tarjeta de sección con cabecera (listas del dashboard,
   paneles laterales de detalle…)
   ------------------------------------------------------- */
.section-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
}

.section-card .section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--card-border);
}

.section-card .section-card-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--color-text-muted);
    margin: 0;
}

.section-card .section-card-body { padding: 8px 0; }
.section-card .section-card-body.padded { padding: 16px; }

/* -------------------------------------------------------
   11. Filas de lista (dentro de section-card): clicables,
   con título/subtítulo y zona lateral (chips, fechas)
   ------------------------------------------------------- */
.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-bg-alt);
    transition: background-color .12s ease;
}

.list-row:last-child { border-bottom: none; }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover { background: var(--color-bg-alt); }

.list-row .row-main { flex: 1; min-width: 0; }

.list-row .row-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-row .row-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-row .row-side {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* -------------------------------------------------------
   11b. PageLoader — logo animado centrado mientras carga
   ------------------------------------------------------- */
.page-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 90px 24px;
}

.page-loader img {
    width: 88px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .08));
}

.page-loader .page-loader-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: .4px;
}

/* -------------------------------------------------------
   11c. DateRangePicker — desde→hasta unidos
   ------------------------------------------------------- */
.date-range {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.date-range .date-range-sep {
    color: var(--color-text-muted);
    font-size: 14px;
    padding-bottom: 14px;
}

/* -------------------------------------------------------
   11d. FilterBar: que los FormField no encojan su contenido
   (valores cortados en dropdowns/fechas de los filtros)
   ------------------------------------------------------- */
.filter-bar .rz-form-field { min-width: 150px; }
.filter-bar .rz-form-field-content { min-width: 0; }
.filter-bar .rz-dropdown,
.filter-bar .rz-multiselect { min-width: 170px; }
.filter-bar .rz-inputtext { font-size: 13.5px; }

/* -------------------------------------------------------
   12. Grid de dos columnas (dashboard, detalles)
   ------------------------------------------------------- */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

@media (max-width: 1100px) {
    .grid-2col { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------
   13. Timeline de tablero (turnos día, fichajes día, overview día)
   Un ÚNICO contenedor de scroll: eje de horas sticky-top y
   columna de nombres sticky-left se mueven CON el contenido.
   ------------------------------------------------------- */
.board-scroll { overflow: auto; max-height: calc(100vh - 380px); min-height: 260px; }

.board-axis-row { display: flex; width: max-content; position: sticky; top: 0; z-index: 3;
    background: var(--rz-base-100); border-bottom: 1px solid var(--rz-base-300); }
.board-row { display: flex; width: max-content; height: 44px;
    border-bottom: 1px solid var(--rz-base-200); background: var(--card-bg); }
.board-label-col { width: 180px; min-width: 180px; display: flex; align-items: center; padding: 0 12px;
    position: sticky; left: 0; background: var(--rz-base-50); border-right: 1px solid var(--rz-base-300);
    z-index: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.axis-corner { height: 28px; background: var(--rz-base-100); z-index: 4; }
.board-track { position: relative; height: 44px; flex-shrink: 0; }
.axis-track { height: 28px; }
.axis-hour { position: absolute; top: 6px; font-size: 11px; color: var(--rz-text-secondary-color);
    border-left: 1px solid var(--rz-base-300); padding-left: 3px; height: 22px; }
.grid-bg { background-image:
    repeating-linear-gradient(to right, var(--rz-base-200) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(to right, var(--rz-base-100) 0 1px, transparent 1px 15px);
    cursor: pointer; }
.shift-block { position: absolute; top: 7px; height: 30px; border-radius: 6px; cursor: pointer;
    background: var(--rz-primary); color: var(--rz-primary-contrast, #fff); font-size: 11px;
    display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 6px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2); white-space: nowrap; }
.shift-block.crosses { border-radius: 6px 0 0 6px;
    background: linear-gradient(to right, var(--rz-primary) 70%, color-mix(in srgb, var(--rz-primary) 55%, transparent)); }
.shift-block.carry { background: transparent; border: 1px dashed var(--rz-primary); border-left: none;
    border-radius: 0 6px 6px 0; color: var(--rz-primary); box-shadow: none; cursor: default; opacity: .75;
    justify-content: flex-start; }
/* Turno PREVISTO como contorno (vista combinada del overview): el fichaje real va encima en sólido. */
.shift-block.outline { background: transparent; border: 1.5px dashed var(--rz-primary);
    color: var(--color-primary-dark); box-shadow: none; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--color-danger, #d9534f);
    z-index: 1; pointer-events: none; }

/* Punto de bandera dentro de un bloque/chip (color por tipo de bandera, a nivel de código). */
.wd-flag-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .8); flex-shrink: 0; }

/* Navegación de periodo: botones alineados y del mismo alto que el campo de fecha. */
.period-nav { display: flex; align-items: flex-end; gap: 4px; }
.period-nav .nav-btn { height: 41px; min-width: 41px; }
.view-bar { align-self: flex-end; height: 41px; }
.period-label { font-size: 13px; font-weight: 600; color: var(--color-text-muted); padding-bottom: 12px; }

/* Recarga sin salto: el contenido anterior se mantiene atenuado mientras llega el nuevo periodo
   (evita que los componentes "salten" al quedarse sin datos una fracción de segundo). */
.reloading { opacity: .55; pointer-events: none; transition: opacity .15s ease; }

/* -------------------------------------------------------
   14. NavMenu: animación de pliegue/despliegue de grupos
   (grid-template-rows 1fr→0fr anima a altura de contenido)
   ------------------------------------------------------- */
.nav-group-items {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows .25s ease;
}

.nav-group-items > * {
    overflow: hidden;
    min-height: 0;
}

.nav-group-items.collapsed { grid-template-rows: 0fr; }

.nav-group-chevron { transition: transform .25s ease; }
.nav-group-chevron.rotated { transform: rotate(-90deg); }

/* -------------------------------------------------------
   15. Leyendas de calendario (muestras de color; pendiente
   = barra rayada "incompleta"; festivo = muestra discontinua)
   ------------------------------------------------------- */
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
    font-size: 12px; color: var(--color-text-muted); padding: 4px 2px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.legend-swatch.striped { background: repeating-linear-gradient(45deg,
    var(--c) 0 5px, color-mix(in srgb, var(--c) 45%, white) 5px 10px); }
.legend-swatch.dashed { border: 1.5px dashed var(--color-text-muted); background: transparent; }

/* Segmento de COMIDA dentro de un bloque de turno (no computa): mismo verde del borde pero el
   fondo a medio rellenar, para que el inicio/fin de la comida quede reflejado en la barra. */
.shift-block .meal-seg { position: absolute; top: 0; bottom: 0; pointer-events: none;
    background: repeating-linear-gradient(45deg,
        rgba(255, 255, 255, .85) 0 5px, rgba(255, 255, 255, .45) 5px 10px);
    border-left: 1px solid rgba(255, 255, 255, .9); border-right: 1px solid rgba(255, 255, 255, .9); }
.shift-block.outline .meal-seg { background: repeating-linear-gradient(45deg,
        color-mix(in srgb, var(--rz-primary) 22%, transparent) 0 5px,
        color-mix(in srgb, var(--rz-primary) 8%, transparent) 5px 10px);
    border-left: 1px dashed var(--rz-primary); border-right: 1px dashed var(--rz-primary); }
