/* Unified Dropdown Styles - RTL/LTR Compatible */
.unified-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
}

.unified-dropdown-button {
    width: 100%;
    text-align: left;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transform: none !important; /* Override .btn transform */
}

/* Ensure btn styling is preserved */
.unified-dropdown-button.btn {
    padding-right: 48px !important;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    font-weight: 700;
    font-family: inherit;
    box-shadow: var(--shadow);
    transition: transform .1s ease, background .2s ease, border-color .2s ease;
}

.unified-dropdown-button:hover {
    transform: none !important; /* Override .btn hover transform */
}

.unified-dropdown-button.btn:hover {
    background: var(--card);
    border-color: var(--accent);
}

.unified-dropdown-button::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23666' d='M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transition: transform 0.2s ease;
    pointer-events: none;
}

/* Better arrow color for light theme */
[data-theme="light"] .unified-dropdown-button::after {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23555' d='M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z'/%3E%3C/svg%3E");
}

.unified-dropdown.open .unified-dropdown-button::after {
    transform: translateY(-50%) rotate(180deg);
}

.unified-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* WebKit (Chrome, Edge, Safari) */
.unified-dropdown-list::-webkit-scrollbar {
    width: 8px;
}

.unified-dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.unified-dropdown-list::-webkit-scrollbar-thumb {
    background: #e84e19;
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.unified-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #e84e19;
}

/* Dark theme */
[data-theme="dark"] .unified-dropdown-list::-webkit-scrollbar-thumb {
    background: #e84e19;
}
[data-theme="dark"] .unified-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #e84e19;
}

.unified-dropdown-item {
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    position: relative;
}

.unified-dropdown-item:last-child {
    border-bottom: none;
}

.unified-dropdown-item:hover {
    background: var(--card);
    color: var(--accent);
}

.unified-dropdown-item.selected {
    background: var(--accent);
    color: white;
    font-weight: 500;
}

.unified-dropdown-item.selected::after {
    content: '✓';
    position: absolute;
    right: 18px;
    font-weight: bold;
}

/* RTL Support */
body.rtl .unified-dropdown-button {
    text-align: right;
}

body.rtl .unified-dropdown-button.btn {
    padding-right: 18px !important;
    padding-left: 48px !important;
}

body.rtl .unified-dropdown-button::after {
    right: auto;
    left: 16px;
}

body.rtl .unified-dropdown-item.selected::after {
    right: auto;
    left: 18px;
}

body.rtl .unified-dropdown-list {
    text-align: right;
}

/* Dark theme adjustments */
[data-theme="dark"] .unified-dropdown-button::after {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23ccc' d='M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z'/%3E%3C/svg%3E");
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .unified-dropdown-list {
        font-size: 16px; /* Prevent zoom on iOS */
        height: 150px;
    }
    
    .unified-dropdown-item {
        padding: 14px 18px;
        min-height: 48px;
    }
    
    .unified-dropdown-button {
        min-height: 48px;
    }
}

/* Animation for dropdown appearance */
.unified-dropdown-list {
    opacity: 0;
    transform: translateY(-10px);
    animation: dropdownShow 0.2s ease forwards;
}

@keyframes dropdownShow {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus states for accessibility */
.unified-dropdown-button:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.unified-dropdown-item:focus {
    background: var(--card);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
