/* =========================================================================
 * Ritz custom <select> dropdown styles
 * The wrapper takes the full width of whatever the native <select> would
 * have taken, and the panel is absolutely positioned at width:100% of the
 * wrapper so it ALWAYS matches the trigger box width exactly.
 * ========================================================================= */

.ritz-cs-wrapper {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Native select is hidden but kept in DOM for form submission */
select.ritz-cs-native {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* Keep tabindex working for the visible trigger only */
    tab-index: -1;
}

/* Trigger box - mimics .form-control / .form-select look */
.ritz-cs-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    background: #FFFFFF;
    color: #2D3748;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.ritz-cs-trigger:hover {
    border-color: #CBD5E0;
}

.ritz-cs-trigger:focus,
.ritz-cs-wrapper.ritz-cs-open .ritz-cs-trigger {
    outline: none;
    border-color: var(--ritz-maroon, #1a1f3a);
    box-shadow: 0 0 0 3px rgba(26, 31, 58, 0.10);
}

.ritz-cs-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ritz-cs-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #4A5568;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.ritz-cs-wrapper.ritz-cs-open .ritz-cs-arrow {
    transform: rotate(180deg);
}

/* Panel - positioned with position:fixed via JS so no ancestor overflow
   can clip it. Width is set inline from the trigger's bounding rect to
   always exactly match the trigger box width. */
.ritz-cs-panel {
    position: fixed;
    box-sizing: border-box;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 99999;
    padding: 4px 0;
    animation: ritzCsFadeIn 0.14s ease;
}

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

.ritz-cs-option {
    padding: 10px 14px;
    font-size: 14px;
    color: #2D3748;
    cursor: pointer;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.12s ease, color 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.ritz-cs-option:hover,
.ritz-cs-option:focus {
    background: #F7FAFC;
}

.ritz-cs-option.ritz-cs-selected {
    background: var(--ritz-maroon, #1a1f3a);
    color: #FFFFFF;
    font-weight: 500;
}

.ritz-cs-option.ritz-cs-selected:hover {
    background: var(--ritz-maroon-dark, #2d3561);
}

.ritz-cs-option.ritz-cs-disabled {
    color: #A0AEC0;
    cursor: not-allowed;
    background: transparent;
}

/* Inline-grid contexts (e.g. .form-row) - keep the wrapper sized to the cell */
.form-row > .form-group > .ritz-cs-wrapper,
.form-group > .ritz-cs-wrapper {
    width: 100%;
}

/* Make sure parent groups don't clip the dropdown panel */
.form-group,
.form-row,
.form-section {
    overflow: visible;
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .ritz-cs-trigger {
        font-size: 14px;
        min-height: 42px;
        padding: 9px 12px;
    }
    .ritz-cs-option {
        padding: 11px 12px;
        font-size: 14px;
    }
    .ritz-cs-panel {
        max-height: 60vh;
    }
}
