/* Custom Dropdown Styles */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary, #333);
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 40px;
    /* Consistent height */
}

/* Specific Style for Header Language Selector (Glassmorphism + Rounded) */
/* Using !important to ensure it overrides any conflicting framework/legacy styles */
#languageSelectWrapper .custom-select-trigger {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    color: white !important;
    border-radius: 20px !important;
    backdrop-filter: blur(4px) !important;
    justify-content: flex-start !important;
    height: 40px !important;
    /* Enforce height match */
    padding: 0 16px !important;
    /* Match button padding roughly */
}

#languageSelectWrapper .custom-select-trigger:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#languageSelectWrapper .custom-select-trigger span {
    margin-right: auto !important;
    /* Push arrow to far right */
    margin-left: 4px;
    /* Slight buffer */
    text-align: left !important;
    flex-grow: 1;
    /* Ensure it takes up space */
}

/* Tighter spacing for options in Language Selector */
#languageSelectWrapper .custom-option {
    padding: 6px 16px !important;
    font-size: 0.95em;
}

#languageSelectWrapper .custom-options {
    margin-top: 6px !important;
}

/* Force white arrow for generic dropdowns in header */
#languageSelectWrapper .arrow::before,
#languageSelectWrapper .arrow::after {
    background-color: white !important;
}

.custom-select-trigger:hover {
    border-color: var(--accent-color, #4a90e2);
}

.custom-select-trigger span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 12px;
}

.arrow {
    position: relative;
    height: 10px;
    width: 10px;
}

.arrow::before,
.arrow::after {
    content: "";
    position: absolute;
    bottom: 0px;
    width: 0.15rem;
    height: 100%;
    transition: all 0.2s;
    background-color: var(--text-secondary, #666);
}

.arrow::before {
    left: -3px;
    transform: rotate(45deg);
}

.arrow::after {
    left: 3px;
    transform: rotate(-45deg);
}

.open .arrow::before {
    left: -3px;
    transform: rotate(-45deg);
}

.open .arrow::after {
    left: 3px;
    transform: rotate(45deg);
}

.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: var(--bg-card, #fff);
    transition: all 0.2s ease-in-out;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 6px;
    text-align: left !important;
    /* Force left alignment for options container */
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
}

.custom-option {
    position: relative;
    display: block;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-primary, #333);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 2px solid transparent;
    text-align: left !important;
    /* Ensure options are left aligned */
}

.custom-option:first-child {
    border-radius: 8px 8px 0 0;
}

.custom-option:last-child {
    border-radius: 0 0 8px 8px;
}

.custom-option:hover {
    background-color: var(--bg-hover, #f5f5f5);
    color: var(--accent-color, #4a90e2);
    padding-left: 16px;
}

.custom-option.selected {
    background-color: var(--bg-selected, #eef4ff);
    color: var(--accent-color, #4a90e2);
    font-weight: 600;
    border-left-color: var(--accent-color, #4a90e2);
}

/* Scrollbar styling for options */
.custom-options::-webkit-scrollbar {
    width: 6px;
}

.custom-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-options::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #ccc);
    border-radius: 3px;
}

.custom-options::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover, #bbb);
}

/* Disabled State */
.custom-select-wrapper.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.custom-select-wrapper.disabled .custom-select-trigger {
    background-color: var(--bg-disabled, #f0f0f0);
    cursor: not-allowed;
    color: var(--text-disabled, #999);
}

.custom-select-trigger:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Reduced font size for all language selectors as requested */
#languageSelectWrapper .custom-select-trigger,
#languageSelectWrapperHeader .custom-select-trigger,
#languageSelectWrapperBottom .custom-select-trigger,
#languageSelectWrapper .custom-option,
#languageSelectWrapperHeader .custom-option,
#languageSelectWrapperBottom .custom-option {
    font-size: 0.85rem !important;
}

/* Reduced Spacing for Mobile Dropdowns (Landing, Daily, Study) */
@media (max-width: 768px) {
    .custom-option {
        padding: 8px 12px;
        /* Reduced from 10px */
        font-size: 0.9em;
        /* Slightly smaller base for tighter feel */
    }
}