/* ==========================================================================
   1. CONFIGURACIÓN Y COMPORTAMIENTO GLOBAL DE INTERFAZ TÁCTIL (CORREGIDO)
   ========================================================================== */

/* Permitimos la selección de texto en todo el cuerpo del sistema por defecto */
body {
    -webkit-user-select: text;
    user-select: text;
}

/* Evitamos selección accidental SOLAMENTE en elementos de control táctil comunes */
a, 
button, 
.btn, 
.badge,
.app-sidebar, 
.nav-menu,
.dropdown-menu,
thead th {
    -webkit-user-select: none;
    user-select: none;
}

/* Permitimos siempre la selección natural en inputs, áreas de texto y contenedores de datos */
input, 
textarea,
.table tbody td,
.articulo-block,
.articulo-content,
.titulo-desc {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* Elimina el molesto recuadro azul que parpadea al tocar elementos en Android/iOS */
a, button, div, span {
    -webkit-tap-highlight-color: transparent;
}


/* ==========================================================================
   2. COMPONENTES Y AVATARES DE USUARIO
   ========================================================================== */

.user-avatar-container {
    position: relative;
    display: inline-block;
}

.user-avatar-container img {
    width: 45px;
    height: 45px;
    border-radius: 10px; /* Estilo moderno cuadradito con bordes curvos */
    object-fit: cover;
}

.activity-indicator {
    position: absolute;
    bottom: 0;
    right: 0; /* Mantiene el punto en la esquina inferior derecha de la foto */
    width: 12px;
    height: 12px;
    background-color: #2ecc71; /* Verde esmeralda */
    border: 2px solid #fff;
    border-radius: 50%;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 120px; /* Ajusta según el ancho de tu sidebar */
    overflow: hidden;
}

.user-info-text strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Pone los "..." automáticamente */
    font-size: 13px;
    font-weight: 600;
}

.user-state-info {
    font-size: 11px;
    opacity: 0.7;
}


/* ==========================================================================
   3. BOTONES DE ACCIÓN CUADRADOS (ESTILO COMPACTO DE TABLAS)
   ========================================================================== */

.btn-action-edit {
    background-color: #4c83ff;
    color: white;
    border: none;
    padding: 6px;
    border-radius: 4px;
    margin-right: 5px;
}

.btn-action-delete {
    background-color: #f75d6fd8;
    color: white;
    border: none;
    padding: 6px;
    border-radius: 4px;
}

/* Clases auxiliares para botones rápidos */
.btn-xs {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1;
    border-radius: 0.2rem;
}


/* ==========================================================================
   4. ESTILOS DE TABLAS (CUSTOM, COMPACTAS Y DATATABLES)
   ========================================================================== */

/* --- Tablas Custom Generales --- */
.table-custom thead th {
    background-color: #2c3e50 !important; /* Azul grisáceo elegante */
    color: #ffffff !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    border: none;
    padding: 12px 15px;
    vertical-align: middle;
}

/* Efecto Hover mejorado para las filas */
.table-custom tbody tr:hover {
    background-color: rgba(44, 62, 80, 0.05) !important;
    transition: background-color 0.2s ease;
}

/* --- Tabla Usuarios --- */
#tblUsuarios thead th {
    border-bottom: 1px solid #ebecef;
    color: #6d718a;
    font-size: 12px;
    text-transform: capitalize;
    font-weight: 500;
}

#tblUsuarios tbody td {
    color: #3d4465;
    font-size: 13px;
    padding: 15px 10px;
}

/* --- Tablas Compactas Reutilizables (.table-compact-custom) --- */
.table-compact-custom {
    font-size: 0.85rem !important;
}

.table-compact-custom th, 
.table-compact-custom td {
    padding: 6px 8px !important; /* Reduce espacio interno vertical y horizontal */
    vertical-align: middle !important;
    white-space: normal !important; /* Permite saltos de línea en celdas */
    word-break: break-word !important; /* Rompe correos o textos sin espacios */
}

.table-compact-custom .badge {
    font-size: 0.75rem !important;
    padding: 4px 6px !important;
}

/* --- Tabla de Nómina General --- */
#tblNominaGeneral {
    font-size: 0.85rem !important;
}

#tblNominaGeneral th, 
#tblNominaGeneral td {
    padding: 6px 8px !important;
    vertical-align: middle !important;
    white-space: normal !important;
    word-break: break-word !important;
}

#tblNominaGeneral .badge {
    font-size: 0.75rem !important;
    padding: 4px 6px !important;
}

/* --- Tabla Solicitud de Jugadores --- */
#tablaJugadoresSolicitud input, 
#tablaJugadoresSolicitud select {
    font-size: 0.85rem; /* Letra un poco más pequeña */
    padding: 0.25rem;   /* Más compacto */
}

#tablaJugadoresSolicitud th {
    font-size: 0.8rem;
    text-transform: uppercase;
    vertical-align: middle;
}

/* --- Alineaciones y Cortes Especiales en Tablas --- */
.text-end-custom {
    text-align: right !important;
    padding-right: 20px !important;
}

.celda-recortada {
    max-width: 350px;       /* Ancho límite para la descripción en listados */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Pone los tres puntos (...) al final */
}


/* ==========================================================================
   5. CONTROLES Y MAQUETACIÓN DE DATATABLES
   ========================================================================== */

/* Contenedor principal de los controles */
.top-controls {
    display: flex !important;
    justify-content: space-between !important;
}

/* Forzar que el buscador (filtro) esté a la izquierda */
.dataTables_filter {
    text-align: left !important;
    margin-left: 0;
}

/* Forzar que el selector de cantidad esté a la derecha */
.dataTables_length {
    text-align: right !important;
    margin-right: 0;
    margin-bottom: 0.5rem !important;
}

/* Corregir el aspecto de la paginación */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.5rem 0.75rem;
    margin-left: 2px;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    color: #0d6efd !important;
    text-decoration: none;
    background-color: #fff;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background-color: #0d6efd !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: #6c757d !important;
    pointer-events: none;
    background-color: #fff;
    border-color: #dee2e6;
}

/* Eliminar el scroll automático del contenedor de la tabla */
.table-responsive {
    overflow-x: auto !important; /* Permite scroll horizontal SÓLO si es estrictamente necesario */
    overflow-y: hidden !important; /* Elimina scroll vertical */
    margin-bottom: 0;
}

/* Forzar el ancho de la tabla al 100% */
#tblusuarios {
    width: 100% !important;
    margin: 0 !important;
}

/* Esto elimina el espaciado extra que a veces crea la barra de scroll */
.dataTables_scrollBody {
    overflow-y: hidden !important;
}


/* ==========================================================================
   6. COMPONENTES GLOBALES (BADGES, SELECTOR DE COLOR, MODALES)
   ========================================================================== */

/* Estilo para los Badges (Estados) */
.badge {
    font-weight: 500;
    padding: 0.5em 0.8em;
    border-radius: 4px;
}

/* Ajuste para que el selectpicker no se vea cortado en modales */
.bootstrap-select .dropdown-menu {
    z-index: 1060 !important;
}

/* Hacer el selector de color más grande y estético */
.input-color-custom {
    padding: 5px !important;
    cursor: pointer;
    border: 2px solid #dee2e6;
    border-radius: 8px !important;
    transition: transform 0.2s, border-color 0.2s;
}

.input-color-custom:hover {
    border-color: var(--color-personalizado); /* Ilumina el borde al pasar el mouse */
    transform: scale(1.02); /* Efecto de aumento sutil */
}

/* Ajuste para navegadores basados en Chrome/Edge para que el color llene todo el espacio */
.input-color-custom::-webkit-color-swatch-wrapper {
    padding: 0;
}
.input-color-custom::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}


/* ==========================================================================
   7. MENÚ SIDEBAR (SISTEMA DE NAVEGACIÓN)
   ========================================================================== */

.app-sidebar .nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-sidebar .nav-menu li {
    position: relative;
}

/* Enlaces de Menú (Items) */
.app-sidebar .nav-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #40475c;
    text-decoration: none;
    transition: all 0.3s ease;
}

.app-sidebar .nav-menu li a:hover {
    color: #2d5d9b;
    background: #BBCAEC;
}

/* Iconos principales */
.app-sidebar .nav-menu li a i {
    margin-right: 10px;
    font-size: 20px;
}

/* Flechas de Despliegue */
.app-sidebar .has-sub > a::after {
    content: '\e5cc'; /* Icono chevron_right de Material Icons */
    font-family: 'Material Icons';
    margin-left: auto;
    transition: transform 0.3s;
    font-size: 18px;
}

/* Rotación de flecha cuando está abierto */
.app-sidebar .has-sub.open > a::after {
    transform: rotate(90deg);
}

/* Sub-Menús (Segundo y Tercer Nivel) */
.app-sidebar .nav-menu ul {
    list-style: none;
    padding: 0;
    display: none; /* Ocultos por defecto */
    background: #e7ecf8;
}

/* Indentación para Niveles */
.app-sidebar .nav-menu ul li a {
    padding-left: 15px; /* Segundo Nivel */
    font-size: 0.9rem;
}

.app-sidebar .nav-menu ul ul li a {
    padding-left: 50px; /* Tercer Nivel */
    font-size: 0.85rem;
}

/* Mostrar submenú cuando el padre tiene la clase .open */
.app-sidebar .has-sub.open > ul {
    display: block;
}

/* Estilo Activo */
.app-sidebar .nav-menu li.active > a {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border-left: 3px solid #3c8dbc;
}


/* ==========================================================================
   8. COLOR DINÁMICO (CONFIGURACIÓN DE ADMINISTRADOR)
   ========================================================================== */

.btn-dinamico {
    background-color: var(--color-personalizado) !important;
    border-color: var(--color-personalizado) !important;
    color: #ffffff !important;
}

.btn-dinamico:hover {
    filter: brightness(90%); /* Oscurece un poquito al pasar el mouse */
}

.text-dinamico {
    color: var(--color-personalizado) !important;
}

.bg-dinamico {
    background-color: var(--color-personalizado) !important;
    color: #ffffff;
}


/* ==========================================================================
   9. GESTOR DE ARCHIVOS (FILE MANAGER)
   ========================================================================== */

.search-area {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.folder-item {
    transition: transform 0.2s;
    cursor: pointer;
    border-radius: 12px;
}

.folder-item:hover {
    background-color: #e9ecef !important;
    transform: translateY(-2px);
}

.file-item {
    border-radius: 15px;
    overflow: visible !important; /* Cambiado para que el menú no se corte */
    transition: all 0.3s ease;
    position: relative; /* Asegura el contexto de apilamiento */
}

.file-item:hover {
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    z-index: 10; /* Sube la tarjeta actual para que su menú no quede debajo de otras */
}

.object-fit-cover {
    object-fit: cover;
}

/* Ajustes para el menú desplegable ultra compacto */
.dropdown-menu {
    z-index: 9999 !important;
    border-radius: 8px !important;
    padding: 0.2rem 0 !important;
    min-width: 140px !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.dropdown-item {
    padding: 0.25rem 0.75rem !important;
    font-size: 11.5px !important;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item i {
    vertical-align: middle;
    margin-right: 8px;
    font-size: 16px !important;
}

.dropdown-divider {
    margin: 0.2rem 0 !important;
    opacity: 0.08 !important;
}

.file-item p {
    max-width: 100%;
    display: block;
}

#breadcrumb-dinamico {
    display: flex;
    align-items: center;
    width: 100%;
}

/* Colores dinámicos para iconos */
.icon-folder { color: #FFCA28; }
.icon-word { color: #2B579A; }
.icon-excel { color: #217346; }
.icon-pdf { color: #F44336; }
.icon-image { color: #E91E63; }
.icon-code { color: #9C27B0; }
.icon-generic { color: #607D8B; }

.app-content .file-card {
    margin-bottom: 5px !important;
}

@media (min-width: 992px) {
    .col-lg-1-5 {
        flex: 0 0 auto;
        width: 12.5%;
    }
}

.file-card {
    border-radius: 8px;
    transition: background-color 0.2s ease;
}
.file-card:hover {
    background-color: #f1f3f4;
}

/* Vista de tabla/lista del file manager */
.table-file-manager thead th {
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

.table-file-manager tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.table-file-manager tbody tr:hover {
    background-color: #f1f3f4;
}

.table-file-manager td {
    vertical-align: middle;
    font-size: 13px;
    padding: 8px 12px;
}

.view-switch-btn {
    border: none !important;
    background: transparent !important;
    color: #888 !important;
    padding: 4px 10px !important;
    transition: all 0.2s ease;
}

.view-switch-btn.active {
    background-color: #fff !important;
    color: #0d6efd !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.view-switch-btn:hover:not(.active) {
    color: #444 !important;
}


/* ==========================================================================
   10. OPTIMIZACIÓN RESPONSIVE GLOBAL (MÓVILES, TABLETS Y WEBVIEWS)
   ========================================================================== */

/* --- Filtros apilables en Móvil (File manager / Listados) --- */
.filtro-fecha-custom {
    max-width: 160px;
}

@media (max-width: 768px) {
    .search-container-stack {
        display: flex !important;
        flex-direction: column;
        background: transparent !important;
        border: none !important;
        gap: 8px;
    }

    .search-container-stack .input-group-text, 
    .search-container-stack #buscarArchivo,
    .search-container-stack .filtro-fecha-custom {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 12px !important;
        border: 1px solid #dee2e6 !important;
    }

    .search-container-stack .input-group-text {
        display: none;
    }
    
    #buscarArchivo {
        border-left: 1px solid #dee2e6 !important;
        padding-left: 40px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z' fill='%23999'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 10px center;
    }
}

/* --- Botones Anchos de Acción en Móviles --- */
@media (max-width: 767.98px) {
    .w-100-mobile {
        width: 100% !important;
        display: block;
    }
}

/* --- Reordenamiento de Formularios y Modales en Móviles --- */
@media (max-width: 767.98px) {
    .ordering-mobile-1 {
        order: 1 !important;
        border-bottom: 1px dashed #dee2e6;
        padding-bottom: 15px !important;
        margin-bottom: 15px !important;
    }
    .ordering-mobile-2 {
        order: 2 !important;
    }
}

/* --- Bordes Condicionales de Separación (Columna Izquierda / Derecha) --- */
@media (min-width: 768px) {
    .border-start-md {
        border-left: 1px solid #dee2e6 !important;
    }
}

/* --- Desplazamiento Táctil Suave de Tablas --- */
.swipe-hint {
    position: relative;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 575.98px) {
    /* Ajustes compactos en celdas para pantallas extra pequeñas */
    .table-custom th, .table-custom td {
        padding: 6px 4px !important;
        font-size: 0.8rem !important;
    }

    /* Reducción controlada de imágenes miniatura en tablas */
    .table-custom img {
        width: 30px !important;
        height: 30px !important;
    }
}


/* ==========================================================================
   11. INTEGRACIÓN CON DETECCIÓN DE LA APP MÓVIL DE REACT NATIVE (BODY CLASES)
   ========================================================================== */

/* Si está dentro de la App (Clase nativa WebView) */
.is-app .sidebar, 
.is-app .app-header { 
    display: none !important; 
}

.is-app .app-content { 
    padding: 10px !important; 
}

/* Optimizaciones estructurales para cuando .is-mobile-app está activo en el body */
.is-mobile-app .app-content {
    padding: 8px !important;
    margin: 0 !important;
}

.is-mobile-app .container-fluid {
    padding-left: 5px !important;
    padding-right: 5px !important;
}

.is-mobile-app .card {
    border: none !important;
    box-shadow: none !important;
}

.is-mobile-app .card-body {
    padding: 10px !important;
}

/* Animación personalizada de abajo hacia arriba */
.modal.fade .modal-dialog {
    transform: translateY(100vh);
    transition: transform 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: translateY(0);
}


.modal-bottom .modal-dialog {
    margin-bottom: 0;
    margin-top: auto;
    display: flex;
    align-items: flex-end;
    min-height: calc(100% - 1rem);
}

.modal-bottom .modal-content {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}