/* TTConfirm DataTables Custom Styling */

/* ========================================
   Table Wrapper
   ======================================== */

.dataTables_wrapper {
    padding: 20px 0;
    font-family: Arial, sans-serif;
}

/* Top section (length menu and search) */
.datatable-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

/* Bottom section (info and pagination) */
.datatable-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.clear {
    clear: both;
}

/* ========================================
   Search Box
   ======================================== */

.dataTables_filter {
    float: right;
}

.dataTables_filter label {
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dataTables_filter input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    margin-left: 8px;
    width: 250px;
    font-size: 14px;
}

.dataTables_filter input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

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

.dataTables_length {
    float: left;
}

.dataTables_length label {
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dataTables_length select {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    margin: 0 8px;
    font-size: 14px;
    cursor: pointer;
}

.dataTables_length select:focus {
    outline: none;
    border-color: #007bff;
}

/* ========================================
   Table Styling
   ======================================== */

table.dataTable {
    width: 100% !important;
    margin: 0 auto;
    clear: both;
    border-collapse: collapse;
}

table.dataTable thead th {
    position: relative;
    cursor: pointer;
    padding-right: 30px !important;
}

table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    cursor: pointer;
}

/* Sorting indicators */
table.dataTable thead th.sorting:before,
table.dataTable thead th.sorting:after,
table.dataTable thead th.sorting_asc:before,
table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:before,
table.dataTable thead th.sorting_desc:after {
    position: absolute;
    right: 8px;
    display: block;
    opacity: 0.3;
    font-size: 14px;
}

table.dataTable thead th.sorting:before {
    content: "↑";
    top: 30%;
}

table.dataTable thead th.sorting:after {
    content: "↓";
    top: 50%;
}

table.dataTable thead th.sorting_asc:before {
    content: "↑";
    top: 40%;
    opacity: 1;
    color: #007bff;
}

table.dataTable thead th.sorting_desc:after {
    content: "↓";
    top: 40%;
    opacity: 1;
    color: #007bff;
}

/* Actions column - no sorting */
table.dataTable thead th.actions-column {
    cursor: default !important;
}

table.dataTable thead th.actions-column:before,
table.dataTable thead th.actions-column:after {
    display: none !important;
}

/* ========================================
   Column Filters
   ======================================== */

thead tr.filters th {
    padding: 8px !important;
    background-color: #f8f9fa;
}

thead tr.filters input.column-filter,
thead tr.filters select.column-filter {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    box-sizing: border-box;
}

thead tr.filters input.column-filter:focus,
thead tr.filters select.column-filter:focus {
    outline: none;
    border-color: #007bff;
}

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

.dataTables_paginate {
    float: right;
    text-align: right;
    padding-top: 0.25em;
}

.dataTables_paginate .paginate_button {
    box-sizing: border-box;
    display: inline-block;
    min-width: 1.5em;
    padding: 6px 12px;
    margin-left: 2px;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
    color: #333 !important;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

.dataTables_paginate .paginate_button:hover {
    color: white !important;
    border-color: #007bff;
    background-color: #007bff;
}

.dataTables_paginate .paginate_button.current {
    color: white !important;
    border-color: #007bff;
    background-color: #007bff;
}

.dataTables_paginate .paginate_button.current:hover {
    color: white !important;
    border-color: #0056b3;
    background-color: #0056b3;
}

.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover,
.dataTables_paginate .paginate_button.disabled:active {
    cursor: default;
    color: #999 !important;
    border-color: #ddd;
    background: white;
    opacity: 0.5;
}

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

.dataTables_info {
    clear: both;
    float: left;
    padding-top: 0.755em;
    font-size: 14px;
    color: #666;
}

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

.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    margin-left: -100px;
    margin-top: -26px;
    text-align: center;
    padding: 1em 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

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

.dataTables_empty {
    text-align: center !important;
    color: #999;
    font-style: italic;
    padding: 20px !important;
}

/* ========================================
   Responsive Features
   ======================================== */

/* Responsive control (expand/collapse button) */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    content: '+';
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    font-weight: bold;
    cursor: pointer;
    margin-right: 8px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before {
    content: '-';
    background-color: #dc3545;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
    cursor: pointer;
}

/* Child row styling (expanded details) */
table.dataTable > tbody > tr.child {
    background-color: #f8f9fa;
}

table.dataTable > tbody > tr.child ul.dtr-details {
    display: block;
    list-style: none;
    padding: 10px;
    margin: 0;
}

table.dataTable > tbody > tr.child ul.dtr-details > li {
    padding: 5px 0;
    border-bottom: 1px solid #ddd;
}

table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
    border-bottom: none;
}

table.dataTable > tbody > tr.child span.dtr-title {
    display: inline-block;
    min-width: 150px;
    font-weight: bold;
    color: #333;
}

table.dataTable > tbody > tr.child span.dtr-data {
    color: #666;
}

@media screen and (max-width: 768px) {
    .datatable-top,
    .datatable-bottom {
        flex-direction: column;
        align-items: stretch;
    }

    .dataTables_filter,
    .dataTables_length,
    .dataTables_info,
    .dataTables_paginate {
        float: none;
        text-align: center;
        margin: 5px 0;
    }

    .dataTables_filter input {
        width: 100%;
        max-width: 300px;
    }

    .dataTables_paginate .paginate_button {
        padding: 4px 8px;
        font-size: 12px;
    }

    /* Make table more compact on mobile */
    table.dataTable thead th,
    table.dataTable tbody td {
        padding: 8px 5px !important;
        font-size: 14px;
    }

    /* Ensure child rows are readable */
    table.dataTable > tbody > tr.child span.dtr-title {
        min-width: 100px;
        font-size: 13px;
    }
}

@media screen and (max-width: 480px) {
    .dataTables_filter input {
        width: 100%;
    }

    .dataTables_length select {
        width: auto;
        max-width: 100px;
    }

    .dataTables_info {
        font-size: 12px;
    }
}

/* ========================================
   Integration with Existing minimalistBlack Style
   ======================================== */

table.minimalistBlack.dataTable {
    /* Preserve existing minimalistBlack styling while adding DataTables features */
}

table.minimalistBlack.dataTable thead th {
    /* Ensure sorting indicators don't conflict with existing header style */
    vertical-align: middle;
}

/* ========================================
   Accessibility
   ======================================== */

/* Focus indicators */
.dataTables_wrapper input:focus,
.dataTables_wrapper select:focus,
.dataTables_wrapper button:focus,
.dataTables_paginate .paginate_button:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .dataTables_filter,
    .dataTables_length,
    .dataTables_info,
    .dataTables_paginate {
        display: none;
    }

    table.dataTable {
        border-collapse: collapse !important;
    }

    table.dataTable thead th {
        border-bottom: 2px solid black !important;
    }
}
