.datatable-wrapper {
    position: relative;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.bg-gray-900 .datatable-wrapper {
    background: #1f2937;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
}

.datatable-wrapper .overflow-x-auto {
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

.datatable-sticky-header,
[id$="-fixed-container"] {
    z-index: 999 !important;
}

.datatable-sticky-header table,
[id$="-fixed-container"] table {
    margin: 0;
    width: 100%;
    border-collapse: collapse;
}

.datatable-sticky-header th,
[id$="-fixed-container"] th {
    padding: 0.5rem 1rem !important;
    background: linear-gradient(to bottom, #f9fafb 0%, #f3f4f6 100%);
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    color: #111827;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.bg-gray-900 .datatable-sticky-header th,
.bg-gray-900 [id$="-fixed-container"] th {
    background: linear-gradient(to bottom, #374151 0%, #1f2937 100%);
    border-bottom: 2px solid #4b5563;
    color: #f9fafb;
}

.bg-gray-900 .datatable-sticky-header th:hover,
.bg-gray-900 [id$="-fixed-container"] th:hover {
    background: linear-gradient(to bottom, #4b5563 0%, #374151 100%);
}

.datatable-sticky-header th:hover,
[id$="-fixed-container"] th:hover {
    background: linear-gradient(to bottom, #f3f4f6 0%, #e5e7eb 100%);
}

.datatable-sticky-header .sort-icon,
[id$="-fixed-container"] .sort-icon {
    display: inline-block;
    margin-left: 0.5rem;
    color: #9ca3af;
    transition: color 0.2s ease, transform 0.2s ease;
}

.datatable-sticky-header th:hover .sort-icon,
[id$="-fixed-container"] th:hover .sort-icon {
    color: #d31100;
}

.datatable-sticky-header .sort-icon.active,
[id$="-fixed-container"] .sort-icon.active {
    color: #d31100;
    transform: scale(1.1);
}

[id$="-fixed-container"] table {
    margin: 0;
    table-layout: fixed;
    border-collapse: collapse;
}

[id$="-fixed-header"] th {
    background: linear-gradient(to bottom, #f9fafb 0%, #f3f4f6 100%);
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    color: #111827;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    user-select: none;
    position: relative;
}

[id$="-fixed-header"] th:hover {
    background: linear-gradient(to bottom, #f3f4f6 0%, #e5e7eb 100%);
}

[id$="-fixed-header"] .sort-icon {
    display: inline-block;
    margin-left: 0.5rem;
    color: #9ca3af;
    transition: color 0.2s ease;
}

[id$="-fixed-header"] th:hover .sort-icon {
    color: #d31100;
}

.datatable-wrapper thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
}

.datatable-wrapper thead th {
    position: relative;
    background: linear-gradient(to bottom, #f9fafb 0%, #f3f4f6 100%);
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    color: #111827;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.datatable-wrapper thead th:hover {
    background: linear-gradient(to bottom, #f3f4f6 0%, #e5e7eb 100%);
}

.datatable-wrapper .sort-icon {
    display: inline-block;
    margin-left: 0.5rem;
    color: #9ca3af;
    transition: color 0.2s ease, transform 0.2s ease;
}

.datatable-wrapper thead th:hover .sort-icon {
    color: #d31100;
}

.datatable-wrapper .sort-icon.active {
    color: #d31100;
    transform: scale(1.1);
}

.datatable-wrapper tbody tr {
    transition: background-color 0.15s ease;
}

.datatable-wrapper tbody tr:hover {
    background-color: #fee2e2 !important;
}

.datatable-wrapper tbody td {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
}


.bg-gray-900 .datatable-wrapper tbody tr:hover {
    background-color: #065f46 !important;
}

.bg-gray-900 .datatable-wrapper tbody td {
    color: #f9fafb;
    border-bottom: 1px solid #4b5563;
    background-color: #1f2937;
}

.bg-gray-900 .datatable-wrapper tbody tr {
    background-color: #1f2937 !important;
}

.bg-gray-900 .datatable-wrapper tbody tr:nth-child(even) {
    background-color: #374151 !important;
}

.bg-gray-900 .datatable-wrapper thead th {
    background: linear-gradient(to bottom, #374151 0%, #1f2937 100%);
    border-bottom: 2px solid #4b5563;
    color: #f9fafb;
}

.bg-gray-900 .datatable-wrapper thead th:hover {
    background: linear-gradient(to bottom, #4b5563 0%, #374151 100%);
}

.datatable-wrapper .overflow-x-auto {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.datatable-wrapper .overflow-x-auto::-webkit-scrollbar {
    height: 8px;
}

.datatable-wrapper .overflow-x-auto::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.datatable-wrapper .overflow-x-auto::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.datatable-wrapper .overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.datatable-wrapper .flex {
    flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .datatable-wrapper thead th,
    .datatable-wrapper tbody td,
    [id$="-fixed-header"] th {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    [id$="-fixed-container"] {
        font-size: 0.75rem;
    }
    
    /* Paginación más compacta en móvil */
    [id$="-pagination"] button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
    
    [id$="-pagination"] span {
        padding: 0.5rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

@media (max-width: 1024px) {
    .datatable-wrapper thead th,
    [id$="-fixed-header"] th {
        font-size: 0.7rem;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

[id$="-fixed-container"].visible {
    animation: slideDown 0.3s ease-out;
}

[id$="-fixed-container"]::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), transparent);
    pointer-events: none;
}

.datatable-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

.datatable-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #d31100;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.datatable-wrapper .export-dropdown {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.datatable-wrapper [class*="dropdown"] {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.datatable-wrapper [class*="dropdown"].hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

body.has-fixed-navbar [id$="-fixed-container"] {
    top: 64px;
}

body.has-fixed-navbar.navbar-h-20 [id$="-fixed-container"] {
    top: 80px;
}

body.has-fixed-navbar.navbar-h-24 [id$="-fixed-container"] {
    top: 96px;
}

/* Estilos para agrupación de filas */
.datatable-wrapper tbody tr.hidden {
    display: none !important;
}

.datatable-wrapper tbody tr.grupo-principal {
    cursor: pointer;
    font-weight: 600;
}

.datatable-wrapper tbody tr.grupo-principal:hover {
    background-color: #dbeafe !important;
}

.datatable-wrapper tbody tr.grupo-detalle {
    background-color: #fafafa;
}

.datatable-wrapper tbody tr.grupo-detalle:hover {
    background-color: #fee2e2 !important;
}

.datatable-wrapper .toggle-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

.datatable-wrapper .bi-chevron-down {
    transform: rotate(90deg);
}

.datatable-wrapper .bi-chevron-right {
    transform: rotate(0deg);
}
