/* 팝업 전체를 감싸는 컨테이너 */
.popup-wrapper {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: row-reverse; /* [2][1] 순서로 배치 */

    /* 핵심 수정: stretch(동일높이) 대신 flex-start(각자높이) 사용 */
    align-items: flex-start;

    gap: 15px;
    z-index: 10000;
    pointer-events: none;
}

/* 개별 팝업 본체 */
.custom-popup-content {
    pointer-events: auto;
    background: #fff;
    width: 500px; /* 너비를 고정해야 나란히 배치했을 때 깔끔합니다 */
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* 팝업 몸통: 남는 공간을 모두 차지하도록 설정 */
.popup-body {
    /* flex: 1은 유지해도 무방하지만, 내용만큼만 줄어들게 됩니다 */
    overflow-y: auto;
    background: #fff;
}

/* 텍스트 팝업 내부 여백 및 폰트 조절 */
.popup-body .p-3 {
    padding: 20px !important;
}

.popup-body .p-3 p {
    margin-bottom: 10px;
    word-break: keep-all;
}

.popup-body img {
    width: 100%;
    height: auto;
    display: block;
}

.popup-body a {
    color: var(--e-global-color-secondary);
    font-size: inherit;
}

/* 푸터 영역 */
.popup-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.today-check-wrapper {
    font-size: 13px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.today-check-wrapper label {
    margin-bottom: 0;
    padding-left: 4px;
}

.btn-close-popup {
    background: #333;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.btn-close-popup:hover {
    background: #000;
}


@media (min-width: 600px) and (max-width: 1024px) {
    /* 팝업이 여러 개일 때 살짝 어긋나게 하거나
       완전히 겹치게 하려면 아래와 같이 설정합니다. */
    .popup-wrapper {
        top: 20px;
        right: 20px;
        display: flex;
        width: 400px;
        flex-direction: column; /* [2][1] 순서로 배치 */

        /* 핵심 수정: stretch(동일높이) 대신 flex-start(각자높이) 사용 */
        align-items: flex-start;

        gap: 0;
    }

    .custom-popup-content {
        position: absolute;
        top: 0;
        pointer-events: auto;
        background: #fff;
        width: 100%; /* 너비를 고정해야 나란히 배치했을 때 깔끔합니다 */
        max-width: 400px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    }

    #mainPopup1 {
        z-index: 10001;
    }

    #mainPopup2 {
        z-index: 10002;
    }

    .popup-body .p-3 {
        padding: 15px !important;
    }

    .popup-body .p-3 p {
        font-size: 14px !important; /* 모바일에서 텍스트 크기 최적화 */
        line-height: 1.4 !important;
    }
}


@media (max-width: 600px) {
    .popup-wrapper {
        top: 5%;
        right: 5%;
        left: 5%; /* 중앙 정렬 느낌을 위해 좌우 여백 통일 */
        flex-direction: column; /* 가로가 아닌 세로로 겹치게 변경 */
        align-items: center;
        gap: 0; /* 겹치는 효과를 위해 간격 제거 (필요시 조정) */
    }

    .custom-popup-content {
        width: 100%; /* 모바일 화면 너비에 맞춤 */
        position: absolute; /* 팝업들을 한 자리에 겹치게 설정 */
        top: 0;
        max-width: 400px; /* 너무 커지는 것 방지 */
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    }

    /* 팝업이 여러 개일 때 살짝 어긋나게 하거나
       완전히 겹치게 하려면 아래와 같이 설정합니다. */
    #mainPopup1 {
        z-index: 10001;
    }

    #mainPopup2 {
        z-index: 10002;
    }

    .popup-body .p-3 {
        padding: 15px !important;
    }

    .popup-body .p-3 p {
        font-size: 14px !important; /* 모바일에서 텍스트 크기 최적화 */
        line-height: 1.4 !important;
    }
}