/**
 * Custom Dropdown Styles
 * 
 * Styles for the custom dropdown component that replaces native select elements
 * with full control over appearance in both light and dark modes
 */

/* ==================== CONTAINER ==================== */

.custom-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.custom-dropdown.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ==================== BUTTON ==================== */

.custom-dropdown-button {
    width: 100%;
    padding: 10px 40px 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary, #f1f5f9);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 150ms ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    outline: none;
}

.custom-dropdown-button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.custom-dropdown-button:focus {
    border-color: var(--accent, #2563EB);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.custom-dropdown.open .custom-dropdown-button {
    border-color: var(--accent, #2563EB);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Button text */
.custom-dropdown-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* Dropdown arrow icon */
.custom-dropdown-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 200ms ease;
    pointer-events: none;
    width: 20px;
    height: 20px;
    color: var(--text-secondary, #cbd5e1);
}

.custom-dropdown-icon svg {
    width: 20px;
    height: 20px;
}

.custom-dropdown.open .custom-dropdown-icon {
    transform: translateY(-50%) rotate(180deg);
}

/* ==================== OPTIONS CONTAINER ==================== */

.custom-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(30, 41, 59, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 200ms ease, transform 200ms ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    max-height: 0;
    overflow: hidden;
}

.custom-dropdown-options.show {
    opacity: 1;
    transform: translateY(0);
    max-height: 300px;
}

/* ==================== OPTIONS LIST ==================== */

.custom-dropdown-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px;
}

/* Scrollbar styling */
.custom-dropdown-list::-webkit-scrollbar {
    width: 8px;
}

.custom-dropdown-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.custom-dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.custom-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== OPTION ITEMS ==================== */

.custom-dropdown-option {
    padding: 10px 12px;
    color: var(--text-secondary, #cbd5e1);
    font-size: 14px;
    cursor: pointer;
    transition: all 150ms ease;
    border-radius: 4px;
    margin: 2px 0;
    position: relative;
}

.custom-dropdown-option:hover,
.custom-dropdown-option.focused {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #f1f5f9);
}

.custom-dropdown-option.selected {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent, #2563EB);
    font-weight: 600;
}

.custom-dropdown-option.selected::before {
    content: '✓';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--accent, #2563EB);
}

/* ==================== LIGHT MODE ==================== */

/* Light mode button */
body.light-mode .custom-dropdown-button {
    background: #ffffff;
    border: 2px solid #d1d5db;
    color: #111827;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.light-mode .custom-dropdown-button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

body.light-mode .custom-dropdown-button:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Light mode dropdown icon */
body.light-mode .custom-dropdown-icon {
    color: #6b7280;
}

/* Light mode options container */
body.light-mode .custom-dropdown-options {
    background: rgba(255, 255, 255, 0.98);
    border-color: #d1d5db;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Light mode scrollbar */
body.light-mode .custom-dropdown-list::-webkit-scrollbar-track {
    background: #f3f4f6;
}

body.light-mode .custom-dropdown-list::-webkit-scrollbar-thumb {
    background: #9ca3af;
}

body.light-mode .custom-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Light mode options */
body.light-mode .custom-dropdown-option {
    color: #6b7280;
}

body.light-mode .custom-dropdown-option:hover,
body.light-mode .custom-dropdown-option.focused {
    background: #f3f4f6;
    color: #111827;
}

body.light-mode .custom-dropdown-option.selected {
    background: #dbeafe;
    color: #2563EB;
}

/* ==================== DISABLED STATE ==================== */

.custom-dropdown-button:disabled,
.custom-dropdown.disabled .custom-dropdown-button {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==================== ANIMATIONS ==================== */

@keyframes dropdownSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dropdownSlideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ==================== MOBILE RESPONSIVE ==================== */

@media (max-width: 640px) {
    .custom-dropdown-button {
        padding: 12px 40px 12px 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .custom-dropdown-option {
        padding: 12px 14px;
        font-size: 16px;
    }
    
    .custom-dropdown-list {
        max-height: 240px;
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Focus visible for keyboard navigation */
.custom-dropdown-button:focus-visible {
    outline: 2px solid var(--accent, #2563EB);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .custom-dropdown-button {
        border-width: 2px;
    }
    
    .custom-dropdown-option.selected {
        outline: 2px solid var(--accent, #2563EB);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .custom-dropdown-button,
    .custom-dropdown-icon,
    .custom-dropdown-options,
    .custom-dropdown-option {
        transition: none;
        animation: none;
    }
}