/* ==============================================
   ESTILOS CRÍTICOS PARA FIXEAR EL BODY SCROLL - VERSIÓN RESPONSIVE
   ============================================== */

/* 1. PREVENIR OVERFLOW HORIZONTAL GLOBAL */
body {
    overflow-x: hidden !important;
    position: relative;
}

/* 2. CONTENEDOR PRINCIPAL */
#main_body {
    width: 100% !important;
    overflow-x: hidden !important;
}

/* 3. CONTENIDO MAIN */
main {
    width: 100% !important;
    overflow-x: hidden !important;
}

/* 4. CONTENEDOR DE LA TABLA */
#main {
    width: 100% !important;
    overflow-x: auto !important;
}

/* ==============================================
   ESTILOS PARA DATATABLES (RESPONSIVE)
   ============================================== */

/* 5. WRAPPER DE DATATABLES - SOLO SCROLL INTERNO */
.dataTables_wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    position: relative;
}

/* 6. ELIMINAR CONFIGURACIONES FIJAS QUE ROMPEN EL RESPONSIVE */
.dataTables_scroll {
    overflow-x: auto !important;
    width: 100% !important;
}

/* 7. QUITAR table-layout: fixed - esto rompe el responsive */
.dataTables_scrollHeadInner table,
.dataTables_scrollBody table {
    table-layout: auto !important; /* Cambiado de fixed a auto */
    min-width: min-content !important; /* Permite que crezca según contenido */
}

/* 8. TABLA PRINCIPAL - FLEXIBLE */
table.dataTable {
    width: 100% !important;
    table-layout: auto !important; /* Cambiado de fixed a auto */
    border-collapse: collapse !important;
}

/* 9. CELDAS FLEXIBLES - PERMITIR AJUSTE */
table.dataTable td,
table.dataTable th {
    min-width: 100px !important; /* Mínimo razonable */
    max-width: 250px !important; /* Máximo razonable */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* 10. PAGINACIÓN Y CONTROLES - RESPONSIVE */
.dataTables_paginate,
.dataTables_info,
.dataTables_length {
    width: 100% !important;
    overflow-x: hidden !important;
}

/* ==============================================
   RESPONSIVE ADICIONAL - MEJORADO
   ============================================== */

/* 11. TABLET - 768px a 1024px */
@media (max-width: 1024px) {
    table.dataTable {
        font-size: 14px !important;
    }

    table.dataTable td,
    table.dataTable th {
        padding: 10px 12px !important;
        min-width: 90px !important;
        max-width: 200px !important;
    }

    .dataTables_wrapper {
        font-size: 13px !important;
    }
}

/* 12. MÓVIL - menos de 768px */
@media (max-width: 768px) {
    /* Forzar scroll horizontal solo en móvil */
    .dataTables_wrapper {
        overflow-x: scroll !important;
    }

    /* Tabla con ancho mínimo para scroll horizontal controlado */
    table.dataTable {
        min-width: 768px !important; /* Permite scroll horizontal controlado */
    }

    table.dataTable td,
    table.dataTable th {
        padding: 8px 10px !important;
        font-size: 13px !important;
        min-width: 80px !important;
        max-width: 180px !important;
    }

    /* Ajustar contenedor principal */
    #main {
        margin: 0 -12px;
        padding: 0 4px;
    }

    main {
        padding: 12px !important;
    }

    section {
        padding: 12px !important;
    }
}

/* 13. MÓVIL PEQUEÑO - menos de 480px */
@media (max-width: 480px) {
    table.dataTable {
        min-width: 480px !important;
    }

    table.dataTable td,
    table.dataTable th {
        padding: 6px 8px !important;
        font-size: 12px !important;
        min-width: 70px !important;
        max-width: 150px !important;
    }

    /* Ocultar columnas menos importantes en móvil muy pequeño */
    table.dataTable td:nth-child(6), /* Sistema Origen */
    table.dataTable th:nth-child(6),
    table.dataTable td:nth-child(9), /* Descuento % */
    table.dataTable th:nth-child(9),
    table.dataTable td:nth-child(14), /* Fecha Creación */
    table.dataTable th:nth-child(14) {
        display: none !important;
    }
}

/* ==============================================
   UTILIDADES RESPONSIVE
   ============================================== */

/* 14. MOSTRAR TODO EL CONTENIDO AL HOVER */
table.dataTable td:hover {
    white-space: normal !important;
    overflow: visible !important;
    background: #f3f4f6 !important;
    position: relative !important;
    z-index: 100 !important;
    max-width: none !important;
    min-width: auto !important;
    word-break: break-word !important;
}

/* 15. BOTONES RESPONSIVE */
@media (max-width: 640px) {
    .dataTables_wrapper .dt-buttons button {
        padding: 4px 8px !important;
        font-size: 12px !important;
        margin: 2px !important;
    }
}

/* 16. HEADER RESPONSIVE */
@media (max-width: 768px) {
    #dataTables thead th {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }
}

/* 17. FIX PARA VISTA PREVIA EN CELDAS LARGAS */
.dataTable td {
    position: relative;
}

.dataTable td[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 0;
    top: 100%;
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: normal;
    z-index: 1000;
    min-width: 150px;
    max-width: 300px;
}

/* 18. SCROLL PERSONALIZADO PARA DATATABLES */
.dataTables_wrapper::-webkit-scrollbar {
    height: 8px;
}

.dataTables_wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.dataTables_wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.dataTables_wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 19. ANIMACIONES SUAVES */
.dataTables_wrapper {
    transition: all 0.3s ease;
}

/* 20. CLASE PARA TABLAS DEMASIADO ANCHAS */
.table-overflow-container {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-overflow-container::after {
    content: '← Desplaza →';
    position: absolute;
    right: 10px;
    top: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-overflow-container:hover::after {
    opacity: 1;
}

/* 21. INDICADOR VISUAL DE SCROLL */
.dataTables_scrollBody {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* ---------------------- */
/* Variables Globales    */
/* ---------------------- */
:root {
    /* Colores personalizados */
    --color-primario: #232523;
    --contraste-primario: #EAE8E2;
    --texto-primario: #232523;
    --superficie-one: #ffffff;
    --boton-secundario: #2f312f;
    --boton-secundario-borde: #373a37;
    --azul-borde: #60a5fa;
    --azul-fondo: #3b82f6;
    --azul-activo: #2563eb;
    --gris-borde: #d1d5db;
    --gris-texto: #4b5563;
}

/* ---------------------- */
/* Fuentes               */
/* ---------------------- */
@font-face {
    font-family: 'Italian Plate No 2 Md';
    src: url('https://s3.amazonaws.com/appforest_uf/f1653263864423x369398250181703230/ItalianPlateNoTwo-Md.otf');
}
@font-face {
    font-family: 'Italian Plate No 1 Extrabold';
    src: url('https://s3.amazonaws.com/appforest_uf/f1653263891442x766837804069760800/ItalianPlateNo1-Extrabold.otf');
}
@font-face {
    font-family: 'Sailec Regular';
    src: url('https://s3.amazonaws.com/appforest_uf/f1653263830305x727370285149920600/Sailec-Regular.otf');
}

* {
    font-family: 'Sailec Regular';
    box-sizing: border-box;
}

.font-sailer {
    font-family: 'Sailec Regular', sans-serif;
}
.font-italian-plate {
    font-family: 'Italian Plate No 1 Extrabold', sans-serif;
    text-transform: uppercase;
}

/* ---------------------- */
/* Generales             */
/* ---------------------- */
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ---------------------- */
/* Clases Globales       */
/* ---------------------- */

/* Botones */
.button_secondary {
    background-color: var(--boton-secundario) !important;
    color: white !important;
    border: 1px solid var(--boton-secundario-borde) !important;
    padding: 0.25rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: background-color 0.2s ease;
}
.button_secondary:hover {
    background-color: var(--boton-secundario) !important;
}

/* Labels e Inputs */
.input-label {
    color: var(--texto-primario);
    font-weight: 600;
}
.input-field {
    border: 1px solid var(--gris-borde);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: box-shadow 0.2s ease;
}
.input-field:focus {
    box-shadow: 0 0 0 2px var(--azul-borde);
    border-color: var(--azul-borde);
}

/*SCROL*/
/* Scrollbar personalizado al estilo jConfirm */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3); /* Blanco translúcido */
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background-color: transparent;
}

/* ---------------------- */
/* JConfirm              */
/* ---------------------- */
.jconfirm .jconfirm-overlay {
    z-index: 999 !important;
}
.jconfirm {
    z-index: 1000 !important;
    padding: 0 !important;
}
.custom-popup {
    z-index: 9999 !important;
}
.jconfirm .jconfirm-box.custom-width {
    width: 900px;
    max-width: 100%;
}
@media (max-width: 900px) {
    .jconfirm-box {
        width: auto !important;
        max-width: calc(100% - 6%) !important;
        margin: 0 3% !important;
        left: 0 !important;
        border-radius: 0 !important;
    }
    .jconfirm .jconfirm-holder {
        width: 100%;
    }
}

/* ---------------------- */
/* DataTables - General   */
/* ---------------------- */
#dataTables {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #fff;
}

#dataTables thead {
    background: #f9fafb; /* bg-gray-50 */
    color: #6b7280;      /* text-gray-500 */
    text-align: left;
    font-family: 'Italian Plate No 1 Extrabold', sans-serif;
    text-transform: uppercase;
}

#dataTables thead .dt-column-title {
    font-family: 'Italian Plate No 1 Extrabold', sans-serif;
    font-size: 1.25rem; /* 20px */
    line-height: 1.75rem; /* 28px */
}

/* Filas cuerpo */
#dataTables tbody {
    background: #ffffff; /* bg-white */
}

#dataTables tbody tr {
    border-bottom: 1px solid #e5e7eb; /* divide-y divide-gray-200 */
    transition: background 0.2s ease, color 0.2s ease;
}

#dataTables tbody tr:hover {
    background: #f9fafb; /* hover:bg-gray-50 */
    color: #111827;      /* text-gray-900 */
}

/* Celdas */
#dataTables tbody td,
#dataTables th {
    padding: 10px 24px;
    color: #374151;
    text-align: left;
    font-size: 1rem; /* text-base */
    max-width: 150px; /* Trunca texto largo */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Alineación */
#dataTables th.text-right,
#dataTables td.text-right {
    text-align: right;
}

#dataTables th.text-left,
#dataTables td.text-left {
    text-align: left;
}

/* Tabla responsive - scroll horizontal */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------------------- */
/* Animaciones            */
/* ---------------------- */
@layer utilities {
    @keyframes slide-bar {
        0%, 100% { left: 0%; }
        50% { left: 100%; transform: translateX(-100%); }
    }

    .animate-slide {
        animation: slide-bar 2s ease-in-out infinite;
    }
}

.fade-in {
    animation: fadeIn 0.15s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scaleY(0.95); }
    to { opacity: 1; transform: scaleY(1); }
}

/* ---------------------- */
/* Responsive             */
/* ---------------------- */
@media (max-width: 768px) {
    .ocultar-en-pequeno {
        display: none;
    }

    #dataTables td, #dataTables th {
        padding: 6px 12px; /* reduce padding */
        font-size: 0.875rem; /* 14px */
    }
}

@media (max-width: 600px) {
    .modal_notificaciones {
        left: 50% !important;
        transform: translateX(-50%);
        right: auto !important;
    }
}

@media (max-width: 430px) {
    #alerta_button {
        display: none;
    }
    .show-on-mobile {
        display: inline !important;
    }
    .hide-on-mobile {
        display: none !important;
    }
}

@media (min-width: 431px) {
    .show-on-mobile {
        display: none !important;
    }
    .hide-on-mobile {
        display: inline !important;
    }
}

/* Mostrar todo el contenido al hacer hover */
#dataTables td:hover {
    white-space: normal;
    overflow: visible;
    background: #f3f4f6;
    position: relative;
    z-index: 1;
}

/* ---------------------- */
/* DataTables - General   */
/* ---------------------- */
#tables {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #fff;
}

#tables thead {
    background: #f9fafb; /* bg-gray-50 */
    color: #6b7280;      /* text-gray-500 */
    text-align: left;
    font-family: 'Italian Plate No 1 Extrabold', sans-serif;
    text-transform: uppercase;
}

#tables thead .dt-column-title {
    font-family: 'Italian Plate No 1 Extrabold', sans-serif;
    font-size: 1.25rem; /* 20px */
    line-height: 1.75rem; /* 28px */
}

/* Filas cuerpo */
#tables tbody {
    background: #ffffff; /* bg-white */
}

#tables tbody tr {
    border-bottom: 1px solid #e5e7eb; /* divide-y divide-gray-200 */
    transition: background 0.2s ease, color 0.2s ease;
}

#tables tbody tr:hover {
    background: #f9fafb; /* hover:bg-gray-50 */
    color: #111827;      /* text-gray-900 */
}

/* Celdas */
#tables tbody td,
#tables th {
    padding: 10px 24px;
    color: #374151;
    text-align: left;
    font-size: 1rem; /* text-base */
    max-width: 150px; /* Trunca texto largo */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Alineación */
#tables th.text-right,
#tables td.text-right {
    text-align: right;
}

#tables th.text-left,
#tables td.text-left {
    text-align: left;
}

/* Tabla responsive - scroll horizontal */
.table-responsive table {
    min-width: 600px; /* Ajusta según columnas */
}

/* ==============================================
   AJUSTES FINALES PARA DATATABLES RESPONSIVE
   ============================================== */

/* 22. CONTENEDOR RESPONSIVE PARA TABLAS */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}

/* 23. MEDIA QUERIES ESPECÍFICAS PARA TABLAS */
@media (max-width: 1200px) {
    .table-container {
        font-size: 13px;
    }

    #dataTables td, #dataTables th,
    #tables td, #tables th {
        padding: 8px 16px;
    }
}

@media (max-width: 992px) {
    .table-container {
        margin: 0 -8px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    #dataTables, #tables {
        min-width: 992px;
    }
}

/* 24. SCROLL TOUCH PARA MÓVIL */
@media (max-width: 768px) {
    .table-container {
        -webkit-overflow-scrolling: touch;
    }

    /* Indicador visual de scroll horizontal */
    .table-container::after {
        content: '← Desplaza horizontalmente →';
        display: block;
        text-align: center;
        padding: 8px;
        font-size: 12px;
        color: #6b7280;
        background: #f9fafb;
        border-top: 1px solid #e5e7eb;
    }
}