/* 
 * 🎨 attendance_ui.css
 * Estilos específicos para el módulo de Asistencia
 */

/* --- 🦴 SKELETON LOADING --- */
.skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

.skeleton-item {
    height: 120px;
    margin-bottom: 16px;
    width: 100%;
    opacity: 0.2;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- 🚀 APP LOADER --- */
#app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#app-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #06b6d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- 💊 NAVEGACIÓN Y CONTROLES --- */
.pill-nav {
    display: flex;
    align-items: center;
    background: #1e293b;
    border-radius: 50px;
    padding: 4px;
    border: 1px solid #334155;
    width: fit-content;
    margin: 0 auto 20px auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pill-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pill-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

.pill-display {
    padding: 0 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f5f9;
    min-width: 180px;
    justify-content: center;
    user-select: none;
}

.pill-display:hover {
    color: #06b6d4;
}

.segmented-control {
    display: flex;
    background: #1e293b;
    padding: 2px;
    /* Reducido de 4px para que coincida con el stepper */
    border-radius: 12px;
    border: 1.5px solid #334155;
    gap: 4px;
    width: 100%;
    height: 44px;
    overflow: hidden;
    box-sizing: border-box;
}

.segmented-item {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: flex 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s, color 0.3s;
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.segmented-item.active {
    flex: 1.8;
    /* El botón activo se expande */
    background: #06b6d4;
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.view-btn {
    padding: 10px 12px;
    border-radius: 8px;
    background: #1e293b;
    border: 2px solid #334155;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.view-btn.active {
    background: #06b6d4;
    color: #0f172a;
    border-color: #06b6d4;
}

/* --- ⏱️ STEPPER DE HORAS --- */
.stepper-container {
    display: flex;
    align-items: center;
    background: #1e293b;
    border-radius: 12px;
    border: 1.5px solid #334155;
    padding: 2px;
    height: 44px;
    width: 100%;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.stepper-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.stepper-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

.stepper-btn:active {
    transform: scale(0.9);
}

.stepper-value {
    padding: 0 12px;
    font-weight: 700;
    color: #10b981;
    /* Verde esmeralda por defecto */
    font-size: 1.2rem;
    min-width: 50px;
    text-align: center;
    user-select: none;
}

.view-controls-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: center;
}

.control-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Todas las secciones (Feriado · Horas a Asignar · Hoy) usan el mismo ancho
       para verse alineadas y simétricas. El control interno se estira al 100%
       del padre, así Feriado y Hoy quedan visualmente del mismo tamaño. */
    flex: 0 0 110px !important;
}

.control-section-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    user-select: none;
    height: 12px !important;
    line-height: 12px !important;
    white-space: nowrap !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- 🗓️ SWITCH DE FERIADO --- */
.holiday-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #1e293b;
    padding: 2px;
    /* Unificado con los otros */
    border-radius: 12px;
    border: 1.5px solid #334155;
    cursor: pointer;
    user-select: none;
    height: 44px;
    width: 100%;
    transition: all 0.3s;
    box-sizing: border-box;
}

.holiday-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    transition: all 0.3s;
}

.holiday-control.active .holiday-icon-box {
    color: #ffcc00;
}

.holiday-control:not(.active) .holiday-icon-box {
    color: #10b981;
    /* Verde esmeralda para estado laboral */
}

.switch-toggle {
    width: 36px;
    height: 20px;
    background: #0f172a;
    border-radius: 20px;
    position: relative;
    border: 1.5px solid #334155;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-handle {
    width: 14px;
    height: 14px;
    background: #475569;
    border-radius: 50%;
    position: absolute;
    top: 1.5px;
    left: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- ✨ ESTADO DORADO (FERIADO) --- */
.holiday-control.active .switch-toggle {
    background: #ffcc00;
    border-color: #ffcc00;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

.holiday-control.active .switch-handle {
    left: 17px;
    background: #0f172a;
    transform: scale(1.1);
}

.holiday-control.active .switch-handle {
    left: 17px;
    background: #0f172a;
    transform: scale(1.1);
}

/* --- 📊 ESTADÍSTICAS Y FILTROS --- */
.stats-combined {
    margin-bottom: 16px;
}

.filter-status-notification {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.filter-status-text {
    font-size: 0.875rem;
    color: #06b6d4;
    font-weight: 600;
}

/* --- 🎯 POSICIONES --- */
.position-filters-grid {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

/* --- 🔍 BÚSQUEDA --- */
.search-wrapper {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: stretch;
}

.search-input-group {
    position: relative;
    flex: 3;
}

.search-input-field {
    width: 100%;
    background: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #f1f5f9 !important;
    padding: 10px 12px;
    padding-left: 36px;
    border-radius: 8px;
    font-size: 0.875rem;
}

.search-icon-fixed {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.attendance-layout-btn {
    width: 44px;
    min-width: 44px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.attendance-layout-btn:hover,
.attendance-layout-btn:focus-visible {
    color: #06b6d4;
    border-color: rgba(6, 182, 212, 0.7);
    background: rgba(6, 182, 212, 0.08);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
    outline: none;
}

.employee-list {
    display: grid;
    gap: 6px;
}

.employee-list .employee-row {
    margin-bottom: 0;
}

@media (min-width: 1024px) {
    .employee-list.employee-list-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

.attendance-layout-overlay {
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10020;
}

.attendance-layout-modal {
    width: min(520px, 100%);
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    padding: 18px;
}

.attendance-layout-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.attendance-layout-header h2 {
    margin: 0;
    font-size: 1rem;
    color: #f8fafc;
    letter-spacing: 0;
}

.attendance-layout-header p {
    margin: 4px 0 0;
    color: #94a3b8;
    font-size: 0.85rem;
}

.attendance-layout-close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.attendance-layout-close:hover,
.attendance-layout-close:focus-visible {
    color: #f8fafc;
    border-color: #64748b;
    outline: none;
}

.attendance-layout-options {
    display: grid;
    gap: 10px;
}

.attendance-layout-section-title {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 14px 0 8px;
}

.attendance-layout-header + .attendance-layout-section-title {
    margin-top: 0;
}

.attendance-layout-option {
    width: 100%;
    border: 1px solid #334155;
    background: #111827;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    display: grid;
    grid-template-columns: 42px 1fr 24px;
    align-items: center;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.attendance-layout-option:hover,
.attendance-layout-option:focus-visible,
.attendance-layout-option.active {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.08);
    box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.15);
    outline: none;
}

.attendance-layout-option-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 182, 212, 0.12);
    color: #06b6d4;
    font-size: 1.25rem;
}

.attendance-layout-option-text {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.attendance-layout-option-text strong {
    color: #f8fafc;
    font-size: 0.95rem;
}

.attendance-layout-option-text small {
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.35;
}

.attendance-layout-option-check {
    color: #10b981;
    font-weight: 800;
    text-align: center;
}

/* --- 👤 FILAS DE EMPLEADO --- */
.employee-row-compact {
    padding: 8px 12px;
    height: 60px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #1e293b;
}

/*
 * ⚡ PERF (Sprint 5 / 2026-05-20): browser-native virtualization.
 *
 * `content-visibility: auto` tells the browser it can skip rendering and
 * layout work for elements that are outside the viewport. Combined with
 * `contain-intrinsic-size` (which provides a placeholder size so scroll
 * height stays stable), the browser only does layout for visible rows.
 *
 * Before this rule: 200/208 nodes laid out on first render → ~2s of work.
 * Expected after:    ~30-60 visible rows → ~300-500ms of work.
 *
 * Trade-offs:
 *  - Off-screen rows are not part of the accessibility tree until visible
 *    (acceptable for an internal attendance app — they enter the tree as
 *     they scroll in).
 *  - In-page Find (Ctrl+F) doesn't search the contents of hidden rows.
 *    If this matters, downgrade to `content-visibility: auto; contain: ...`
 *    only for rows below a "fold" threshold.
 */
.employee-row,
.week-view-table tbody tr {
    content-visibility: auto;
    /* Estimated height of one row — keeps scrollbar position stable. */
    contain-intrinsic-size: auto 80px;
}

/* --- 📅 TABLA SEMANAL (STICKY) --- */
.sticky-table-container {
    overflow: auto;
    max-height: calc(100vh - 180px);
    position: relative;
    border-radius: 8px;
    box-shadow: inset -10px 0 10px -10px rgba(0, 0, 0, 0.5);
}

.sticky-column {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #1e293b !important;
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #0f172a !important;
}

/* --- ✨ MISC --- */
.glass-effect {
    background: rgba(15, 23, 42, 0.7) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.header-content {
    align-items: center !important;
}

.weather-sync-compact {
    display: none;
}

@media (max-width: 640px) {
    .weather-sync-full {
        display: none;
    }

    .weather-sync-compact {
        display: inline;
    }
}

/* --- 📅 ESTILOS DE TABLA SEMANAL (STICKY COLUMNS & NOMBRES) --- */
.week-view-table .sticky-column {
    min-width: 180px;
    width: 180px;
}
.name-line-1 {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    color: #f1f5f9;
}
.name-line-2 {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 1px;
}

/* --- 📱 DISEÑO RESPONSIVO MÓVIL --- */
@media (max-width: 480px) {
    .attendance-toolbar {
        padding: 12px 8px !important;
    }
    
    .view-controls-row {
        gap: 8px !important;
    }
    
    .control-section.side-control {
        flex: 1 1 85px !important;
        min-width: 80px !important;
        max-width: 105px !important;
    }
    
    .control-section.center-control {
        flex: 1.2 1 105px !important;
        min-width: 95px !important;
        max-width: 120px !important;
    }
    
    .control-section-label {
        font-size: 0.6rem !important;
    }
    
    .stepper-value {
        font-size: 0.95rem !important;
        min-width: 28px !important;
        padding: 0 2px !important;
    }
    
    .stepper-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 1rem !important;
    }
    
    .holiday-control {
        gap: 6px !important;
    }
    
    .btn-today-nav {
        padding: 8px 8px !important;
        gap: 4px !important;
        font-size: 0.75rem !important;
    }
    
    /* Adaptabilidad de tabla semanal y buscador */
    .search-wrapper {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .attendance-layout-btn {
        width: 100%;
        min-width: 0;
        height: 42px;
    }
    .search-input-group {
        width: 100% !important;
        flex: none !important;
    }
    .week-view-table .sticky-column {
        min-width: 90px !important;
        width: 90px !important;
    }
    .week-employee-positions {
        display: block !important;
        font-size: 0.62rem !important;
        color: #94a3b8 !important;
        margin-top: 1px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    .week-employee-cell {
        padding: 4px 2px !important;
        min-width: 0 !important;
        width: 100% !important;
        overflow: hidden !important;
    }
    .name-line-1 {
        font-size: 0.78rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        max-width: 100% !important;
    }
    .name-line-2 {
        font-size: 0.68rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        max-width: 100% !important;
    }
}

/* --- 📱 OPTIMIZACIÓN EN MODO HORIZONTAL (LANDSCAPE) MÓVIL --- */
@media (max-height: 480px) and (orientation: landscape) {
    /* Reducir alto de toolbar y controles para ganar espacio vertical */
    .attendance-toolbar {
        padding: 8px 12px !important;
        margin-bottom: 8px !important;
        border-radius: 12px !important;
    }
    .view-mode-container {
        margin-bottom: 8px !important;
    }
    .pill-nav {
        margin-bottom: 8px !important;
    }
    .view-controls-row {
        gap: 6px !important;
    }

    /* Reducir padding de cabeceras y celdas para mayor densidad */
    .week-view-table th, 
    .week-view-table td {
        padding: 3px 2px !important;
    }
    
    /* Ensanchar la columna sticky en landscape para que el nombre quepa inline */
    .week-view-table .sticky-column {
        min-width: 125px !important;
        width: 125px !important;
    }
    
    .week-employee-cell {
        padding: 2px !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 4px !important;
        min-height: 0 !important;
    }
    
    .employee-number {
        font-size: 0.65rem !important;
        margin-right: 2px !important;
    }
    
    .week-employee-name-container {
        display: flex !important;
        flex-direction: column !important;
        width: calc(100% - 24px) !important;
    }
    
    /* Mostrar primer nombre y primer apellido lado a lado de forma horizontal */
    .name-line-1, .name-line-2 {
        display: inline !important;
        font-size: 0.72rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: none !important;
    }
    
    .name-line-1::after {
        content: " " !important;
        display: inline !important;
    }
    
    .week-employee-positions {
        display: block !important;
        font-size: 0.58rem !important;
        color: #94a3b8 !important;
        margin-top: 0px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    /* Reducir altura del checkbox semanal */
    .week-check-wrapper, 
    .week-check-container {
        width: 32px !important;
        height: 32px !important;
    }
    
    .week-check-box {
        border-radius: 6px !important;
        font-size: 1.1rem !important;
    }
    
    .hours-badge {
        bottom: -3px !important;
        right: -3px !important;
        font-size: 0.55rem !important;
        padding: 1px 3px !important;
        border-radius: 3px !important;
    }
    
    .week-position-toggles {
        margin-top: 2px !important;
        gap: 1px !important;
    }
    
    .week-position-toggle {
        padding: 1px 4px !important;
        font-size: 0.52rem !important;
        border-radius: 3px !important;
    }
    
    /* Ajustar max-height para evitar scrolling excesivo en viewports cortos */
    .sticky-table-container {
        max-height: calc(100vh - 120px) !important;
    }
}

