/*
|--------------------------------------------------------------------------
| Viartas Admin Theme - DataTables Styles
| Custom styling for DataTables integration with Bootstrap 5
|--------------------------------------------------------------------------
*/

/* ========================================================================
   DataTables Wrapper
   ======================================================================== */

.dataTables_wrapper {
    padding: 0;
    font-family: var(--vt-font-family);
}

.dataTables_wrapper .row {
    margin: 0;
    align-items: center;
}

/* ========================================================================
   Export Buttons (Copy, Excel, CSV, PDF)
   ======================================================================== */

.dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.dt-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--vt-radius);
    border: 1px solid var(--vt-dark-200);
    background: var(--vt-card-bg);
    color: var(--vt-dark-600);
    transition: all var(--vt-transition-fast);
    cursor: pointer;
}

.dt-buttons .btn:hover {
    background: var(--vt-dark-50);
    border-color: var(--vt-dark-300);
    color: var(--vt-dark-800);
}

.dt-buttons .btn:active {
    transform: scale(0.98);
}

.dt-buttons .buttons-copy:before { content: '\f0c5'; font-family: 'Font Awesome 6 Free'; font-weight: 400; margin-right: 6px; }
.dt-buttons .buttons-excel:before { content: '\f1c3'; font-family: 'Font Awesome 6 Free'; font-weight: 400; margin-right: 6px; }
.dt-buttons .buttons-csv:before { content: '\f6dd'; font-family: 'Font Awesome 6 Free'; font-weight: 900; margin-right: 6px; }
.dt-buttons .buttons-pdf:before { content: '\f1c1'; font-family: 'Font Awesome 6 Free'; font-weight: 400; margin-right: 6px; }
.dt-buttons .buttons-print:before { content: '\f02f'; font-family: 'Font Awesome 6 Free'; font-weight: 900; margin-right: 6px; }

/* Button group style */
.dt-buttons.btn-group {
    gap: 0;
}

.dt-buttons.btn-group .btn {
    border-radius: 0;
}

.dt-buttons.btn-group .btn:first-child {
    border-radius: var(--vt-radius) 0 0 var(--vt-radius);
}

.dt-buttons.btn-group .btn:last-child {
    border-radius: 0 var(--vt-radius) var(--vt-radius) 0;
}

.dt-buttons.btn-group .btn:not(:last-child) {
    border-right: none;
}

/* ========================================================================
   Length Menu (Show entries dropdown)
   ======================================================================== */

.dataTables_length {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.dataTables_length label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--vt-dark-600);
    margin: 0;
}

.dataTables_length select {
    min-width: 70px;
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius);
    background-color: var(--vt-card-bg);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    color: var(--vt-dark-700);
    cursor: pointer;
    transition: all var(--vt-transition-fast);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.dataTables_length select:focus {
    outline: none;
    border-color: var(--vt-primary);
    box-shadow: 0 0 0 3px var(--vt-primary-light);
}

.dataTables_length select:hover {
    border-color: var(--vt-dark-300);
}

/* ========================================================================
   Search Filter
   ======================================================================== */

.dataTables_filter {
    margin-bottom: 16px;
}

.dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--vt-dark-600);
    margin: 0;
}

.dataTables_filter input {
    min-width: 200px;
    padding: 10px 16px;
    font-size: 14px;
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius);
    background: var(--vt-card-bg);
    color: var(--vt-dark-700);
    transition: all var(--vt-transition-fast);
}

.dataTables_filter input:focus {
    outline: none;
    border-color: var(--vt-primary);
    box-shadow: 0 0 0 3px var(--vt-primary-light);
}

.dataTables_filter input::placeholder {
    color: var(--vt-dark-400);
}

/* Search with icon */
.dataTables_filter label {
    position: relative;
}

.dataTables_filter input[type="search"] {
    padding-left: 40px;
}

.dataTables_filter label::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--vt-dark-400);
    font-size: 14px;
    pointer-events: none;
}

/* ========================================================================
   Table Styles
   ======================================================================== */

.dataTables_wrapper table.dataTable {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0 !important;
}

.dataTables_wrapper table.dataTable thead th {
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--vt-dark-500);
    background: var(--vt-dark-50);
    border-bottom: 1px solid var(--vt-dark-100);
    border-top: none;
    text-align: left;
    white-space: nowrap;
    position: relative;
}

.dataTables_wrapper table.dataTable thead th:first-child {
    border-radius: var(--vt-radius) 0 0 0;
}

.dataTables_wrapper table.dataTable thead th:last-child {
    border-radius: 0 var(--vt-radius) 0 0;
}

/* Sorting indicators */
.dataTables_wrapper table.dataTable thead th.sorting,
.dataTables_wrapper table.dataTable thead th.sorting_asc,
.dataTables_wrapper table.dataTable thead th.sorting_desc {
    cursor: pointer;
    padding-right: 30px;
}

.dataTables_wrapper table.dataTable thead th.sorting::after,
.dataTables_wrapper table.dataTable thead th.sorting_asc::after,
.dataTables_wrapper table.dataTable thead th.sorting_desc::after {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
    color: var(--vt-dark-400);
}

.dataTables_wrapper table.dataTable thead th.sorting::after {
    content: '\f0dc';
    opacity: 0.4;
}

.dataTables_wrapper table.dataTable thead th.sorting_asc::after {
    content: '\f0de';
    color: var(--vt-primary);
    opacity: 1;
}

.dataTables_wrapper table.dataTable thead th.sorting_desc::after {
    content: '\f0dd';
    color: var(--vt-primary);
    opacity: 1;
}

/* Column filter row (second header row) */
.dataTables_wrapper table.dataTable thead tr:nth-child(2) th {
    background: var(--vt-card-bg);
    padding: 8px 12px;
    border-bottom: 1px solid var(--vt-dark-100);
}

.dataTables_wrapper table.dataTable thead tr:nth-child(2) th input,
.dataTables_wrapper table.dataTable thead tr:nth-child(2) th select {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius-sm);
    background: var(--vt-dark-50);
    color: var(--vt-dark-700);
    transition: all var(--vt-transition-fast);
}

.dataTables_wrapper table.dataTable thead tr:nth-child(2) th input:focus,
.dataTables_wrapper table.dataTable thead tr:nth-child(2) th select:focus {
    outline: none;
    border-color: var(--vt-primary);
    background: var(--vt-card-bg);
    box-shadow: 0 0 0 2px var(--vt-primary-light);
}

/* Table body */
.dataTables_wrapper table.dataTable tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--vt-dark-700);
    border-bottom: 1px solid var(--vt-dark-100);
    vertical-align: middle;
    background: var(--vt-card-bg);
    transition: background var(--vt-transition-fast);
}

.dataTables_wrapper table.dataTable tbody tr:hover td {
    background: var(--vt-dark-50);
}

.dataTables_wrapper table.dataTable tbody tr:last-child td {
    border-bottom: none;
}

/* Striped rows */
.dataTables_wrapper table.dataTable.table-striped tbody tr.odd td {
    background: var(--vt-card-bg);
}

.dataTables_wrapper table.dataTable.table-striped tbody tr.even td {
    background: rgba(var(--vt-dark-50), 0.5);
}

.dataTables_wrapper table.dataTable.table-striped tbody tr:hover td {
    background: var(--vt-primary-light) !important;
}

/* ========================================================================
   Table Cell Elements
   ======================================================================== */

/* ID Column */
.dataTables_wrapper table.dataTable tbody td .sorting_1,
.dataTables_wrapper table.dataTable tbody td:first-child {
    font-weight: 600;
    color: var(--vt-dark-600);
}

/* Badges */
.dataTables_wrapper .badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 50px;
    text-transform: none;
}

.dataTables_wrapper .badge-primary {
    background: var(--vt-primary-light);
    color: var(--vt-primary);
}

.dataTables_wrapper .badge-secondary {
    background: var(--vt-dark-100);
    color: var(--vt-dark-600);
}

.dataTables_wrapper .badge-success {
    background: var(--vt-success-light);
    color: var(--vt-success);
}

.dataTables_wrapper .badge-danger {
    background: var(--vt-danger-light);
    color: var(--vt-danger);
}

.dataTables_wrapper .badge-warning {
    background: var(--vt-warning-light);
    color: var(--vt-warning);
}

.dataTables_wrapper .badge-info {
    background: var(--vt-info-light);
    color: var(--vt-info);
}

/* ========================================================================
   Table Switch (Toggle)
   ======================================================================== */

.table-switch .form-check {
    margin: 0;
    padding: 0;
    min-height: auto;
}

.table-switch .form-check-input {
    width: 40px;
    height: 22px;
    margin: 0;
    cursor: pointer;
    border: 2px solid var(--vt-dark-300);
    border-radius: 50px;
    background-color: var(--vt-dark-100);
    transition: all var(--vt-transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.table-switch .form-check-input:checked {
    background-color: var(--vt-success);
    border-color: var(--vt-success);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: right center;
    background-size: contain;
}

.table-switch .form-check-input:not(:checked) {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2394a3b8'/%3e%3c/svg%3e");
    background-position: left center;
    background-size: contain;
}

.table-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--vt-primary-light);
    border-color: var(--vt-primary);
}

/* ========================================================================
   Table Checkbox
   ======================================================================== */

.table-checkbox .form-check {
    margin: 0;
    padding: 0;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-checkbox .form-check-input {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    border: 2px solid var(--vt-dark-300);
    border-radius: 4px;
    background-color: var(--vt-card-bg);
    transition: all var(--vt-transition-fast);
}

.table-checkbox .form-check-input:checked {
    background-color: var(--vt-primary);
    border-color: var(--vt-primary);
}

.table-checkbox .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--vt-primary-light);
    border-color: var(--vt-primary);
}

/* Check/Uncheck all buttons */
.table-check-all,
.table-uncheck-all {
    padding: 6px 8px !important;
    font-size: 12px !important;
}

/* ========================================================================
   Table Action Buttons
   ======================================================================== */

.table-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.table-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 13px;
    border-radius: var(--vt-radius-sm);
    border: 1px solid transparent;
    transition: all var(--vt-transition-fast);
}

.table-buttons .btn-primary {
    background: var(--vt-primary-light);
    color: var(--vt-primary);
    border-color: transparent;
}

.table-buttons .btn-primary:hover {
    background: var(--vt-primary);
    color: white;
}

.table-buttons .btn-danger {
    background: var(--vt-danger-light);
    color: var(--vt-danger);
    border-color: transparent;
}

.table-buttons .btn-danger:hover {
    background: var(--vt-danger);
    color: white;
}

.table-buttons .btn-success {
    background: var(--vt-success-light);
    color: var(--vt-success);
    border-color: transparent;
}

.table-buttons .btn-success:hover {
    background: var(--vt-success);
    color: white;
}

.table-buttons .btn-warning {
    background: var(--vt-warning-light);
    color: var(--vt-warning);
    border-color: transparent;
}

.table-buttons .btn-warning:hover {
    background: var(--vt-warning);
    color: white;
}

.table-buttons .btn-info {
    background: var(--vt-info-light);
    color: var(--vt-info);
    border-color: transparent;
}

.table-buttons .btn-info:hover {
    background: var(--vt-info);
    color: white;
}

/* Icon-only buttons */
.table-buttons .btn-icon {
    width: 32px;
    height: 32px;
}

.table-buttons .btn-xs {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

/* ========================================================================
   Table Actions (Status Dropdown)
   ======================================================================== */

.table-actions .btn-group {
    display: flex;
}

.table-actions .dropdown-toggle {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--vt-radius-sm);
    min-width: 100px;
}

.table-actions .dropdown-toggle::after {
    margin-left: 8px;
}

.table-actions .dropdown-menu {
    min-width: 160px;
    padding: 8px;
    border: 1px solid var(--vt-dark-100);
    border-radius: var(--vt-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.table-actions .dropdown-item {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--vt-dark-700);
    border-radius: var(--vt-radius-sm);
    transition: all var(--vt-transition-fast);
}

.table-actions .dropdown-item:hover {
    background: var(--vt-dark-50);
    color: var(--vt-dark-800);
}

.table-actions .dropdown-item.active,
.table-actions .dropdown-item:active {
    background: var(--vt-primary-light);
    color: var(--vt-primary);
}

/* ========================================================================
   Pagination
   ======================================================================== */

.dataTables_paginate {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 16px;
}

.dataTables_paginate .pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dataTables_paginate .page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--vt-dark-600);
    background: var(--vt-card-bg);
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius-sm);
    transition: all var(--vt-transition-fast);
    text-decoration: none;
}

.dataTables_paginate .page-item .page-link:hover {
    background: var(--vt-dark-50);
    border-color: var(--vt-dark-300);
    color: var(--vt-dark-800);
}

.dataTables_paginate .page-item.active .page-link {
    background: var(--vt-primary);
    border-color: var(--vt-primary);
    color: white;
}

.dataTables_paginate .page-item.disabled .page-link {
    background: var(--vt-dark-50);
    border-color: var(--vt-dark-100);
    color: var(--vt-dark-400);
    cursor: not-allowed;
    pointer-events: none;
}

/* Previous/Next icons */
.dataTables_paginate .page-item .page-link .previous,
.dataTables_paginate .page-item .page-link .next {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-style: solid;
    border-width: 0 2px 2px 0;
    border-color: currentColor;
}

.dataTables_paginate .page-item .page-link .previous {
    transform: rotate(135deg);
}

.dataTables_paginate .page-item .page-link .next {
    transform: rotate(-45deg);
}

/* ========================================================================
   Info Text
   ======================================================================== */

.dataTables_info {
    font-size: 13px;
    color: var(--vt-dark-500);
    padding-top: 16px;
}

/* ========================================================================
   Processing Indicator
   ======================================================================== */

.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--vt-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--vt-dark-600);
}

.dataTables_processing .spinner-border {
    width: 20px;
    height: 20px;
    border-width: 2px;
    color: var(--vt-primary);
}

/* ========================================================================
   Empty Table
   ======================================================================== */

.dataTables_wrapper table.dataTable tbody td.dataTables_empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--vt-dark-500);
    font-size: 14px;
    background: var(--vt-dark-50);
}

/* ========================================================================
   Select2 Integration (for column filters)
   ======================================================================== */

.dataTables_wrapper .select2-container {
    min-width: 100%;
}

.dataTables_wrapper .select2-container--default .select2-selection--single {
    height: 36px;
    padding: 4px 8px;
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius-sm);
    background: var(--vt-dark-50);
}

.dataTables_wrapper .select2-container--default .select2-selection--single:focus {
    border-color: var(--vt-primary);
    box-shadow: 0 0 0 2px var(--vt-primary-light);
}

.dataTables_wrapper .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--vt-dark-700);
    line-height: 26px;
    padding-left: 4px;
}

.dataTables_wrapper .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 34px;
}

.dataTables_wrapper .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--vt-dark-400);
}

.dataTables_wrapper .select2-dropdown {
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.dataTables_wrapper .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--vt-primary);
    color: white;
}

/* ========================================================================
   Date Range Picker Integration
   ======================================================================== */

.dataTables_wrapper .daterangepicker-input {
    padding: 8px 10px;
    font-size: 12px;
    border: 1px solid var(--vt-dark-200);
    border-radius: var(--vt-radius-sm);
    background: var(--vt-dark-50);
    color: var(--vt-dark-700);
    transition: all var(--vt-transition-fast);
}

.dataTables_wrapper .daterangepicker-input:focus {
    outline: none;
    border-color: var(--vt-primary);
    background: var(--vt-card-bg);
    box-shadow: 0 0 0 2px var(--vt-primary-light);
}

/* ========================================================================
   Responsive Adjustments
   ======================================================================== */

@media (max-width: 991.98px) {
    .dataTables_wrapper .row > div {
        margin-bottom: 12px;
    }
    
    .dataTables_length,
    .dataTables_filter {
        justify-content: center;
    }
    
    .dataTables_info,
    .dataTables_paginate {
        justify-content: center;
        text-align: center;
    }
    
    .dt-buttons {
        justify-content: center;
    }
}

@media (max-width: 767.98px) {
    .dataTables_wrapper table.dataTable thead th,
    .dataTables_wrapper table.dataTable tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .table-buttons .btn {
        width: 28px;
        height: 28px;
    }
    
    .dataTables_filter input {
        min-width: 150px;
    }
}

/* ========================================================================
   Dark Mode Support
   ======================================================================== */

[data-theme="dark"] .dataTables_wrapper table.dataTable thead th {
    background: var(--vt-dark-800);
    border-color: var(--vt-dark-700);
    color: var(--vt-dark-400);
}

[data-theme="dark"] .dataTables_wrapper table.dataTable tbody td {
    background: var(--vt-dark-900);
    border-color: var(--vt-dark-700);
    color: var(--vt-dark-300);
}

[data-theme="dark"] .dataTables_wrapper table.dataTable tbody tr:hover td {
    background: var(--vt-dark-800);
}

[data-theme="dark"] .dataTables_length select,
[data-theme="dark"] .dataTables_filter input {
    background: var(--vt-dark-800);
    border-color: var(--vt-dark-700);
    color: var(--vt-dark-300);
}

[data-theme="dark"] .dataTables_paginate .page-item .page-link {
    background: var(--vt-dark-800);
    border-color: var(--vt-dark-700);
    color: var(--vt-dark-400);
}

[data-theme="dark"] .dataTables_paginate .page-item .page-link:hover {
    background: var(--vt-dark-700);
    color: var(--vt-dark-200);
}

[data-theme="dark"] .dataTables_processing {
    background: rgba(30, 41, 59, 0.95);
    color: var(--vt-dark-300);
}

[data-theme="dark"] .dt-buttons .btn {
    background: var(--vt-dark-800);
    border-color: var(--vt-dark-700);
    color: var(--vt-dark-400);
}

[data-theme="dark"] .dt-buttons .btn:hover {
    background: var(--vt-dark-700);
    color: var(--vt-dark-200);
}
