/* General Styles */

/* Escala base para coincidir con producción (13.6px / 16px = 85%) */
html {
    font-size: 85%;
}

/* Manejar estilos para validation-message de Blazor */
.validation-message {
    color: #FF0000;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Estilos para inputs con validación */
.invalid {
    border-color: #FF0000;
}

/* Estilo de app nativa: deshabilitar selección de texto globalmente */
* {
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version, currently supported by Chrome, Opera and Firefox */
    -webkit-tap-highlight-color: transparent; /* Quitar highlight azul al tocar en móviles */
    -webkit-touch-callout: none; /* Deshabilitar callout en iOS */
}

/* Permitir selección en elementos editables y de entrada de texto */
input,
textarea,
select,
[contenteditable="true"],
.allow-select {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

.text-description {
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.2;
}

.fs-3x {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 2s linear infinite;
}

.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

.text-fluid {
    font-size: calc(16px + (24 - 16) * ((100vw - 400px) / (1600 - 400)));
}

.text-auto-adjust {
    font-size: clamp(1rem, 2.5vw, 2rem);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.text-value-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Custom Card Styles */
.custom-card {
    border-radius: 20px;
    overflow: hidden;
    transition: transform .2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.custom-card:hover {
    transform: scale(1.03);
}

.card-header-custom {
    background-color: #007BFF;
    color: #FFF;
    font-weight: bold;
    font-size: 24px;
}

.card-footer-custom {
    background-color: rgba(0, 123, 255, 0.1);
}

/* Button Styles */
.btn-label {
    overflow: hidden;
    word-break: break-word;
}

.fs-7 {
    font-size: 0.875rem;
}

.adjust-font-size {
    font-size: calc(200px / 20) !important;
}

/* Scrollbar Customization */
.main-navigation nav::-webkit-scrollbar {
    width: 1px;
}

.main-navigation nav::-webkit-scrollbar-track {
    background-color: rgba(194, 194, 194, 0.5);
}

.main-navigation nav::-webkit-scrollbar-thumb {
    background-color: #131418;
}

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background-color: #4d4d4d;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background-color: #c2c2c2;
    border-radius: 10px;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
    html {
        font-size: 80%;
    }
}

.brand-link .brand-image {
    float: left;
    line-height: .8;
    margin-left: .8rem;
    margin-right: .5rem;
    margin-top: -3px;
    max-height: 33px;
    width: auto;
}

/* Preloader Styles */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 1s ease-in-out;
}

.preloader.hidden {
    opacity: 0;
    pointer-events: none;
}

.curtain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    opacity: 1.9;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px) rotate(-5deg);
    }
    50% {
        transform: translateX(5px) rotate(5deg);
    }
    75% {
        transform: translateX(-5px) rotate(-5deg);
    }
    100% {
        transform: translateX(0);
    }
}

.animation__shake {
    animation: shake 1500ms infinite;
}

/* SweetAlert Customization */
.swal2-popup {
    font-family: sans-serif !important;
    border-radius: 12px !important;
    padding: 2rem !important;
    font-family: inherit !important;
}

.swal2-title {
    color: var(--css-dark) !important;
    font-weight: 600 !important;
}

.swal2-html-container {
    font-size: 1rem !important;
    color: #666 !important;
}

.swal2-container {
    z-index: 1050 !important;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

/* Custom Button */
.btn-css {
    display: inline-block;
    font-weight: 400;
    color: #fff;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    background-color: #0d3d70;
    border: 1px solid #0d3d70;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    cursor: pointer;
    text-decoration: none;
}

.btn-css:hover {
    background-color: #0a2f5a;
    border-color: #0a2f5a;
    color: #fff;
}

.btn-css:focus,
.btn-css.focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 61, 112, 0.5);
}

.btn-css:active,
.btn-css.active {
    background-color: #082440;
    border-color: #051930;
    box-shadow: 0 0.2rem 0.2rem rgba(0, 0, 0, 0.075);
}

.btn-css:disabled,
.btn-css.disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Modal de reconexión de Blazor - HABILITADO para mostrar estado de conexión */
/* Permite que el usuario vea el overlay cuando pierde conexión con el servidor */
.components-reconnect-modal {
    /* Habilitado - muestra el "sombrado" automático cuando se pierde la conexión */
}

/* SweetAlert Height Adjustment */
body.swal2-height-auto {
    height: 100% !important;
}

/* Salary Table Styles */
.salary-table {
    position: relative;
    z-index: 1;
}

.salary-table .rz-datatable-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.salary-table .rz-datatable-data th,
.salary-table .rz-datatable-data td {
    white-space: nowrap;
    vertical-align: middle;
    position: relative;
    z-index: 2;
}

.salary-table .rz-datatable-data .rz-cell-data {
    position: relative;
    z-index: 3;
}

/* Button overlays fix */
.salary-table button {
    position: relative;
    z-index: 10 !important;
}

.salary-table input {
    position: relative;
    z-index: 5;
}

/* Enhanced table cell styles for better visibility */
.salary-table .cell-historico {
    background-color: #f3f4f6;
    color: #374151;
}

.salary-table .cell-editable {
    background-color: #d1fae5;
    color: #065f46;
}

.salary-table .cell-proyectado {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Popup/Modal z-index hierarchy */
.salary-popup {
    z-index: 200 !important;
}

.salary-overlay {
    z-index: 190 !important;
}

/* Mobile Responsive Table */
@media screen and (max-width: 768px) {
    .salary-table {
        font-size: 0.875rem;
    }
    
    .salary-table .rz-datatable-data th,
    .salary-table .rz-datatable-data td {
        padding: 0.5rem 0.25rem;
        min-width: 100px;
    }
    
    .salary-table input {
        font-size: 0.875rem;
        padding: 0.375rem 0.5rem;
    }
    
    .salary-table button {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        min-width: auto;
        min-height: 32px;
    }
    
    /* Improve button container spacing on mobile */
    .mb-4.flex.flex-col.md\\:flex-row.md\\:justify-between .flex.flex-col.sm\\:flex-row {
        gap: 0.5rem;
    }
    
    /* Better mobile text wrapping for buttons */
    .whitespace-nowrap {
        white-space: normal !important;
        line-height: 1.2;
        text-align: center;
    }
}

@media screen and (max-width: 640px) {
    .salary-table {
        font-size: 0.75rem;
    }
    
    .salary-table .rz-datatable-data th,
    .salary-table .rz-datatable-data td {
        padding: 0.375rem 0.125rem;
        min-width: 100px;
    }
    
    .salary-table input {
        font-size: 0.75rem;
        padding: 0.25rem 0.375rem;
    }
    
    .salary-table button svg {
        width: 12px;
        height: 12px;
    }
    
    /* Stack sidebar vertically on small screens */
    .salary-container {
        flex-direction: column;
    }
    
    .salary-sidebar {
        width: 100% !important;
        margin-bottom: 1rem;
    }
}

/* Enhanced button styles for better visibility */
.salary-table .replicate-button {
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    transition: all 0.2s ease;
}

.salary-table .replicate-button:hover {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.salary-table .replicate-button-green {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.salary-table .replicate-button-green:hover {
    background-color: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
}

/* ========================================
   CLASES TAILWIND ARBITRARIAS PARA SIDEBAR
   Estas clases no se compilan con Tailwind JIT
   porque son valores arbitrarios [22rem], [23rem]
   ======================================== */

/* Margen derecho para contenido cuando hay sidebar (desktop) */
@media (min-width: 1024px) {
    .lg\:mr-\[22rem\] {
        margin-right: 22rem !important;
    }

    .lg\:mr-\[23rem\] {
        margin-right: 23rem !important;
    }

    .lg\:mr-\[24rem\] {
        margin-right: 24rem !important;
    }

    .lg\:w-\[23rem\] {
        width: 23rem !important;
    }
}

/* Ancho máximo para sidebar */
.max-w-\[24rem\] {
    max-width: 24rem;
}

/* Ancho con calc para sidebar móvil */
.w-\[calc\(100\%-32px\)\] {
    width: calc(100% - 32px);
}

/* ========================================
   ESTILOS DEL DASHBOARD
   Migrados desde MasterDasboard.razor del Server
   ======================================== */

/* Contenedor principal del dashboard */
.dashboard-container {
    position: relative;
    min-height: 100vh;
    z-index: 1;
}

/* Contenedor de servicios con scroll propio */
.services-grid-container {
    position: relative;
    z-index: 1;
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    scrollbar-width: thin; /* Para Firefox */
    scrollbar-color: rgba(136, 136, 136, 0.5) transparent; /* Para Firefox */
}

/* Padding para scrollbar solo en desktop */
@media (min-width: 1024px) {
    .services-grid-container {
        padding-right: 8px;
        max-width: calc(100% - 3rem);
    }
}

/* Limitar ancho en mobile (max 767px) */
@media (max-width: 767px) {
    .services-grid-container {
        max-width: calc(100% - 1rem);
    }
}

/* Limitar ancho en tablet (768px-1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .services-grid-container {
        max-width: calc(100% - 1rem);
    }
}

/* Personalización del scrollbar - Auto-hide */
/* Para navegadores webkit (Chrome, Safari, Edge) */
.services-grid-container::-webkit-scrollbar {
    width: 6px;
    opacity: 0;
    transition: opacity 0.3s;
}

.services-grid-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

.services-grid-container::-webkit-scrollbar-thumb {
    background: rgba(136, 136, 136, 0.3);
    border-radius: 10px;
    transition: background 0.3s;
}

.services-grid-container:hover::-webkit-scrollbar-thumb {
    background: rgba(136, 136, 136, 0.5);
}

.services-grid-container::-webkit-scrollbar-thumb:hover {
    background: rgba(136, 136, 136, 0.7);
}

/* Ocultar scrollbar cuando no se usa */
@media (hover: hover) {
    .services-grid-container {
        overflow-y: overlay; /* Solo Chrome/Safari soportan esto */
    }
}

/* Para móviles, ocultar completamente el scrollbar pero mantener el scroll */
@media (max-width: 768px) {
    .services-grid-container::-webkit-scrollbar {
        display: none;
    }

    .services-grid-container {
        -ms-overflow-style: none;  /* IE y Edge */
        scrollbar-width: none; /* Firefox */
    }
}

/* ========================================
   ESTILOS DEL GRID DE SERVICE CARDS
   Migrados desde MasterDasboard.razor del Server
   ======================================== */

/* Escala general para TODA la página WASM (incluyendo fixed elements) */
html, body {
    background-color: #f4f5f9 !important;
    min-height: 100vh;
}

/* Grid uniforme para todos los navegadores */
.service-grid-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(220px, auto);
    gap: 1rem;
}

@media (min-width: 640px) {
    .service-grid-container {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: minmax(220px, auto);
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .service-grid-container {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: minmax(220px, auto);
        gap: 1.25rem;
    }
}

@media (min-width: 1280px) {
    .service-grid-container {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: minmax(220px, auto);
    }
}

.service-card-wrapper {
    display: flex;
    height: 100%;
}

.service-card-wrapper > * {
    width: 100%;
    height: 100%;
}

.service-card-wrapper > button {
    width: 100% !important;
    height: 100% !important;
    min-height: 220px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Grid uniforme para Safari */
@supports (-webkit-touch-callout: none) {
    .service-grid-container {
        display: grid !important;
        grid-auto-rows: minmax(180px, 200px) !important;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }

    .service-card-wrapper {
        display: flex !important;
        height: 100% !important;
        -webkit-box-flex: 1;
        flex: 1;
    }

    .service-card-wrapper > button {
        -webkit-box-orient: vertical !important;
        -webkit-box-direction: normal !important;
    }
}

/* ========================================
   Modal Frame Styles
   ======================================== */

/* Clase para controlar el scroll a nivel documento cuando modal está activo */
html.modal-open-noscroll {
    overflow: hidden !important;
}

body.modal-active {
    overflow: hidden !important;
}

/* Contenido scrollable del modal frame */
.modal-frame-content {
    margin-top: 90px;
    height: calc(100% - 90px);
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
}

@media (min-width: 768px) {
    .modal-frame-content {
        margin-top: 150px;
        height: calc(100% - 150px);
    }
}

/* Iframe ocupa todo el espacio disponible */
.modal-frame-iframe {
    width: 100%;
    height: 100%;
    border: none;
    transition: opacity 0.3s ease-in-out;
}

/* ========== ESTILOS HEADER MODAL LAYOUT ========== */
/* Fallback de colores institucionales para las clases de valor arbitrario.
   Ya se generan en tailwind.output.css (build-css.sh); se conservan aqui SIN
   !important como respaldo. OJO: nunca usar !important aqui, porque le ganaria
   a las variantes hover:/group-hover: (ej. group-hover:text-white) y el texto
   quedaria invisible en hover (bug del boton de las service cards). */
.bg-\[\#083D6C\] {
    background-color: #083D6C;
}

.text-\[\#083D6C\] {
    color: #083D6C;
}

.border-\[\#083D6C\] {
    border-color: #083D6C;
}

.stroke-\[\#083D6C\] {
    stroke: #083D6C;
}

.border-l-\[\#083D6C\] {
    border-left-color: #083D6C;
}

/* ========== FIX Z-INDEX RADZEN FROZEN CELLS ========== */
/*
 * Problema: Las celdas frozen de Radzen usan position:sticky con z-index inline.
 * Esto causa que aparezcan sobre los overlays fixed cuando se abre un sidebar.
 *
 * Solución: Crear un contexto de apilamiento (stacking context) en el contenedor
 * del DataGrid usando position:relative + z-index:0. Esto "encierra" todos los
 * z-index internos (sticky cells) dentro de ese contexto, permitiendo que los
 * overlays fixed con z-index alto aparezcan por encima.
 */

/* Crear contexto de apilamiento en el contenedor del DataGrid */
.rz-datatable,
.rz-data-grid {
    position: relative !important;
    z-index: 0 !important;
    isolation: isolate !important;
}

/* Contenedor de scroll también necesita contexto de apilamiento */
.rz-datatable-wrapper,
.rz-data-grid-wrapper,
.rz-datatable-scrollable-wrapper {
    position: relative !important;
    z-index: 0 !important;
}

/* Tabla interna mantiene z-index bajo */
.rz-grid-table,
.rz-datatable-thead,
.rz-datatable-scrollable-header,
.rz-datatable-scrollable-header-box {
    position: relative !important;
    z-index: 0 !important;
}
