/* Filament Select/Native Select Dark Mode Fixes */

/* Fix for native select elements in dark mode */
.dark select,
.dark .fi-select,
.dark select.fi-input,
.dark input[type="text"].fi-input,
.dark input[type="email"].fi-input,
.dark input[type="password"].fi-input,
.dark input[type="number"].fi-input,
.dark input[type="tel"].fi-input,
.dark input[type="url"].fi-input,
.dark textarea.fi-input {
    background-color: rgb(31 41 55) !important; /* gray-800 */
    color: rgb(243 244 246) !important; /* gray-100 */
    border-color: rgb(55 65 81) !important; /* gray-700 */
}

/* Hover state */
.dark select:hover,
.dark .fi-select:hover,
.dark select.fi-input:hover,
.dark input.fi-input:hover,
.dark textarea.fi-input:hover {
    border-color: rgb(75 85 99) !important; /* gray-600 */
    background-color: rgb(55 65 81) !important;
}

/* Focus state */
.dark select:focus,
.dark .fi-select:focus,
.dark select.fi-input:focus,
.dark input.fi-input:focus,
.dark textarea.fi-input:focus {
    border-color: rgb(249 115 22) !important; /* orange-500 - your primary color */
    background-color: rgb(31 41 55) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgb(124 45 18 / 0.5) !important;
}

/* Disabled state */
.dark select:disabled,
.dark .fi-select:disabled,
.dark select.fi-input:disabled,
.dark input.fi-input:disabled,
.dark textarea.fi-input:disabled {
    background-color: rgb(17 24 39) !important; /* gray-900 */
    color: rgb(107 114 128) !important; /* gray-500 */
    border-color: rgb(55 65 81) !important;
    opacity: 0.6 !important;
}

/* Select dropdown arrow styling for dark mode */
.dark select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='rgb(156, 163, 175)' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
}

/* Fix for Filament input wrapper in dark mode */
.dark .fi-input-wrp {
    background-color: rgb(31 41 55) !important;
    border-color: rgb(55 65 81) !important;
}

.dark .fi-input-wrp:focus-within {
    border-color: rgb(249 115 22) !important;
    box-shadow: 0 0 0 3px rgb(124 45 18 / 0.5) !important;
}

/* Fix for placeholder text in dark mode */
.dark input::placeholder,
.dark textarea::placeholder,
.dark select::placeholder {
    color: rgb(107 114 128) !important; /* gray-500 */
}

/* Fix for option elements in dark mode (for native selects) */
.dark select option {
    background-color: rgb(31 41 55) !important;
    color: rgb(243 244 246) !important;
}

/* Fix for Filament choices.js select (if used) */
.dark .choices__inner {
    background-color: rgb(31 41 55) !important;
    color: rgb(243 244 246) !important;
    border-color: rgb(55 65 81) !important;
}

.dark .choices__list--dropdown {
    background-color: rgb(31 41 55) !important;
    border-color: rgb(55 65 81) !important;
}

.dark .choices__item--selectable {
    color: rgb(243 244 246) !important;
}

.dark .choices__item--selectable.is-highlighted {
    background-color: rgb(249 115 22) !important;
    color: white !important;
}

/* Fix for Tom Select (alternative select library) */
.dark .ts-dropdown,
.dark .ts-control {
    background-color: rgb(31 41 55) !important;
    color: rgb(243 244 246) !important;
    border-color: rgb(55 65 81) !important;
}

.dark .ts-dropdown .option {
    color: rgb(243 244 246) !important;
    background-color: rgb(31 41 55) !important;
}

.dark .ts-dropdown .option.active {
    background-color: rgb(249 115 22) !important;
    color: white !important;
}

/* Fix for Filament Select Component */
.dark [x-data*="selectFormComponent"],
.dark .fi-fo-select {
    background-color: rgb(31 41 55) !important;
}

.dark .fi-fo-select .fi-input {
    background-color: rgb(31 41 55) !important;
    color: rgb(243 244 246) !important;
    border-color: rgb(55 65 81) !important;
}

/* Fix for searchable select dropdown */
.dark [x-data*="selectFormComponent"] [role="listbox"],
.dark .fi-fo-select [role="listbox"] {
    background-color: rgb(17 24 39) !important; /* gray-900 - darker for dropdown */
    border-color: rgb(55 65 81) !important;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3) !important;
}

.dark [x-data*="selectFormComponent"] [role="option"],
.dark .fi-fo-select [role="option"] {
    color: rgb(209 213 219) !important; /* gray-300 */
}

.dark [x-data*="selectFormComponent"] [role="option"][aria-selected="true"],
.dark .fi-fo-select [role="option"][aria-selected="true"] {
    background-color: rgb(55 65 81) !important;
    color: rgb(243 244 246) !important;
}

.dark [x-data*="selectFormComponent"] [role="option"]:hover,
.dark .fi-fo-select [role="option"]:hover {
    background-color: rgb(31 41 55) !important;
}

/* Fix for multiselect tags */
.dark .fi-fo-select .fi-badge {
    background-color: rgb(55 65 81) !important;
    color: rgb(243 244 246) !important;
}

/* Task View Tables - Actions column width and alignment */
.survey-actions-vertical .fi-ta th:last-child {
    width: 220px !important;
    min-width: 220px !important;
    text-align: left !important;
}

/* Override Filament's fi-align-end on actions header */
.survey-actions-vertical .fi-ta th.fi-ta-header-cell.fi-align-end:last-child {
    text-align: left !important;
}

.survey-actions-vertical .fi-ta td:last-child {
    width: 220px !important;
    min-width: 220px !important;
}
