/**
 * DataTable Custom Styles
 * Global styling for DataTables - used across all pages
 *
 * My Ledgers / Supplier / Customer: scrollX only (wide columns). No scrollY —
 * table grows with rows on the current page; page scrolls if Show 25/50/100.
 * Use scrollY + datatable-scroll.js only on pages that need a fixed row viewport.
 */

/* ============================================
   DataTable Wrapper - Basic
   ============================================ */
.dataTables_wrapper .dataTables_length select {
    min-width: 80px;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: #7366ff;
    box-shadow: 0 0 0 0.2rem rgba(115, 102, 255, 0.15);
    outline: none;
}

/* ============================================
   DataTable Search & Buttons Layout
   ============================================ */
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
}

.dataTables_wrapper .dataTables_filter label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dataTables_wrapper .dataTables_filter input {
    margin-left: 0;
    width: auto;
    min-width: 250px;
    height: 31px;
    padding: 0.25rem 0.75rem;
}

/* Length dropdown alignment */
.dataTables_wrapper .dataTables_length {
    display: flex;
    align-items: center;
}

.dataTables_wrapper .dataTables_length label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_length select {
    height: 31px;
    padding: 0.25rem 2rem 0.25rem 0.75rem;
}

/* ============================================
   DataTable Button Group (Export, Refresh, Delete)
   ============================================ */
.dataTables_wrapper .dt-buttons {
    display: flex;
    gap: 0;
    align-items: center;
    margin-left: 0.5rem;
}

.dataTables_wrapper .dt-buttons .btn {
    margin: 0;
    border-radius: 0;
    height: 31px;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-width: 1px;
}

.dataTables_wrapper .dt-buttons .btn i {
    font-size: 13px;
}

/* First button - left rounded only */
.dataTables_wrapper .dt-buttons .btn:first-child {
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

/* Middle buttons - no rounded corners */
.dataTables_wrapper .dt-buttons .btn:not(:first-child):not(:last-child) {
    border-radius: 0;
    border-right: none;
}

/* Last button - right rounded only */
.dataTables_wrapper .dt-buttons .btn:last-child {
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

/* Hover effect to show borders */
.dataTables_wrapper .dt-buttons .btn:hover {
    z-index: 1;
    border-right: 1px solid;
}

/* Fix dropdown caret alignment */
.dataTables_wrapper .dt-buttons .btn .dt-button-collection {
    height: auto;
}

/* ============================================
   DataTable Button Colors
   ============================================ */
/* Primary Button */
.dataTables_wrapper .btn-primary {
    background-color: #7366ff;
    border-color: #7366ff;
    color: #ffffff;
}

.dataTables_wrapper .btn-primary:hover {
    background-color: #5a4fd1;
    border-color: #5a4fd1;
    color: #ffffff;
}

/* Outline Buttons */
.dataTables_wrapper .btn-outline-primary {
    background-color: transparent;
    border-color: #7366ff;
    color: #7366ff;
}

.dataTables_wrapper .btn-outline-primary:hover {
    background-color: #7366ff;
    border-color: #7366ff;
    color: #ffffff;
}

.dataTables_wrapper .btn-outline-success {
    background-color: transparent;
    border-color: #28c76f;
    color: #28c76f;
}

.dataTables_wrapper .btn-outline-success:hover {
    background-color: #28c76f;
    border-color: #28c76f;
    color: #ffffff;
}

.dataTables_wrapper .btn-outline-danger {
    background-color: transparent;
    border-color: #ea5455;
    color: #ea5455;
}

.dataTables_wrapper .btn-outline-danger:hover {
    background-color: #ea5455;
    border-color: #ea5455;
    color: #ffffff;
}

.dataTables_wrapper .btn-outline-secondary {
    background-color: transparent;
    border-color: #82868b;
    color: #6c757d;
}

.dataTables_wrapper .btn-outline-secondary:hover {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #ffffff;
}

/* Delete button disabled state */
.btn-delete-selected:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   DataTable Button Collection (Export Dropdown)
   ============================================ */
.dataTables_wrapper .dt-button-collection {
    padding: 8px;
    border-radius: 8px;
}

div.dt-button-collection {
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    background-color: #ffffff;
}

div.dt-button-collection .dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    color: #6c757d;
    font-size: 13px;
    transition: all 0.2s ease;
}

div.dt-button-collection .dropdown-item:hover {
    background-color: rgba(115, 102, 255, 0.1);
    color: #7366ff;
}

div.dt-button-collection .dropdown-item i {
    width: 20px;
    opacity: 0.7;
}

div.dt-button-collection .dropdown-item:hover i {
    opacity: 1;
}

/* ============================================
   DataTable Pagination
   ============================================ */
.dataTables_paginate {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.dataTables_paginate .paginate_button {
    min-width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.dataTables_paginate .paginate_button:hover:not(.disabled):not(.current) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.dataTables_paginate .paginate_button.current {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    font-weight: 600;
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f8f9fa;
}

.dataTables_paginate .paginate_button.disabled:hover {
    background: transparent !important;
    border-color: transparent !important;
    color: #6c757d !important;
}

.dataTables_paginate .paginate_button.previous,
.dataTables_paginate .paginate_button.next {
    color: #0d6efd;
}

.dataTables_paginate .paginate_button.previous:hover:not(.disabled),
.dataTables_paginate .paginate_button.next:hover:not(.disabled) {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

/* ============================================
   DataTable Info Text
   ============================================ */
.dataTables_wrapper .dataTables_info {
    font-size: 13px;
    color: #6c757d;
}

/* ============================================
   Table Row Styles
   ============================================ */
.table.dataTable tbody tr:hover {
    background-color: rgba(115, 102, 255, 0.05) !important;
}

.table.dataTable tbody tr.selected {
    background-color: rgba(115, 102, 255, 0.1) !important;
}

.table.dataTable tbody tr.table-secondary {
    opacity: 0.7;
}

.table.dataTable tbody tr.table-warning-subtle {
    background-color: rgba(255, 159, 67, 0.05) !important;
}

/* ============================================
   Table Header - No Sort Columns
   ============================================ */
.no-sort {
    cursor: default !important;
}

.no-sort::before,
.no-sort::after {
    display: none !important;
}

/* ============================================
   Table Header Filter Dropdowns
   ============================================ */
.dataTables_wrapper th select.form-select,
.dataTables_wrapper th select.form-select-sm {
    border: 1px solid #dee2e6;
    background: #fff;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    cursor: pointer;
    min-width: 120px;
    border-radius: 0.25rem;
    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='%23343a40' 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 0.75rem center;
    background-size: 16px 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.dataTables_wrapper th select.form-select:hover,
.dataTables_wrapper th select.form-select-sm:hover {
    border-color: #adb5bd;
}

.dataTables_wrapper th select.form-select:focus,
.dataTables_wrapper th select.form-select-sm:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* ============================================
   User Avatar in Table
   ============================================ */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================
   Status Badges - Soft Variants
   ============================================ */
.badge-soft-success {
    background-color: rgba(40, 199, 111, 0.1);
    color: #28c76f;
}

.badge-soft-warning {
    background-color: rgba(255, 159, 67, 0.1);
    color: #ff9f43;
}

.badge-soft-danger {
    background-color: rgba(234, 84, 85, 0.1);
    color: #ea5455;
}

.badge-soft-info {
    background-color: rgba(0, 207, 232, 0.1);
    color: #00cfe8;
}

.badge-soft-primary {
    background-color: rgba(115, 102, 255, 0.1);
    color: #7366ff;
}

.badge-soft-secondary {
    background-color: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}

/* ============================================
   Loading Indicator
   ============================================ */
.dataTables_processing {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

/* ============================================
   Fixed Header Adjustments
   ============================================ */
.dtfh-floatingparent {
    z-index: 1020;
}

/* ============================================
   Select Checkbox Column
   ============================================ */
table.dataTable tbody td.select-checkbox {
    position: relative;
}

table.dataTable tbody td.select-checkbox::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    margin: 0 auto;
    transition: all 0.2s ease;
}

table.dataTable tbody tr.selected td.select-checkbox::before {
    border-color: #7366ff;
    background-color: #7366ff;
}

table.dataTable tbody tr.selected td.select-checkbox::after {
    content: '?';
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
}

/* ============================================
   Action Buttons & Dropdowns in Table
   ============================================ */
.btn-group .btn {
    padding: 4px 8px;
}

.btn-group .btn i {
    font-size: 14px;
}

/* Row action dropdowns — unclip while open (see datatable-dropdown.js) */
.dataTables_wrapper.dt-row-dropdown-open,
div[id$="_wrapper"].dt-row-dropdown-open {
    position: relative;
    z-index: 30;
}

.dataTables_wrapper.dt-row-dropdown-open .dataTables_scroll,
.dataTables_wrapper.dt-row-dropdown-open .dataTables_scrollBody,
div[id$="_wrapper"].dt-row-dropdown-open .dataTables_scroll,
div[id$="_wrapper"].dt-row-dropdown-open .dataTables_scrollBody {
    overflow: visible !important;
    overflow-y: visible !important;
}

.table-responsive.dt-row-dropdown-open {
    overflow: visible !important;
}

.dataTables_wrapper table.dataTable tbody td .dropdown {
    position: relative;
}

.dataTables_wrapper table.dataTable tbody .dropdown-menu {
    z-index: 1060;
}

.table .dropdown-menu {
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.table .dropdown-item {
    padding: 8px 16px;
    font-size: 13px;
}

.table .dropdown-item i {
    width: 18px;
}

/* ============================================
   Empty/Zero Records Message
   ============================================ */
.dataTables_empty {
    padding: 30px !important;
}

/* ============================================
   Responsive - Tablet
   ============================================ */
@media (max-width: 1199.98px) {
    .dataTables_wrapper .dataTables_filter input {
        min-width: 200px;
    }
}

/* ============================================
   Responsive - Mobile
   ============================================ */
@media (max-width: 768px) {
    .dataTables_wrapper .dt-buttons {
        margin-bottom: 10px;
    }

    .dataTables_wrapper .dt-buttons .btn {
        font-size: 12px;
        padding: 5px 10px;
    }

    .dataTables_wrapper .dataTables_filter input {
        min-width: 180px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
}
