/* ==========================================================================
   CUSTOM REUSABLE SELECT SYSTEM — CAREER EDUCATION SERVICES
   Unified Desktop Dropdown + Mobile Bottom-Sheet Selection Component
   ========================================================================== */

/* 1. Component Wrapper */
.cselect-wrapper {
    position: relative;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 2. Custom Trigger Button */
.cselect-trigger {
    width: 100%;
    min-height: 48px;
    padding: 0.65rem 1rem;
    background: #FFFFFF;
    border: 1.5px solid #CBD5E1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    text-align: left;
    outline: none;
}

.cselect-trigger:hover {
    border-color: #94A3B8;
    background: #F8FAFC;
}

.cselect-trigger:focus,
.cselect-wrapper.is-open .cselect-trigger {
    border-color: #2563EB;
    background: #FFFFFF;
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.16);
}

.cselect-trigger-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
}

.cselect-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #64748B;
    flex-shrink: 0;
}

.cselect-wrapper.has-value .cselect-trigger-icon {
    color: #2563EB;
}

.cselect-trigger-text {
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cselect-placeholder {
    color: #64748B;
    font-weight: 400;
}

.cselect-selected-value {
    color: #0F172A;
    font-weight: 600;
}

.cselect-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748B;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.cselect-wrapper.is-open .cselect-chevron {
    transform: rotate(180deg);
    color: #2563EB;
}

/* 3. Desktop Dropdown Panel */
@media (min-width: 768px) {
    .cselect-dropdown {
        position: absolute;
        top: calc(100% + 6px);
        left: 0;
        right: 0;
        min-width: 290px;
        background: #FFFFFF;
        border: 1px solid #E2E8F0;
        border-radius: 14px;
        box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.14), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
        z-index: 1050;
        display: none;
        opacity: 0;
        transform: translateY(-8px);
        transition: opacity 0.18s ease, transform 0.18s ease;
        max-height: 380px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .cselect-wrapper.is-open .cselect-dropdown {
        opacity: 1;
        transform: translateY(0);
        display: flex;
    }

    .cselect-search-wrap {
        padding: 10px 12px;
        background: #F8FAFC;
        border-bottom: 1px solid #E2E8F0;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .cselect-search-icon {
        color: #94A3B8;
        flex-shrink: 0;
    }

    .cselect-search-input {
        width: 100%;
        border: 1px solid #CBD5E1;
        border-radius: 8px;
        padding: 7px 10px;
        font-size: 0.88rem;
        color: #0F172A;
        background: #FFFFFF;
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s;
    }

    .cselect-search-input:focus {
        border-color: #2563EB;
        box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    }

    .cselect-options-list {
        padding: 6px 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        max-height: 280px;
    }

    .cselect-group-header {
        padding: 8px 14px 4px;
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: #64748B;
        background: #F8FAFC;
        border-top: 1px solid #F1F5F9;
        border-bottom: 1px solid #F1F5F9;
    }

    .cselect-group-header:first-child {
        border-top: none;
    }

    .cselect-option {
        padding: 8px 14px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        cursor: pointer;
        font-size: 0.88rem;
        color: #1E293B;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .cselect-option:hover,
    .cselect-option.is-focused {
        background: #F1F5F9;
        color: #1D4ED8;
    }

    .cselect-option.is-selected {
        background: #EFF6FF;
        color: #1D4ED8;
        font-weight: 600;
    }

    .cselect-option-left {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .cselect-opt-tag {
        font-size: 0.7rem;
        background: #E2E8F0;
        color: #475569;
        padding: 2px 6px;
        border-radius: 4px;
        font-weight: 600;
    }

    .cselect-option.is-selected .cselect-opt-tag {
        background: #DBEAFE;
        color: #1D4ED8;
    }

    .cselect-check-icon {
        display: none;
        color: #2563EB;
        flex-shrink: 0;
    }

    .cselect-option.is-selected .cselect-check-icon {
        display: inline-flex;
    }

    .cselect-footer {
        padding: 8px 14px;
        background: #F8FAFC;
        border-top: 1px solid #E2E8F0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 0.8rem;
        color: #64748B;
        flex-shrink: 0;
    }

    .cselect-clear-btn {
        background: none;
        border: none;
        padding: 0;
        color: #64748B;
        font-size: 0.8rem;
        cursor: pointer;
        text-decoration: underline;
    }

    .cselect-clear-btn:hover {
        color: #DC2626;
    }

    .cselect-empty-msg {
        padding: 16px;
        text-align: center;
        color: #94A3B8;
        font-size: 0.88rem;
        display: none;
    }
}

/* 4. Mobile Bottom-Sheet Modal (Active on <= 767px) */
@media (max-width: 767.98px) {
    /* Hide desktop dropdown on mobile */
    .cselect-dropdown {
        display: none !important;
    }

    /* Global Bottom Sheet Backdrop */
    .cselect-sheet-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 99998;
        display: none;
        opacity: 0;
        transition: opacity 0.25s ease;
    }

    .cselect-sheet-backdrop.active {
        display: block;
        opacity: 1;
    }

    /* Mobile Bottom Sheet Drawer */
    .cselect-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 85vh;
        background: #FFFFFF;
        border-radius: 20px 20px 0 0;
        z-index: 99999;
        display: flex;
        flex-direction: column;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
        transform: translateY(105%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
        box-sizing: border-box;
    }

    .cselect-sheet.active {
        transform: translateY(0);
    }

    .cselect-sheet-handle {
        width: 44px;
        height: 5px;
        background: #CBD5E1;
        border-radius: 3px;
        margin: 10px auto 4px;
        flex-shrink: 0;
    }

    .cselect-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 18px;
        border-bottom: 1px solid #F1F5F9;
        flex-shrink: 0;
    }

    .cselect-sheet-title {
        font-size: 1.05rem;
        font-weight: 700;
        color: #0F172A;
    }

    .cselect-sheet-close {
        background: #F1F5F9;
        border: none;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #475569;
        cursor: pointer;
        font-size: 14px;
        transition: background 0.15s;
    }

    .cselect-sheet-close:hover {
        background: #E2E8F0;
        color: #0F172A;
    }

    .cselect-sheet-search {
        padding: 10px 18px;
        background: #F8FAFC;
        border-bottom: 1px solid #E2E8F0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .cselect-sheet-search input {
        width: 100%;
        min-height: 42px;
        padding: 8px 14px;
        font-size: 0.95rem;
        border: 1.5px solid #CBD5E1;
        border-radius: 10px;
        background: #FFFFFF;
        color: #0F172A;
        outline: none;
    }

    .cselect-sheet-search input:focus {
        border-color: #2563EB;
    }

    .cselect-sheet-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 12px;
    }

    .cselect-sheet-group-label {
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #64748B;
        padding: 10px 14px 4px;
        background: #F8FAFC;
        border-radius: 6px;
        margin: 6px 0 2px;
    }

    .cselect-sheet-item {
        min-height: 50px;
        padding: 11px 14px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        margin-bottom: 2px;
        transition: background 0.15s;
    }

    .cselect-sheet-item:active {
        background: #F1F5F9;
    }

    .cselect-sheet-item.is-selected {
        background: #EFF6FF;
        color: #1D4ED8;
        font-weight: 600;
    }

    .cselect-sheet-item-text {
        font-size: 0.95rem;
        color: #1E293B;
    }

    .cselect-sheet-item.is-selected .cselect-sheet-item-text {
        color: #1D4ED8;
        font-weight: 600;
    }

    .cselect-sheet-check {
        display: none;
        color: #2563EB;
    }

    .cselect-sheet-item.is-selected .cselect-sheet-check {
        display: inline-flex;
    }

    .cselect-sheet-footer {
        padding: 12px 18px;
        border-top: 1px solid #F1F5F9;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
    }

    .cselect-sheet-clear-btn {
        background: none;
        border: none;
        color: #DC2626;
        font-size: 0.9rem;
        font-weight: 600;
        cursor: pointer;
    }

    .cselect-sheet-done-btn {
        background: #2563EB;
        color: #FFFFFF;
        border: none;
        padding: 8px 20px;
        border-radius: 8px;
        font-size: 0.9rem;
        font-weight: 600;
        cursor: pointer;
    }

    /* Mobile trigger styling to prevent truncation & awkward box overflow */
    .cselect-trigger {
        min-height: 48px;
        padding: 0.5rem 0.6rem;
        gap: 0.3rem;
        border-radius: 10px;
    }

    .cselect-trigger-left {
        gap: 0.35rem;
        min-width: 0;
        flex: 1;
    }

    .cselect-trigger-icon {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .cselect-trigger-icon svg {
        width: 16px;
        height: 16px;
    }

    .cselect-trigger-text {
        font-size: 0.8rem;
        font-weight: 550;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cselect-chevron {
        flex-shrink: 0;
    }

    .cselect-chevron svg {
        width: 12px;
        height: 12px;
    }
}

