/* Theme-specific component styles for modals and dropdowns */

/* Modal style fixes for dark mode */

/* Fix modal dialog styles */
.modal-content {
    border-radius: 0.5rem;
    overflow: hidden;
}

/* Ensure modals properly handle dark mode transitions */
.modal-dialog,
.modal-content,
.modal-header,
.modal-body,
.modal-footer {
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

/* Ensure modals are always on top */
.modal-backdrop {
    z-index: 1040;
}

.modal {
    z-index: 1050;
}

/* Dark mode specifics */
[data-bs-theme="dark"] .modal-content {
    background-color: #2b3035;
    color: #f8f9fa;
    border-color: #495057;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: #495057;
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Handle modal animations consistently across browsers */
.modal.fade .modal-dialog {
    transform: translate(0, -50px);
    transition: transform 0.25s ease-out;
}

.modal.show .modal-dialog {
    transform: translate(0, 0);
}

/* Fix Safari specific issues */
@media not all and (min-resolution: 0.001dpcm) { 
    @supports (-webkit-appearance:none) {
        .modal-backdrop.show {
            opacity: 0.5;
        }
    }
}

/* Dropdown styles for dark mode */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .dropdown-item.active,
[data-bs-theme="dark"] .dropdown-item:active {
    background-color: var(--bs-primary);
    color: #fff;
}

/* Form select styles for dark mode */
[data-bs-theme="dark"] .form-select {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23adb5bd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

[data-bs-theme="dark"] .form-select option {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Fix for native select dropdowns which show the OS UI */
[data-bs-theme="dark"] select {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

/* Ensure dropdowns transition properly with theme changes */
.dropdown-menu,
.form-select,
select {
    transition: background-color var(--theme-transition-time) ease,
                color var(--theme-transition-time) ease,
                border-color var(--theme-transition-time) ease;
}

/* Fix for Bootstrap's dropdown menu transition */
.dropdown-menu.show {
    animation: fadeInDropdown 0.2s ease-in-out;
}

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
