/* Custom Selects - Premium Glassmorphism styling */

/* Hide original selects visually but keep them accessible for screen readers and JS forms */
.custom-select-hidden {
    display: none !important;
}

/* Custom dropdown wrapper */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
    vertical-align: middle;
}

/* Default trigger style for generic selects without custom classes */
.custom-select-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    min-height: 36px;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #0f172a;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    box-sizing: border-box;
    outline: none;
    transition: all 0.15s ease;
    text-align: left;
    user-select: none;
    gap: 8px;
    background-image: none !important; /* Prevent background-image arrows from classes/styles */
}

.custom-select-trigger:hover:not(.custom-select-disabled) {
    border-color: #94a3b8;
    background: #f8fafc;
}

.custom-select-trigger:focus-visible {
    border-color: var(--custom-select-accent, #3b82f6);
    box-shadow: 0 0 0 3px var(--custom-select-accent-focus, rgba(59, 130, 246, 0.15));
}

/* Disabled state */
.custom-select-wrapper.custom-select-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.custom-select-wrapper.custom-select-disabled .custom-select-trigger {
    pointer-events: none;
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
}

/* Label text inside trigger */
.custom-select-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chevron arrow indicator */
.custom-select-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: inherit;
    opacity: 0.8;
    flex-shrink: 0;
}

.custom-select-wrapper.custom-select-open .custom-select-arrow {
    transform: rotate(180deg);
}

/* Dropdown list container (Glassmorphic) */
.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    min-width: 160px;
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    z-index: 10000;
    overflow: hidden;
    display: none !important;
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

/* Active state allows display: block for animation prep */
.custom-select-wrapper.custom-select-active .custom-select-dropdown {
    display: block !important;
}

/* Dropdown list open state */
.custom-select-wrapper.custom-select-open .custom-select-dropdown {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

/* Open upwards if flagged */
.custom-select-wrapper.custom-select-open-upwards .custom-select-dropdown {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 6px;
    transform: translateY(8px) scale(0.98);
}
.custom-select-wrapper.custom-select-open.custom-select-open-upwards .custom-select-dropdown {
    transform: translateY(0) scale(1);
}

/* Options list scroll area */
.custom-select-options {
    list-style: none;
    padding: 4px;
    margin: 0;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 23, 42, 0.2) transparent;
}

.custom-select-options::-webkit-scrollbar {
    width: 6px;
}
.custom-select-options::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.15);
    border-radius: 99px;
}

/* Individual options */
.custom-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    user-select: none;
    gap: 8px;
    box-sizing: border-box;
}

.custom-select-option:hover {
    background: var(--custom-select-accent-light, rgba(28, 119, 255, 0.08));
    color: var(--custom-select-accent, #1c77ff);
}

.custom-select-option.custom-select-option-selected {
    background: var(--custom-select-accent, #1c77ff);
    color: #ffffff;
    font-weight: 600;
}

.custom-select-option.custom-select-option-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Optgroup styling */
.custom-select-group-label {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.05em;
    user-select: none;
}

/* Selected option checkmark icon */
.custom-select-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: currentColor;
    flex-shrink: 0;
}


/* ==================== PREVENT DOUBLE BORDERS / PADDING ON WRAPPER ==================== */
.custom-select-wrapper.form-select,
.custom-select-wrapper.tselect,
.custom-select-wrapper.jsf-select,
.custom-select-wrapper.schedule-pill,
.custom-select-wrapper.schedule-period-select,
.custom-select-wrapper.teachers-perpage {
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}


/* ==================== ENVIRONMENT-SPECIFIC THEMES ==================== */

/* --- 1. LIGHT THEME (Selects on white/light backgrounds, e.g., Settings, Modals) --- */
.custom-select-wrapper:not(.custom-select-dark) .custom-select-trigger {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    height: 40px !important; /* default height for form controls */
    min-height: 40px !important;
    padding: 8px 14px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-trigger:hover:not(.custom-select-disabled) {
    border-color: #94a3b8 !important;
    background: #f8fafc !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-trigger:focus-visible {
    border-color: var(--custom-select-accent, #1c77ff) !important;
    box-shadow: 0 0 0 3px var(--custom-select-accent-focus, rgba(28, 119, 255, 0.15)) !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-arrow {
    color: #64748b !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-dropdown {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03) !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-option {
    color: #334155 !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-option:hover {
    background: var(--custom-select-accent-light, rgba(28, 119, 255, 0.08)) !important;
    color: var(--custom-select-accent, #1c77ff) !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-option.custom-select-option-selected {
    background: var(--custom-select-accent, #1c77ff) !important;
    color: #ffffff !important;
}

.custom-select-wrapper:not(.custom-select-dark) .custom-select-options::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.15);
}


/* --- 2. DARK THEME (Selects on blue/dark backgrounds, e.g., toolbars, headers) --- */
.custom-select-wrapper.custom-select-dark .custom-select-trigger {
    background: var(--primary-blue, #0f68f8) !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    border-radius: 999px !important; /* Pill style by default on blue header bars */
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 16px !important;
    box-shadow: 0 2px 6px rgba(15, 104, 248, 0.15) !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-trigger:hover:not(.custom-select-disabled) {
    background: rgba(255, 255, 255, 0.16) !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-arrow {
    color: #ffffff !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-dropdown {
    background: var(--primary-blue, #0f68f8) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25) !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-option {
    color: rgba(255, 255, 255, 0.9) !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-option:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-option.custom-select-option-selected {
    background: rgba(255, 255, 255, 0.3) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
}

.custom-select-wrapper.custom-select-dark .custom-select-options::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.25);
}


/* ==================== ENVIRONMENT OVERRIDES (MODALS & LAYOUTS) ==================== */

/* Modals: auto-stretch selects to 100% width and set exact modal heights */
.custom-select-wrapper.in-modal {
    display: block !important;
    width: 100% !important;
}

.custom-select-wrapper.in-modal .custom-select-trigger {
    height: 48px !important; /* form controls in modals are taller */
    min-height: 48px !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
    width: 100% !important;
}

.custom-select-wrapper.in-modal .custom-select-dropdown {
    width: 100% !important;
}

/* Specific layout overrides based on parent classes */
.custom-select-wrapper.tselect .custom-select-trigger {
    border-radius: 9px !important;
    height: 32px !important;
    min-height: 32px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    padding: 0 12px !important;
}

.custom-select-wrapper.jsf-select .custom-select-trigger {
    border-radius: 12px !important;
    height: 40px !important;
    min-height: 40px !important;
    font-weight: 800 !important;
    padding: 0 14px !important;
}

.custom-select-wrapper.form-select:not(.in-modal) .custom-select-trigger {
    border-radius: 12px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 14px !important;
    font-weight: 600 !important;
}

.custom-select-wrapper.schedule-period-select .custom-select-trigger {
    height: 34px !important;
    min-height: 34px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    padding: 0 14px !important;
}
