/* ========================================
   DS-DATATABLES REUSABLE CSS
   Generic DataTables styling for Holiday Bright Lights
   ======================================== */

/* === BASE CARD STYLING === */
.ds-form-card {
    border: none;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
    background: var(--theme-bg-card, #ffffff);
    color: var(--theme-text-color, inherit);
}

.ds-card-header {
    border-bottom: 3px solid var(--theme-primary-500, var(--primary));
    padding: 1rem 1.25rem;
    border-radius: 0.25rem 0.25rem 0 0;
    background: var(--theme-bg-card-header, rgba(var(--theme-rgb-primary), 0.05));
}

.ds-card-header h6 {
    margin: 0;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1.1;
    white-space: normal;
    flex-wrap: wrap;
    color: var(--theme-text-color, inherit);
}

.ds-card-header i {
    font-size: 1rem;
    line-height: 1;
    flex: 0 0 auto;
    color: var(--theme-primary-500, var(--primary));
}

.ds-card-header h6 .badge {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    vertical-align: middle;
    margin-top: -1px;
}

.ds-card-body {
    padding: 1.5rem;
    background: var(--theme-bg-card, #ffffff);
    color: var(--theme-text-color, inherit);
}

/* === FILTER SECTION === */
.ds-filter-section {
    background: var(--theme-bg-subtle, #f8f9fc);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--theme-border-color, rgba(0, 0, 0, 0.1));
}

.ds-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ds-filter-btn {
    border-radius: 20px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    color: var(--theme-text-muted, #6c757d);
    background: var(--theme-bg-card, #ffffff);
}

.ds-filter-btn.active {
    border-color: var(--theme-primary-500, var(--primary));
    background: var(--theme-primary-500, var(--primary));
    color: var(--theme-text-on-primary, #ffffff);
    box-shadow: 0 0.125rem 0.25rem rgba(var(--theme-rgb-primary), 0.3);
}

.ds-filter-btn:not(.active) {
    border-color: var(--theme-border-color, #dee2e6);
    background: var(--theme-bg-card, #ffffff);
    color: var(--theme-text-muted, #6c757d);
}

.ds-filter-btn:not(.active):hover {
    border-color: var(--theme-primary-500, var(--primary));
    color: var(--theme-primary-500, var(--primary));
    background: var(--theme-bg-hover, rgba(var(--theme-rgb-primary), 0.1));
}

.ds-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.ds-filter-active {
    border-color: var(--theme-primary-500, var(--primary)) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--theme-rgb-primary), 0.25) !important;
}

/* === TABLE WRAPPER === */
.ds-table-wrapper {
    background: var(--theme-bg-card, #ffffff);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    overflow: hidden;
}

/* === TABLE STYLES AND CHILD ELEMENT STYLING === */
.ds-table {
    vertical-align: middle;
    color: var(--theme-text-color, inherit);
    border-color: var(--theme-border-color, #dee2e6);
}

.ds-table td {
    vertical-align: middle;
    color: var(--theme-text-color, inherit);
    border-color: var(--theme-border-color, #dee2e6);
}

/* DataTable-specific styling for standard Bootstrap components */
.ds-table .badge {
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    border: 1px solid transparent;
}

.ds-table .badge-primary {
    background: var(--theme-primary-500, #007bff);
    color: var(--theme-text-on-primary, #ffffff);
    border-color: var(--theme-primary-500, #007bff);
}

.ds-table .badge-secondary {
    background: var(--theme-bg-secondary, #6c757d);
    color: var(--theme-text-on-secondary, #ffffff);
    border-color: var(--theme-bg-secondary, #6c757d);
}

.ds-table .badge-success {
    background: var(--theme-bg-success, #28a745);
    color: var(--theme-text-on-success, #ffffff);
    border-color: var(--theme-bg-success, #28a745);
}

.ds-table .badge-info {
    background: var(--theme-bg-info-subtle, #17a2b8);
    color: var(--theme-text-on-info, #ffffff);
    border-color: var(--theme-bg-info, #17a2b8);
}

.ds-table .badge-warning {
    background: var(--theme-bg-warning, #ffc107);
    color: var(--theme-text-on-warning, #212529);
    border-color: var(--theme-bg-warning, #ffc107);
}

.ds-table .badge-danger {
    background: var(--theme-bg-danger, #dc3545);
    color: var(--theme-text-on-danger, #ffffff);
    border-color: var(--theme-bg-danger, #dc3545);
}

/* Icons within DataTables get consistent spacing */
.ds-table i[class*="fa"] {
    margin-right: 0.25rem;
}

.ds-table i[class*="fa"]:last-child {
    margin-right: 0;
}

/* Text-based metrics styling */
.ds-table .text-center {
    text-align: center;
    min-width: 70px;
}

/* Code elements within tables */
.ds-table code {
    background-color: var(--theme-bg-code, #f8f9fa);
    padding: 2px 4px;
    border-radius: 3px;
    color: var(--theme-text-code, #e83e8c);
    border: 1px solid var(--theme-border-color, rgba(0, 0, 0, 0.1));
    font-size: 0.875em;
}

/* Small elements for additional info */
.ds-table small {
    font-size: 0.75em;
    opacity: 0.8;
}

/* Timing/schedule badges with special styling */
.ds-table .badge.timing-badge {
    border-radius: 12px;
    background: var(--theme-bg-info-subtle, #e3f2fd);
    color: var(--theme-text-info, #1976d2);
    border: 1px solid var(--theme-border-info, rgba(25, 118, 210, 0.25));
}

/* Performance metric containers */
.ds-table .performance-metric,
.ds-table .usage-metric {
    text-align: center;
    min-width: 70px;
}

/* Enhanced div containers for statistics */
.ds-table .stat-item {
    padding: 15px;
    border-radius: 8px;
    background: var(--theme-bg-subtle, rgba(0, 123, 255, .1));
    margin: 5px 0;
    text-align: center;
    color: var(--theme-text-color, inherit);
    border: 1px solid var(--theme-border-color, rgba(0, 0, 0, 0.1));
}

/* === MODAL STYLES === */
.ds-modal .swal2-popup {
    font-size: 14px;
    text-align: left !important;
    background-color: var(--theme-bg-card, #ffffff) !important;
    color: var(--theme-text-color, inherit) !important;
}

.ds-modal .swal2-title {
    text-align: center !important;
    color: var(--theme-text-color, inherit) !important;
}

.ds-modal-content {
    text-align: left;
    color: var(--theme-text-color, inherit);
}

.ds-modal-content h6 {
    text-align: left;
    margin-bottom: 0.5rem;
    color: var(--theme-text-color, inherit);
}

.ds-modal-content p {
    text-align: left;
    color: var(--theme-text-muted, #6c757d);
}

.ds-modal-content .border {
    text-align: left;
    border-color: var(--theme-border-color, #dee2e6) !important;
    background: var(--theme-bg-subtle, #f8f9fa);
    color: var(--theme-text-color, inherit);
}

.ds-modal-content code {
    background-color: var(--theme-bg-code, #f8f9fa);
    padding: 2px 4px;
    border-radius: 3px;
    color: var(--theme-text-code, #e83e8c);
    border: 1px solid var(--theme-border-color, rgba(0, 0, 0, 0.1));
}

.ds-modal-content .stat-item {
    padding: 15px;
    border-radius: 8px;
    background: var(--theme-bg-subtle, rgba(0, 123, 255, .1));
    margin: 5px 0;
    text-align: center;
    color: var(--theme-text-color, inherit);
    border: 1px solid var(--theme-border-color, rgba(0, 0, 0, 0.1));
}

.ds-modal-content .alert {
    text-align: left;
    background-color: var(--theme-bg-info-subtle, rgba(var(--theme-rgb-info), 0.1));
    border-color: var(--theme-info-border, rgba(var(--theme-rgb-info), 0.25));
    color: var(--theme-text-color, inherit);
}

/* === DARK MODE OVERRIDES === */
.mod-skin-dark:not(.mod-skin-light) .ds-form-card {
    background: var(--theme-bg-card, #26272b);
    color: var(--theme-text-color, #a5abb1);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.25);
}

.mod-skin-dark:not(.mod-skin-light) .ds-card-header {
    background: var(--theme-bg-card-header, rgba(var(--theme-rgb-primary), 0.1));
    border-bottom-color: var(--theme-primary-500, #886ab5);
}

.mod-skin-dark:not(.mod-skin-light) .ds-card-body {
    background: var(--theme-bg-card, #26272b);
    color: var(--theme-text-color, #a5abb1);
}

.mod-skin-dark:not(.mod-skin-light) .ds-filter-section {
    background: var(--theme-bg-subtle, #303136);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .ds-filter-btn {
    background: var(--theme-bg-card, #37393e);
    color: var(--theme-text-muted, #a5abb1);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .ds-filter-btn.active {
    border-color: var(--theme-primary-500, #886ab5);
    background: var(--theme-primary-500, #886ab5);
    color: var(--theme-text-on-primary, #ffffff);
    box-shadow: 0 0.125rem 0.25rem rgba(136, 106, 181, 0.3);
}

.mod-skin-dark:not(.mod-skin-light) .ds-filter-btn:not(.active):hover {
    border-color: var(--theme-primary-500, #886ab5);
    color: var(--theme-primary-500, #886ab5);
    background: rgba(var(--theme-rgb-primary), 0.1);
}

.mod-skin-dark:not(.mod-skin-light) .ds-table-wrapper {
    background: var(--theme-bg-card, #26272b);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.25);
}

.mod-skin-dark:not(.mod-skin-light) .ds-table .badge {
    border-color: rgba(255, 255, 255, 0.15);
}

.mod-skin-dark:not(.mod-skin-light) .ds-table .badge.timing-badge {
    background: var(--theme-bg-info-subtle, rgba(136, 106, 181, 0.15));
    color: var(--theme-text-info, #ffffff);
    border-color: var(--theme-border-info, rgba(136, 106, 181, 0.25));
}

.mod-skin-dark:not(.mod-skin-light) .ds-table code {
    background-color: var(--theme-bg-code, #2d2e32);
    color: var(--theme-text-code, #fd3995);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .ds-table .stat-item {
    background: var(--theme-bg-subtle, rgba(136, 106, 181, 0.15));
    color: var(--theme-text-color, #ffffff);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .ds-modal-content .border {
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15)) !important;
    background: var(--theme-bg-subtle, #303136);
    color: var(--theme-text-color, #a5abb1);
}

.mod-skin-dark:not(.mod-skin-light) .ds-modal-content code {
    background-color: var(--theme-bg-code, #2d2e32);
    color: var(--theme-text-code, #fd3995);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .ds-modal-content .stat-item {
    background: var(--theme-bg-subtle, rgba(136, 106, 181, 0.15));
    color: var(--theme-text-color, #ffffff);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .ds-modal-content .alert {
    background-color: rgba(var(--theme-rgb-info), 0.2);
    border-color: rgba(var(--theme-rgb-info), 0.6);
    color: var(--theme-text-color, #ffffff);
}

.mod-skin-dark:not(.mod-skin-light) .ds-form-card .badge-light,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-card .badge-light,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTasksCard .badge-light {
    background: var(--theme-bg-subtle, #303136) !important;
    border: 1px solid var(--theme-border-color, rgba(255, 255, 255, 0.15));
    color: var(--theme-text-color, #a5abb1) !important;
}

.mod-skin-dark:not(.mod-skin-light) .ds-card-header i {
    color: var(--theme-text-color, #e2e8f0);
}

.mod-skin-dark:not(.mod-skin-light) .js-save-work-order-settings.btn-warning,
.mod-skin-dark:not(.mod-skin-light) .js-save-work-order-settings.btn-warning:hover,
.mod-skin-dark:not(.mod-skin-light) .js-save-work-order-settings.btn-warning:focus {
    color: var(--theme-dark, #212529) !important;
}

.mod-skin-dark:not(.mod-skin-light) .js-save-work-order-settings.btn-warning i {
    color: var(--theme-dark, #212529) !important;
}

.mod-skin-dark:not(.mod-skin-light) .ds-form-card .btn-outline-light,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-card .btn-outline-light,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTasksCard .btn-outline-light {
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
    color: var(--theme-text-color, #a5abb1);
    background: transparent;
}

.mod-skin-dark:not(.mod-skin-light) .ds-form-card .btn-outline-light:hover,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-card .btn-outline-light:hover,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTasksCard .btn-outline-light:hover {
    background: rgba(var(--theme-rgb-primary), 0.15);
    border-color: var(--theme-primary-500, #886ab5);
    color: var(--theme-primary-500, #886ab5);
}

.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor .btn-light,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer .btn-light {
    background: var(--theme-bg-card, #26272b);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
    color: var(--theme-text-color, #a5abb1);
}

.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor .btn-light:hover,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer .btn-light:hover {
    background: var(--theme-bg-subtle, #303136);
    border-color: var(--theme-primary-500, #886ab5);
    color: var(--theme-text-color, #e2e8f0);
}

.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor-row>td,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer {
    background: var(--theme-bg-subtle, #303136) !important;
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15)) !important;
    color: var(--theme-text-color, #a5abb1);
}

.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor .form-control,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor .custom-select,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer .form-control,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer .custom-select,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor .form-control:focus,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer .form-control:focus {
    background: var(--theme-bg-card, #26272b);
    color: var(--theme-text-color, #a5abb1);
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
}

.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor .custom-control-label,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer .custom-control-label,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-card .custom-control-label,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-editor label,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTaskFormContainer label {
    color: var(--theme-text-color, #a5abb1);
}

.mod-skin-dark:not(.mod-skin-light) .js-task-template-card .table thead th,
.mod-skin-dark:not(.mod-skin-light) .js-task-template-card .table td,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTasksCard .table thead th,
.mod-skin-dark:not(.mod-skin-light) #WorkOrderTasksCard .table td {
    border-color: var(--theme-border-color, rgba(255, 255, 255, 0.15));
    color: var(--theme-text-color, #a5abb1);
}

/* === LIGHT MODE SPECIFIC === */
.mod-skin-light:not(.mod-skin-dark) .ds-form-card {
    background: #ffffff;
    color: #333333;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.mod-skin-light:not(.mod-skin-dark) .ds-filter-section {
    background: #f8f9fc;
    border-color: #e9ecef;
}

.mod-skin-light:not(.mod-skin-dark) .ds-filter-btn {
    background: #ffffff;
    color: #6c757d;
    border-color: #dee2e6;
}

.mod-skin-light:not(.mod-skin-dark) .ds-table-wrapper {
    background: #ffffff;
    border-color: #e9ecef;
}

.mod-skin-light:not(.mod-skin-dark) .ds-table .badge.timing-badge {
    background: #e3f2fd;
    color: #1976d2;
    border-color: rgba(25, 118, 210, 0.25);
}

.mod-skin-light:not(.mod-skin-dark) .ds-table code {
    background-color: #f8f9fa;
    color: #e83e8c;
    border-color: #e9ecef;
}

.mod-skin-light:not(.mod-skin-dark) .ds-modal-content code {
    background-color: #f8f9fa;
    color: #e83e8c;
    border-color: #e9ecef;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .ds-filter-section {
        padding: 1rem;
    }

    .ds-action-buttons {
        justify-content: center;
        margin-top: 1rem;
    }

    .ds-filter-group {
        justify-content: center;
    }

    .ds-filter-btn {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

    .ds-card-header {
        padding: 0.75rem 1rem;
    }

    .ds-card-body {
        padding: 1rem;
    }

    .ds-table .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    .ds-table .performance-metric,
    .ds-table .usage-metric {
        min-width: 50px;
    }
}