/*
 * 결제 화면 쿠폰 할인 UI (TP-86)
 * 모바일(ticketPayment.html)과 웹(ticketPayment_web.html)이 같은 마크업을 쓰므로 공용으로 둔다.
 */
/* ===== 쿠폰 할인 (TP-86) ===== */
/* 결제 화면에는 한 줄만 둔다. 쿠폰이 없는 사람에게는 이 줄 자체가 렌더되지 않는다 */
.coupon_entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    margin: 4px 0 12px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}
.coupon_entry.is_applied {
    border-color: #e8574c;
    background: #fff5f4;
}
.coupon_entry .coupon_entry_label { color: #1f1f1f; font-weight: 600; }
.coupon_entry .coupon_entry_value { color: #e8574c; font-weight: 600; }
.coupon_entry .coupon_entry_value::after { content: ' ›'; }

.coupon_fee_notice { display: block; margin: 4px 0 0; font-size: 12px; color: #8a8a8a; }
/*
   초대권으로 수수료가 빠졌을 때, 금액 아래에 이유를 붙인다.
   안내 문구가 금액보다 넓어서 감싼 영역도 오른쪽 정렬해야 금액이 다른 줄과 맞는다.
*/
.fee_value_wrap { display: block; text-align: right; }
/* 공통 .row_wrap .txt(웹: flex+가운데 정렬, 모바일: -webkit-box+max-width)가 금액을 가운데/왼쪽으로 보내므로
   그보다 구체적인 선택자로 오른쪽 정렬을 되돌린다 */
.info_st4_wrap .row_wrap .fee_value_wrap > .txt.tit_st5 {
    display: block;
    max-width: none !important;
    text-align: right;
}
.coupon_fee_waived { display: block; margin-top: 2px; font-size: 12px; color: #1a9d63; text-align: right; }
.coupon_origin_amount { display: block; margin-top: 2px; font-size: 12px; color: #8a8a8a; text-align: right; }
.coupon_discount_value { color: #e8574c; }

/* ===== 쿠폰 팝업 ===== */
.coupon_modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .45);
}
.coupon_modal[hidden] { display: none; }
.coupon_modal_box {
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}
.coupon_modal_head {
    position: relative;
    padding: 16px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid #eee;
}
.coupon_modal_close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: 0;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: #767676;
    cursor: pointer;
}
.coupon_modal_body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;   /* 없으면 flex 자식이 내용만큼 부풀어 목록이 안 줄어든다 */
}

/* 등록 방식 전환 탭 — 결제 팝업과 내 쿠폰함이 같이 쓴다 (TP-86) */
.coupon_code_tabs {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.coupon_code_tab {
    flex: 1 1 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 18px;
    background: #fff;
    color: #767676;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.coupon_code_tab.is_active {
    border-color: #e8574c;
    background: #fdeeed;
    color: #e8574c;
}

.coupon_code_row { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.coupon_code_row input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.coupon_code_row button {
    flex: 0 0 auto;
    height: 40px;
    padding: 0 14px;
    border: 1px solid #767676;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
}
.coupon_code_hint { flex: 0 0 auto; margin: 6px 2px 0; font-size: 12px; color: #8a8a8a; }
.coupon_code_error { flex: 0 0 auto; margin-top: 6px; font-size: 12px; color: #e8574c; }
.coupon_code_error.is_ok { color: #1a9d63; }
.coupon_code_error[hidden] { display: none; }

.coupon_guide { flex: 0 0 auto; margin: 14px 0 0; padding: 0 0 0 4px; }
.coupon_guide li {
    position: relative;
    padding-left: 10px;
    font-size: 12px;
    line-height: 1.7;
    color: #555;
    list-style: none;
}
.coupon_guide li::before { content: '·'; position: absolute; left: 0; }
.coupon_guide em { font-style: normal; font-weight: 700; color: #e8574c; }

.coupon_list_head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 18px 0 8px;
    font-size: 14px;
    font-weight: 700;
}

/*
    쿠폰이 여러 장이면 목록만 스크롤한다.
    등록칸과 적용 버튼은 늘 보여야 하므로 목록에만 높이를 주고 넘치면 굴린다.
*/
.coupon_list {
    flex: 0 1 auto;   /* 쿠폰이 없으면 높이를 차지하지 않는다 */
    max-height: 46vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;   /* 스크롤바가 카드 테두리를 덮지 않게 */
}
.coupon_list::-webkit-scrollbar { width: 6px; }
.coupon_list::-webkit-scrollbar-thumb { background: #d5d5d5; border-radius: 3px; }
.coupon_list::-webkit-scrollbar-track { background: transparent; }
.coupon_list_head .coupon_selected_cnt { font-size: 12px; font-weight: 500; color: #767676; }

.coupon_item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    cursor: pointer;
}
.coupon_item.is_checked { border-color: #e8574c; background: #fff5f4; }
.coupon_item.is_disabled { opacity: .55; cursor: default; background: #fafafa; }
.coupon_item input[type="checkbox"] { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; accent-color: #e8574c; }
.coupon_item_body { flex: 1 1 auto; min-width: 0; }
.coupon_item_top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.coupon_item_name { font-size: 14px; font-weight: 600; color: #1f1f1f; }
.coupon_item_amount { font-size: 14px; font-weight: 700; color: #e8574c; white-space: nowrap; }
/* 주문 전체 쿠폰 — 쓰임이 달라(주문당 1장) 한눈에 구분되게 */
.coupon_item_scope {
    flex: 0 0 auto;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 10px;
    background: #eef4ff;
    color: #3b6fd4;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.coupon_item_desc { margin-top: 4px; font-size: 12px; color: #767676; }
.coupon_item.is_disabled .coupon_item_amount { color: #999; }
.coupon_empty { padding: 24px 0; text-align: center; font-size: 13px; color: #767676; }

.coupon_modal_foot { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid #eee; }
.coupon_modal_foot button { flex: 1 1 0; height: 46px; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; }
.coupon_btn_cancel { border: 1px solid #e8574c; background: #fff; color: #e8574c; }
.coupon_btn_apply { border: 0; background: #e8574c; color: #fff; }

/* ===== 마이페이지 '내 쿠폰함' (TP-86) ===== */
/* 다른 화면(구매내역 등)처럼 좌우 20px 여백을 둔다 — 이 클래스만 좌우 패딩이 0이라 유독 답답해 보였다 */
.coupon_box_wrap { padding: 8px 20px 24px; }

/*
   .depth2_wrap 기본값(height:100%)은 슬라이드 패널(공지사항/알림설정 등)이 뷰포트 높이를
   꽉 채우고 그 안에서만 스크롤되게 하려는 의도인데, 쿠폰함은 그런 오버레이 패널이 아니라
   그냥 한 페이지라 쿠폰이 몇 장 없으면 아래에 빈 흰 공간만 남는다.
   .depth2_wrap은 여러 화면이 공유하는 클래스라 여기서 직접 못 고치고, 쿠폰함 전용 클래스로만 덮어쓴다.
   — 내용만큼만 높이를 갖게 하고, 넘치면 페이지 자체가 스크롤된다(다른 일반 화면들과 동일).
*/
.depth2_wrap.coupon_wrap {
    height: auto;
}

.coupon_register_box {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}
.coupon_register_box input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    text-transform: uppercase;
}
.coupon_register_box button {
    flex: 0 0 auto;
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    background: #e8574c;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.coupon_register_hint { margin: 0 2px 4px; font-size: 12px; color: #8a8a8a; }
.coupon_register_msg { margin: 4px 2px 0; font-size: 13px; }
.coupon_register_msg[hidden] { display: none; }
.coupon_register_msg.is_error { color: #e8574c; }
.coupon_register_msg.is_ok { color: #1a9d63; }

/* 좁은 화면(모바일)은 1열, 넓은 화면(웹 마이페이지 패널)은 2열 — 구매 내역 카드 그리드와 맞춤 */
.coupon_box_list { margin-top: 18px; display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) {
    .coupon_box_list { grid-template-columns: 1fr 1fr; }
}

.coupon_card {
    position: relative;
    border: 1px solid #eee;
    border-left: 4px solid #e8574c;
    border-radius: 14px;
    padding: 16px 16px 14px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}
.coupon_card.is_dim { border-left-color: #c9c9c9; background: #fafafa; }
.coupon_card.is_dim .coupon_card_discount { color: #999; }

.coupon_card_head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.coupon_card_discount { font-size: 18px; font-weight: 800; color: #e8574c; }
.coupon_card_name { margin-top: 2px; font-size: 15px; font-weight: 600; color: #1f1f1f; }
.coupon_card_meta { margin-top: 6px; font-size: 13px; color: #666; line-height: 1.5; }
.coupon_card_meta .lbl { display: inline-block; min-width: 56px; color: #999; }
.coupon_card_code { margin-top: 8px; font-size: 12px; color: #aaa; letter-spacing: 1px; }

.coupon_badge {
    flex: 0 0 auto;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.coupon_badge.st_USABLE   { background: #eaf7ef; color: #1a9d63; }
.coupon_badge.st_PENDING  { background: #fff3e0; color: #d98a00; }
.coupon_badge.st_USED     { background: #eee; color: #888; }
.coupon_badge.st_DISABLED { background: #eee; color: #888; }
.coupon_badge.st_EXPIRED  { background: #f6e7e7; color: #b05656; }

.coupon_box_empty { padding: 48px 0; text-align: center; color: #999; font-size: 14px; }

/*
   내 쿠폰함(웹) 좁은 화면 대응.
   style_web.css의 .mypage_wrap은 사이드메뉴(최소 240px)+본문을 가로로 배치하는
   데스크톱 2단 레이아웃이라, 900px 밑에서는 본문 폭이 음수가 되어 내용이 밀려난다.
   이 화면(.coupon_page_wrap)만 세로로 쌓아서 좁은 화면에서도 보이게 한다.
*/
@media (max-width: 900px) {
    .coupon_page_wrap {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .coupon_page_wrap .side_menu_wrap {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
    }
    .coupon_page_wrap .side_menu_wrap .side_menu_area {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px 20px;
    }
    .coupon_page_wrap .side_menu_wrap .menu {
        width: auto;
        padding: 8px 0;
    }
    .coupon_page_wrap .side_menu_wrap .menu.st2 {
        padding-bottom: 8px;
        margin-bottom: 0;
        border-bottom: 0;
    }
    .coupon_page_wrap .side_cont_wrap {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 480px) {
    .content_area:has(.coupon_page_wrap) {
        padding: 0 16px 40px 16px;
    }
    .coupon_page_wrap .coupon_register_box {
        flex-wrap: wrap;
    }
    .coupon_page_wrap .coupon_register_box button {
        flex: 1 1 100%;
    }
}
