/**
 * TTAssure DataTables Custom Styles
 * Version: 1.0
 *
 * Custom styling for DataTables to match TTConfirm V2 design system.
 * Uses minimalistBlack table theme with primary blue accents.
 */

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

.dataTables_wrapper {
    font-family: Arial, sans-serif;
    color: #333;
}

/* Top section - length menu and search */
.dt-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.dt-length {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dt-search {
    display: flex;
    align-items: center;
}

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

.dataTables_filter {
    margin: 0;
}

.dataTables_filter label {
    display: flex;
    align-items: center;
    margin: 0;
}

.dataTables_filter input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    width: 250px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.dataTables_filter input::placeholder {
    color: #999;
}

/* ==========================================================================
   Length Menu
   ========================================================================== */

.dataTables_length {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 13px;
}

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

.dataTables_length select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

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

/* ==========================================================================
   Table Styles (minimalistBlack theme)
   ========================================================================== */

table.dataTable {
    width: 100% !important;
    border: 3px solid black;
    border-collapse: collapse;
    margin: 0 !important;
}

table.dataTable thead {
    background: linear-gradient(180deg, #dbdbdb 0%, #cfcfcf 100%);
}

table.dataTable thead th {
    padding: 12px 10px;
    font-weight: bold;
    font-size: 13px;
    color: black;
    border: 1px solid black;
    text-align: left;
    white-space: nowrap;
}

table.dataTable thead th:focus {
    outline: none;
}

table.dataTable tbody td {
    padding: 10px;
    font-size: 12px;
    border: 1px solid black;
    vertical-align: middle;
    text-align: left;
}

table.dataTable tbody tr:hover {
    background-color: #f4f4f4 !important;
}

table.dataTable tbody tr.odd {
    background-color: #fff;
}

table.dataTable tbody tr.even {
    background-color: #fafafa;
}

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

table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #666;
}

table.dataTable thead th.sorting::after {
    content: "▲▼";
    opacity: 0.4;
    font-size: 8px;
}

table.dataTable thead th.sorting_asc::after {
    content: "▲";
    opacity: 1;
    color: #007bff;
}

table.dataTable thead th.sorting_desc::after {
    content: "▼";
    opacity: 1;
    color: #007bff;
}

/* Non-sortable columns */
table.dataTable thead th.sorting_disabled {
    cursor: default;
    padding-right: 10px;
}

table.dataTable thead th.sorting_disabled::after {
    display: none;
}

/* ==========================================================================
   Bottom Section - Info and Pagination
   ========================================================================== */

.dt-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.dt-info {
    color: #666;
    font-size: 13px;
}

.dataTables_info {
    color: #666;
    font-size: 13px;
}

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

.dataTables_paginate {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dataTables_paginate .paginate_button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f4f4f4;
    color: #333;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.dataTables_paginate .paginate_button:hover:not(.disabled):not(.current) {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

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

.dataTables_paginate .paginate_button.disabled {
    background: #f4f4f4;
    border-color: #ddd;
    color: #ccc;
    cursor: not-allowed;
}

.dataTables_paginate .ellipsis {
    padding: 8px 4px;
    color: #999;
}

/* ==========================================================================
   Column Alignment
   ========================================================================== */

/* Force left alignment on all data columns (except actions) */
table.dataTable thead th:not(.dt-actions),
table.dataTable tbody td:not(.dt-actions) {
    text-align: left !important;
}

/* Explicitly left-align first column (filename/name) */
table.dataTable thead th:first-child,
table.dataTable tbody td:first-child {
    text-align: left !important;
}

/* Center-aligned columns (add dt-center class where needed) */
.dt-center {
    text-align: center !important;
}

/* ==========================================================================
   Action Buttons (test-button pattern)
   ========================================================================== */

.dt-actions {
    white-space: nowrap;
    text-align: center !important;
}

.dt-action-btn {
    display: inline-block;
    padding: 4px 10px;
    background: #cfcfcf;
    color: black;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 2px;
}

.dt-action-btn:hover {
    background: #0056b3;
    color: white;
}

.dt-action-btn.dt-btn-delete:hover,
.dt-action-btn[data-action="delete"]:hover {
    background: #c62828;
    color: white;
}

.dt-action-btn.dt-btn-success:hover {
    background: #2e7d32;
    color: white;
}

/* Emoji action buttons */
.dt-action-btn-icon {
    display: inline-block;
    padding: 4px 10px;
    background: #cfcfcf;
    color: black;
    border: none;
    border-radius: 5px;
    font-size: 1.25em;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 2px;
}

.dt-action-btn-icon:hover {
    background: #0056b3;
    color: white;
}

.dt-action-btn-icon.dt-btn-delete:hover {
    background: #c62828;
    color: white;
}

/* ==========================================================================
   Responsive Details
   ========================================================================== */

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    background: #007bff;
    border-radius: 50%;
    box-shadow: none;
}

.dt-details-table {
    width: 100%;
    margin: 8px 0;
    border-collapse: collapse;
}

.dt-details-table td {
    padding: 6px 12px;
    border: none !important;
    font-size: 12px;
}

.dt-detail-label {
    font-weight: 600;
    color: #666;
    width: 30%;
    text-align: right;
    padding-right: 16px !important;
}

.dt-detail-value {
    color: #333;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.dataTables_empty {
    text-align: center;
    padding: 40px 20px !important;
    color: #999;
    font-size: 14px;
}

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

.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: #333;
    font-size: 14px;
    z-index: 100;
}

/* ==========================================================================
   Status Badges in Tables
   ========================================================================== */

.dt-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.dt-badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.dt-badge-warning {
    background: #fff3e0;
    color: #e65100;
}

.dt-badge-error {
    background: #ffebee;
    color: #c62828;
}

.dt-badge-info {
    background: #e3f2fd;
    color: #1565c0;
}

/* Workflow status aliases */
.dt-badge-pending {
    background: #fff3e0;
    color: #e65100;
}

.dt-badge-running {
    background: #e3f2fd;
    color: #1565c0;
}

.dt-badge-failed {
    background: #ffebee;
    color: #c62828;
}

.dt-badge-timeout {
    background: #ffebee;
    color: #c62828;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
    .dt-top,
    .dt-bottom {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .dt-length,
    .dt-search,
    .dt-info,
    .dt-pagination {
        width: 100%;
    }

    .dataTables_filter input {
        width: 100%;
    }

    .dataTables_paginate {
        justify-content: center;
        flex-wrap: wrap;
    }

    .dataTables_paginate .paginate_button {
        padding: 6px 10px;
        font-size: 12px;
    }

    table.dataTable thead th,
    table.dataTable tbody td {
        padding: 8px;
        font-size: 11px;
    }

    .dt-action-btn {
        padding: 3px 8px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .dataTables_length {
        font-size: 12px;
    }

    .dataTables_filter input {
        font-size: 12px;
        padding: 6px 10px;
    }

    .dataTables_info {
        font-size: 12px;
        text-align: center;
    }

    .dt-action-btn {
        padding: 2px 6px;
        font-size: 11px;
        margin: 1px;
    }
}

/* ==========================================================================
   DataTables in Container
   ========================================================================== */

.datatable-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.datatable-container table.dataTable {
    margin: 0 !important;
}

/* Hide default DataTables border styling */
table.dataTable.no-footer {
    border-bottom: 3px solid black;
}

table.dataTable thead th,
table.dataTable thead td {
    border-bottom: none;
}

/* Fix for scrolling tables */
.dataTables_scrollHead {
    border: 3px solid black !important;
    border-bottom: none !important;
}

.dataTables_scrollBody {
    border: 3px solid black !important;
    border-top: none !important;
}
