/* =============================================
   CustomSelect - 공통 셀렉트 컴포넌트
   PC: 드롭다운 / 모바일: 바텀시트
   ============================================= */

/* ===== Wrapper ===== */
.cs-wrap {
    position: relative;
    width: 100%;
}

.cs-wrap select {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ===== Display (트리거 버튼) ===== */
.cs-display {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    background: #FAFAFA;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s;
    -webkit-user-select: none;
    user-select: none;
}

.cs-display:active,
.cs-wrap.open .cs-display {
    border-color: #512772;
    background: #fff;
}

.cs-display .cs-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-display .cs-text.placeholder {
    color: #bbb;
}

.cs-display .cs-arrow {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    margin-left: 8px;
    transition: transform 0.2s;
}

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

/* ===== PC: 드롭다운 ===== */
@media (min-width: 768px) {
    .cs-dropdown {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        background: white;
        border: 1px solid #ddd;
        border-radius: 10px;
        max-height: 280px;
        overflow-y: auto;
        z-index: 200;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }

    .cs-wrap.open .cs-dropdown {
        display: block;
    }

    .cs-bottomsheet-overlay,
    .cs-bottomsheet {
        display: none !important;
    }
}

/* ===== Mobile: 바텀시트 ===== */
@media (max-width: 767px) {
    .cs-dropdown {
        display: none !important;
    }

    .cs-bottomsheet-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 2000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.25s ease;
        backdrop-filter: blur(0px);
    }

    .cs-bottomsheet-overlay.active {
        opacity: 1;
        visibility: visible;
        backdrop-filter: blur(2px);
    }

    .cs-bottomsheet {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: white;
        border-radius: 20px 20px 0 0;
        z-index: 2001;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        max-height: 70vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .cs-bottomsheet.active {
        transform: translateY(0);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .cs-bs-header {
        padding: 16px 20px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #f0f0f0;
        flex-shrink: 0;
    }

    .cs-bs-title {
        font-size: 16px;
        font-weight: 700;
        color: #333;
    }

    .cs-bs-close {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #f5f5f5;
        border: none;
        font-size: 18px;
        color: #666;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .cs-bs-body {
        overflow-y: auto;
        flex: 1;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

/* ===== 옵션 아이템 (공통) ===== */
.cs-option {
    padding: 14px 16px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.cs-option:last-child {
    border-bottom: none;
}

.cs-option:hover {
    background: #f5f0fa;
}

.cs-option.selected {
    color: #512772;
    font-weight: 600;
    background: #F5F0FA;
}

.cs-option.selected::after {
    content: '✓';
    float: right;
    color: #512772;
    font-weight: 700;
}

.cs-option.disabled {
    color: #ccc;
    pointer-events: none;
}
