/* Hide number input spinners */
.no-spinners::-webkit-outer-spin-button,
.no-spinners::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.no-spinners {
    -moz-appearance: textfield;
}

/* Required field indicator */
label.required::after {
    content: " *";
    color: var(--tw-danger, #f1416c);
}

/* Validation styling for submitted forms */
form.was-validated input:invalid,
form.was-validated select:invalid,
form.was-validated textarea:invalid {
    border-color: var(--tw-danger, #f1416c) !important;
}

form.was-validated input:valid,
form.was-validated select:valid,
form.was-validated textarea:valid {
    border-color: var(--tw-success, #50cd89) !important;
}

/* Validation styling for Select2 selects */
form.was-validated select:invalid + .select2-container .select2-selection {
    border-color: var(--tw-danger, #f1416c) !important;
}

form.was-validated select:valid + .select2-container .select2-selection {
    border-color: var(--tw-success, #50cd89) !important;
}

/* ── Select2 KTUI overrides ── */

.select2-container--default .select2-selection--single {
    height: calc(var(--spacing) * 8.5);
    padding-inline: calc(var(--spacing) * 3);
    font-size: 0.8125rem;
    border: 1px solid var(--tw-border, #e5e7eb);
    border-radius: calc(var(--radius) - 2px);
    background-color: var(--tw-card-background, #fff);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(var(--spacing) * 8.5 - 2px);
    padding-left: 0;
    color: var(--tw-foreground, #111827);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(var(--spacing) * 8.5 - 2px);
    right: 8px;
}

.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--tw-primary, #3b82f6);
}

.select2-dropdown {
    border-color: var(--tw-border, #e5e7eb);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.select2-container--default .select2-results__option {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--tw-foreground, #111827);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--tw-primary, #3b82f6);
    color: #fff;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--tw-coal-100, #f3f4f6);
    color: var(--tw-foreground, #111827);
}

.select2-results__options {
    max-height: 250px;
    overflow-y: auto;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    border: 1px solid var(--tw-border, #e5e7eb);
    border-radius: 0.375rem;
}

/* Select2 multiple */
.select2-container--default .select2-selection--multiple {
    min-height: 40px;
    padding: 0.25rem 0.375rem;
    font-size: 0.875rem;
    border: 1px solid var(--tw-border, #e5e7eb);
    border-radius: 0.375rem;
    background-color: var(--tw-card-background, #fff);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: var(--tw-primary, #3b82f6);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem 0.125rem 0.625rem;
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--tw-primary, #3b82f6);
    background-color: var(--tw-primary-light, #eff6ff);
    border: 1px solid var(--tw-primary, #3b82f6);
    border-radius: 9999px;
    position: relative;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    position: relative;
    margin-left: 0.375rem;
    margin-right: 0;
    padding: 0 0.125rem;
    order: 1;
    color: var(--tw-primary, #3b82f6);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    background: none;
    line-height: 1;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--tw-danger, #f1416c);
    background: none;
}

.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    margin-top: 0;
    font-size: 0.875rem;
    color: var(--tw-foreground, #111827);
}

.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field::placeholder {
    color: var(--tw-muted-foreground, #9ca3af);
}

/* Select2 small variant for inline filters */
.kt-select-sm + .select2-container .select2-selection--single {
    height: 32px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    min-width: 160px;
}

.kt-select-sm + .select2-container .select2-selection--single .select2-selection__arrow {
    height: 30px;
}

/* ── DataTables KTUI overrides ── */

/* Length menu */
.dataTables_length {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--tw-secondary-foreground, #6b7280);
}

.dataTables_length select {
    padding: 0.35rem 1.75rem 0.35rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--tw-border, #e5e7eb);
    border-radius: 0.375rem;
    background-color: var(--tw-card-background, #fff);
    outline: none;
    appearance: auto;
}

/* Search input */
.dataTables_filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--tw-secondary-foreground, #6b7280);
}

.dataTables_filter input {
    padding: 0.35rem 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid var(--tw-border, #e5e7eb);
    border-radius: 0.375rem;
    background-color: var(--tw-card-background, #fff);
    outline: none;
}

.dataTables_filter input:focus {
    border-color: var(--tw-primary, #3b82f6);
}

/* Info text */
.dataTables_info {
    font-size: 0.8125rem;
    color: var(--tw-secondary-foreground, #6b7280);
}

/* Pagination */
.dataTables_paginate {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dataTables_paginate .paginate_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--tw-secondary-foreground, #6b7280);
    background: none;
    transition: all 0.15s;
}

.dataTables_paginate .paginate_button:hover:not(.disabled):not(.current) {
    background-color: var(--tw-coal-100, #f3f4f6);
    color: var(--tw-foreground, #111827);
}

.dataTables_paginate .paginate_button.current {
    background-color: var(--tw-primary, #3b82f6);
    color: #fff;
    border-color: var(--tw-primary, #3b82f6);
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: default;
}

/* Processing indicator */
.dataTables_processing {
    padding: 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--tw-secondary-foreground, #6b7280);
}


/* Sort indicators */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    position: relative;
    cursor: pointer;
    padding-right: 1.5rem !important;
    transition: background-color 0.15s;
}

table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--tw-secondary-foreground, #6b7280);
}

table.dataTable thead th.sorting::after {
    content: "\2195"; /* ↕ up-down arrow */
    opacity: 0.4;
}

table.dataTable thead th.sorting_asc::after {
    content: "\2191"; /* ↑ up arrow */
    opacity: 1;
    color: var(--tw-primary, #3b82f6);
}

table.dataTable thead th.sorting_desc::after {
    content: "\2193"; /* ↓ down arrow */
    opacity: 1;
    color: var(--tw-primary, #3b82f6);
}

table.dataTable thead th.sorting:hover,
table.dataTable thead th.sorting_asc:hover,
table.dataTable thead th.sorting_desc:hover {
    background-color: var(--tw-coal-100, #f3f4f6);
}

.dark table.dataTable thead th.sorting:hover,
.dark table.dataTable thead th.sorting_asc:hover,
.dark table.dataTable thead th.sorting_desc:hover {
    background-color: var(--tw-coal-800, rgba(255, 255, 255, 0.05));
}

/* Remove default DataTables border/stripe styles */
table.dataTable {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

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

table.dataTable.no-footer {
    border-bottom: none !important;
}

/* Empty table row */
.dataTables_empty {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.875rem;
    color: var(--tw-secondary-foreground, #6b7280);
}
