/* 바텀시트 오버레이 */
.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.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(0px);
    display: none;
}

.bottomsheet-overlay.active {
    opacity: 1;
    visibility: visible;
    display: block;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* 바텀시트 */
.bottomsheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 2001;
    transform: translateY(100%) scale(0.95);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-height: 80vh;
    overflow: hidden;
    box-shadow:
            0 -4px 20px rgba(0, 0, 0, 0),
            0 0 0 1px rgba(255, 255, 255, 0);
    opacity: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.bottomsheet.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    box-shadow:
            0 -4px 20px rgba(0, 0, 0, 0.15),
            0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* PC에서는 중앙 모달 — 최소 높이는 기존 크기, 내용이 넘치면 늘어난다 (#520)
   ⚠️ bottom:auto 가 핵심 — 모바일용 base 규칙의 bottom:0 이 PC 의 top:50% 와 동시에 걸리면
   높이가 내용과 무관하게 항상 딱 50vh 로 강제된다(over-constrained). 운영 실측 2026-09-15:
   세로 1000px 화면에서 모달 500px, KD 호텔 검색 결과는 590px 가 필요해 선택 버튼이 잘렸다.
   작업자 결정: 짧은 단계는 기존 크기(여기 50vh, 세로 950px 이하는 아래 컴팩트 블록의
   min(85vh, 480px/KD 530px)) 그대로 두고, 그보다 긴 단계만 내용만큼 늘린다.
   (고정 높이로 올리면 짧은 단계에 하단 여백이, 순수 내용 기반이면 단계마다 크기 변화가 커서 둘 다 기각.)
   내용이 88vh 를 넘으면 모달은 거기서 멈추고 .bottomsheet-content 안에서만 스크롤한다. */
@media (min-width: 768px) {
    .bottomsheet {
        position: fixed;
        top: 50%;
        bottom: auto;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        width: 90%;
        max-width: 500px;
        border-radius: 16px;
        min-height: 50vh;
        max-height: 88vh;
        display: none;
    }

    /* 모달이 88vh 에서 멈추면 내용 영역이 줄어들며 스크롤. 파일 아래쪽 base
       .bottomsheet-content 의 max-height(calc(90vh - 100px))보다 우선하도록 부모 셀렉터를 붙인다. */
    .bottomsheet .bottomsheet-content {
        max-height: none;
    }

    .bottomsheet.active {
        transform: translate(-50%, -50%) scale(1);
        display: flex;
    }
}

/* 바텀시트 헤더 */
.bottomsheet-header {
    padding: 20px 20px 0;
    text-align: center;
    position: relative;
}

.bottonsheet-header-top {
    display: flex;
    flex-direction: row;
    align-items: start;
    margin-bottom: 8px;
    justify-content: space-between;
    gap: 10px;
}

.bottomsheet-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-top: 3px;
}

.bottomsheet-subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.bottomsheet-close-btn {
    /*position: absolute;*/
    /*top: 16px;*/
    /*right: 20px;*/
    background: #f5f5f5;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bottomsheet-close-btn:hover {
    background: #eee;
    color: #333;
}

.bottomsheet-back-btn {
    /*position: absolute;*/
    /*top: 16px;*/
    /*left: 20px;*/
    background: #f5f5f5;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    display: none;
    /*flex-shrink: 0;*/
}

.bottomsheet-back-btn.active {
    display: block;
}

.bottomsheet-back-btn:hover {
    background: #eee;
    color: #333;
}

/* 바텀시트 컨텐츠 */
.bottomsheet-content {
    padding: 0 20px 20px;
    overflow-y: auto;
    max-height: calc(90vh - 100px);
    min-height: 150px;
}

/* 검색 박스 */
.bottomsheet-search-container {
    margin-bottom: 20px;
    display: none;
}

.bottomsheet-search-container.active {
    display: block;
}

.bottomsheet-search-box {
    position: relative;
}

.bottomsheet-search-input {
    width: 100%;
    padding: 14px 20px 14px 45px;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    font-size: 16px;
    background: #fafafa;
    transition: all 0.3s ease;
}

.bottomsheet-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #999;
}

/* 리스트 컨테이너 */
.bottomsheet-list-container {
    display: none;
}
.bottomsheet-list-container.active {
    display: block;
}

.bottomsheet-list-item {
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.bottomsheet-list-item.selected {
    border-color: #667eea;
    background: #f8f9ff;
}

/* 준비중(오픈 예정) 공항: 보이지만 클릭 불가 비활성 상태 */
.bottomsheet-list-item-disabled {
    cursor: default;
    opacity: 0.45;
    background: #f7f7f7;
    pointer-events: none;
}

.bottomsheet-item-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
}

.bottomsheet-item-content {
    margin-left: 36px;
}

.bottomsheet-item-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.bottomsheet-item-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.3;
}

.bottomsheet-item-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #ccc;
    font-size: 14px;
}

/* 빈 상태 */
.bottomsheet-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    display: none;
}

.bottomsheet-empty-state.active {
    display: block;
}

.bottomsheet-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.bottomsheet-empty-text {
    font-size: 16px;
    margin-bottom: 6px;
}

.bottomsheet-empty-desc {
    font-size: 14px;
    line-height: 1.4;
}

/* 로딩 */
.bottomsheet-loading {
    text-align: center;
    padding: 40px;
    color: #999;
    display: none;
}

.bottomsheet-loading.active {
    display: block;
}

.bottomsheet-loading-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: bottomsheet-spin 1s linear infinite;
}

@keyframes bottomsheet-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 스크롤바 */
.bottomsheet-content::-webkit-scrollbar {
    width: 4px;
}

.bottomsheet-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.bottomsheet-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.bottomsheet-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 구글맵 검색 스타일 */
.google-map-search {
    padding: 10px 0;
}

.map-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 15px;
    display: none;
}
.map-search-input.active {
    display: block;
}

.google-map-container {
    width: 100%;
    height: 200px;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 15px;
    align-items: center;
    justify-content: center;
    color: #666;
    display: none;
}

.google-map-container.active {
    display: flex;
}

.autocomplete-results {
    overflow-y: auto;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.autocomplete-item:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.autocomplete-icon {
    font-size: 18px;
}

.autocomplete-content {
    flex: 1;
}

.autocomplete-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.autocomplete-address {
    font-size: 12px;
    color: #666;
}

/* 날짜/시간 선택 컨테이너 */
.bottomsheet-datetime-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

/* 날짜/시간 선택기 */
.datetime-picker {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 89px;
}

/* 날짜/시간 섹션 */
.datetime-section {
    border-radius: 12px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    overflow: hidden; /* 중요: 애니메이션 중 내용이 밖으로 나가지 않도록 */
}

.datetime-section.expanded {
    border-color: #007bff;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.1);
}

.datetime-section.expanded .datetime-content {
    max-height: 600px; /* 충분히 큰 값 */
    opacity: 1;
    transform: translateY(0);
    padding: 0 16px 16px; /* 원래 패딩 유지 */
}

/* 접힌 상태에서는 패딩도 0으로 */
.datetime-section .datetime-content {
    padding: 0 16px 0; /* 아래 패딩만 0 */
}

/* 날짜/시간 헤더 */
.datetime-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.datetime-label {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.datetime-value {
    font-size: 14px;
    color: #666;
    margin-left: auto;
    margin-right: 8px;
}

.datetime-arrow {
    font-size: 14px;
    color: #999;
    transition:
            transform 0.3s ease,
            color 0.3s ease;
    display: inline-block;
}

.datetime-arrow.expanded {
    transform: rotate(180deg);
}

/* 날짜/시간 내용 */
.datetime-content {
    padding: 0 16px 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-10px);
    transition:
            max-height 0.4s ease,
            opacity 0.3s ease 0.1s,
            transform 0.3s ease 0.1s,
            padding 0.3s ease;
}

/* 달력 스타일 */
.calendar {
    background: white;
    border-radius: 8px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
}

.calendar-nav-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-nav-btn:hover {
    background: #e9ecef;
}

.calendar-month {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.calendar-grid {
    padding: 16px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.calendar-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    padding: 8px 0;
}

.calendar-dates {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-date {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.calendar-date.today {
    border: 1px solid grey;
    font-weight: 600;
}

.calendar-date.selected {
    background: #007bff;
    color: white;
    font-weight: 600;
}

.calendar-date.disabled {
    color: #ccc;
    cursor: not-allowed;
}

.calendar-date.empty {
    cursor: default;
}

/* 시간 리스트 스타일 */
.time-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.time-item {
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.time-item:hover {
    background: rgba(0, 123, 255, 0.1);
    border-color: #007bff;
}

.time-item.selected {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* 시간 묶음 제목 — 당일 도착 가능 / 다음 날부터 도착 (#547). 스크롤해도 목록 위에 붙어 있다. */
.time-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    flex: none;
    padding: 6px 4px 4px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: #555;
}

/* 선택 완료 버튼 */
.datetime-actions {
    margin-top: 20px;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));   /* 홈 인디케이터 safe-area */
    border-top: 1px solid #e9ecef;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    z-index: 1000;
}

.datetime-confirm-btn {
    width: 100%;
    padding: 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.datetime-confirm-btn:hover:not(:disabled) {
    background: #218838;
}

.datetime-confirm-btn.disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.datetime-confirm-btn.enabled {
    background: #28a745;
}

/* =========================================================================
 * 저해상도 PC 컴팩트 모드 (#425) — KD·D2D 예약 바텀시트 공용
 * 1366x768·1600x900 같은 세로가 낮은 PC 에서 중앙 모달이 화면을 넘어
 * 하단 버튼이 잘리던 문제.
 * - 모바일(<768px, 바텀시트 모드)과 FHD 이상(세로 951px+)은 조건에 안 걸려 불변.
 * - 가독성 우선: 폰트는 최대 -1px(12px 미만 금지), 여백·달력 셀 위주로 압축.
 * - D2D 전용 요소(지도 미리보기 등)의 압축은 d2d/booking.css 의 같은 미디어 블록에.
 * ========================================================================= */
@media (min-width: 768px) and (max-height: 950px) {
    /* 최소 높이 min(85vh, 480px) — KD 는 koreaDelivery.css 에서 530px.
       #425 에서는 고정 높이였는데, 호텔 검색 결과처럼 내용이 더 긴 단계에서 선택 버튼이 잘려
       #520 에서 최소 높이로 바꿨다 — 짧은 단계는 기존 크기 그대로, 넘치면 늘어난다(최대 88vh).
       bottom:auto·max-height 는 파일 위쪽 PC 공통 규칙에 있다. */
    .bottomsheet,
    .bottomsheet[data-active-page] { min-height: min(85vh, var(--gl-bottomsheet-h, 480px)); }
    /* 최소 높이를 내용 영역이 채우도록 flex — D2D 장소 미리보기의 확인 버튼 하단 고정이 이것에 기댄다 */
    .bottomsheet-content,
    .bottomsheet[data-active-page] .bottomsheet-content { flex: 1 1 auto; min-height: 0; }

    .bottomsheet-header { padding: 14px 20px 0; }
    .bottomsheet-title { font-size: 17px; }
    .bottomsheet-subtitle { margin-bottom: 12px; }
    .bottomsheet-content { padding-bottom: 14px; }
    .bottomsheet-list-item { padding: 12px 14px; }

    /* 호텔/장소 검색 결과 페이지: 지도를 화면 높이 비례로 축소해 내용 자체를 낮춘다
       (그래도 최소 높이보다 길면 모달이 늘어난다, 최대 88vh). */
    .google-map-container { height: clamp(140px, 22vh, 200px); }

    /* 달력·시간 선택 (KD 스타일 datetime 바텀시트) */
    .datetime-header { padding: 12px 16px; }
    .calendar-header { padding: 8px 12px; }
    .calendar-nav-btn { width: 30px; height: 30px; }
    .calendar-grid { padding: 10px 12px; }
    .calendar-days, .calendar-dates { gap: 4px; }
    .calendar-day-header { padding: 4px 0; }
    .calendar-date { aspect-ratio: auto; height: 32px; font-size: 13px; }
    .time-list { max-height: 160px; }
    .time-item { padding: 10px 12px; }
    .datetime-actions { margin-top: 12px; padding: 12px 16px; }
    .datetime-confirm-btn { padding: 12px; font-size: 15px; }
    /* 고정 확인 바가 낮아진 만큼 스크롤 여유분도 축소 (원래 89px) */
    .datetime-picker { padding-bottom: 74px; }

    /* 날짜 선택 시트(.dtp-sheet, common/DateTimePicker.js)는 원래부터 내용 기반
       높이(PC max 70vh)라 고정 대상이 아니다. 아주 낮은 화면(1280x720 등)에서
       달력+확인 버튼이 70vh 를 넘어 잘리는 것만 max 를 올려 막는다.
       (클래스 2회 반복은 로드 순서와 무관하게 datetimepicker.css 를 이기기 위함 —
        KD 페이지는 datetimepicker.css 가 이 파일보다 늦게 로드된다.) */
    .dtp-sheet.dtp-sheet { max-height: 88vh; }

    /* dtp 내부도 KD 달력과 같은 밀도로 — 날짜 셀이 aspect-ratio:1 이라 저해상도에서
       셀 하나가 ~48px 로 부풀어 시트가 화면을 거의 채우던 문제 */
    .dtp-sheet.dtp-sheet .dtp-header { padding: 14px 16px 8px; }
    .dtp-sheet.dtp-sheet .dtp-title { font-size: 16px; }
    .dtp-sheet.dtp-sheet .dtp-body { padding: 0 16px; }
    .dtp-sheet.dtp-sheet .dtp-section-header { padding: 10px 14px; }
    .dtp-sheet.dtp-sheet .dtp-calendar-header { padding: 4px 0 8px; }
    .dtp-sheet.dtp-sheet .dtp-calendar-nav { width: 30px; height: 30px; }
    .dtp-sheet.dtp-sheet .dtp-calendar-month { font-size: 15px; }
    .dtp-sheet.dtp-sheet .dtp-calendar-day-header { padding: 4px 0; }
    .dtp-sheet.dtp-sheet .dtp-calendar-date { aspect-ratio: auto; height: 32px; font-size: 13px; }
    .dtp-sheet.dtp-sheet .dtp-footer { padding: 10px 16px; }
    .dtp-sheet.dtp-sheet .dtp-confirm-btn { padding: 12px; font-size: 15px; }
}

/* 더 낮은 화면 (1366x768, 1280x720 등) — 여백만 한 단계 더 압축.
   높이는 위 컴팩트 블록의 최소 높이 규칙을 그대로 쓴다. */
@media (min-width: 768px) and (max-height: 800px) {
    .bottomsheet-header { padding: 10px 16px 0; }
    .bottomsheet-title { font-size: 16px; }
    .bottomsheet-subtitle { margin-bottom: 8px; }
    .bottomsheet-list-item { padding: 10px 12px; }

    .calendar-date { height: 28px; }
    .datetime-header { padding: 10px 14px; }

    .dtp-sheet.dtp-sheet .dtp-header { padding: 10px 14px 6px; }
    .dtp-sheet.dtp-sheet .dtp-calendar-date { height: 28px; }
}

/* 반응형 */
@media (max-width: 768px) {
    .datetime-header {
        padding: 12px;
    }

    .datetime-content {
        padding: 0 12px 12px;
    }

    .calendar-grid {
        padding: 12px;
    }

    .calendar-date {
        font-size: 13px;
    }

    .time-item {
        padding: 10px 12px;
        font-size: 13px;
    }

    .datetime-confirm-btn {
        padding: 14px;
        font-size: 15px;
    }

    .datetime-picker {
        padding-bottom: 84px;
    }
}