/**
 * Cart Feature - Table Style CSS
 * 장바구니 표 형식 스타일
 */

/* ===== 장바구니 테이블 ===== */
.cart-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cart-table thead {
    background: #7ED321;
    color: #fff;
}

.cart-table thead th {
    padding: 16px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 2px solid #6FC010;
}

.cart-table tbody tr {
    border-bottom: 1px solid #e5e5e5;
    transition: background-color 0.2s;
}

.cart-table tbody tr:hover {
    background-color: #E8F5D6;
}

.cart-table tbody tr:last-child {
    border-bottom: none;
}

.cart-table td {
    padding: 16px 12px;
    vertical-align: middle;
    text-align: center;
}

/* ===== 컬럼별 스타일 ===== */

/* 이미지 컬럼 */
.col-image {
    width: 60px;
}

.col-image img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e5e5e5;
}

/* 상품명 컬럼 */
.col-product {
    text-align: left;
    min-width: 200px;
}

.col-product .product-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    display: block;
    line-height: 1.4;
}

/* 단가 컬럼 */
.col-price {
    width: 120px;
}

.col-price .price {
    font-size: 14px;
    font-weight: 600;
    color: #7ED321;
}

/* 수량 컬럼 */
.col-quantity {
    width: 140px;
}

.quantity-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px;
    background: #f8f8f8;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #7ED321;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: #6FC010;
    transform: scale(1.05);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-btn i {
    font-size: 10px;
}

.qty-input {
    width: 50px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    pointer-events: none;
}

/* 합계 컬럼 */
.col-total {
    width: 120px;
}

.col-total .item-total {
    font-size: 15px;
    font-weight: 700;
    color: #7ED321;
}

/* 삭제 컬럼 */
.col-actions {
    width: 80px;
}

.btn-remove {
    width: 36px;
    height: 36px;
    border: none;
    background: #dc3545;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #c82333;
    transform: scale(1.1);
}

.btn-remove:active {
    transform: scale(0.95);
}

.btn-remove i {
    font-size: 14px;
}

/* ===== 빈 장바구니 상태 ===== */
.empty-cart-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-cart-state i {
    font-size: 64px;
    margin-bottom: 20px;
    color: #ddd;
}

.empty-cart-state p {
    font-size: 16px;
    margin-bottom: 24px;
}

.continue-shopping-btn {
    display: inline-block;
    padding: 12px 32px;
    background: #7ED321;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.3s;
}

.continue-shopping-btn:hover {
    background: #6FC010;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(126, 211, 33, 0.3);
}

/* ===== 카트 사이드바 스타일 (Desktop) ===== */
/* 데스크탑: 플로팅 오버레이 */
.cart-modal {
    display: none;
    position: fixed;
    top: 130px;
    right: 16px;
    bottom: 16px;
    width: 300px;
    height: calc(100% - 146px);
    background: transparent;
    z-index: 1000;
    pointer-events: none;
}

/* 데스크탑: 플로팅 오버레이 (슬라이드 인/아웃) */
@media (min-width: 1025px) {
    .cart-modal {
        display: block;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    .cart-modal.active {
        transform: translateX(0);
    }
}

.cart-modal.active {
    display: block;
}

.cart-modal-content {
    background: #fff;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
    pointer-events: auto;
}

/* 플로팅 카트 - 레이아웃에 영향 없음 (margin-right 제거됨) */

.cart-modal-close {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #333;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1;
}

.cart-modal-close:hover {
    background: transparent;
    color: #666;
}

.cart-modal-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.cart-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.cart-modal-count {
    position: absolute;
    right: 20px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.cart-modal-items {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #fff;
}

.cart-modal-items::-webkit-scrollbar {
    width: 6px;
}

.cart-modal-items::-webkit-scrollbar-track {
    background: transparent;
}

.cart-modal-items::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.cart-modal-items::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.cart-modal-footer {
    padding: 20px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
}

.cart-modal-total-breakdown {
    margin-bottom: 16px;
}

.cart-modal-subtotal,
.cart-modal-shipping,
.cart-modal-discount {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
    color: #666;
}

.cart-modal-shipping-notice {
    font-size: 12px;
    color: #888;
    text-align: right;
    padding: 4px 0 8px 0;
}

.cart-modal-divider {
    height: 1px;
    background: #e5e5e5;
    margin: 12px 0;
}

.cart-modal-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.total-amount {
    color: #333;
    font-size: 22px;
    font-weight: 700;
}

.checkout-btn {
    width: 100%;
    padding: 14px;
    background: #7ED321;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.checkout-btn:hover {
    background: #6FC010;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(126, 211, 33, 0.3);
}

.checkout-btn:active {
    transform: translateY(0);
}

/* 카트 아이템 스타일 - 2열 레이아웃 */
.cart-item {
    display: flex;
    flex-direction: row;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.cart-item:last-child {
    border-bottom: none;
}

/* 1열: 이미지 + 넘버링 */
.cart-item-col1 {
    position: relative;
    flex-shrink: 0;
}

.cart-item-number {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #7ED321;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    background: #f5f5f5;
}

/* 2열: 상품정보 */
.cart-item-col2 {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 상품명 + 삭제버튼 헤더 */
.cart-item-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.cart-item-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cart-item-remove {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #bbb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.cart-item-remove:hover {
    color: #e74c3c;
}

.cart-item-remove i {
    font-size: 12px;
}

/* 가격 표시 */
.cart-item-unit-price {
    font-size: 11px;
    font-weight: 500;
    color: #888;
}

.cart-item-prices {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cart-item-original-price {
    font-size: 10px;
    color: #999;
    text-decoration: line-through;
}

.cart-item-discounted-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cart-item-current-price {
    font-size: 12px;
    font-weight: 700;
    color: #7ED321;
}

.cart-item-discount-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    color: #5a9e1a;
    background: #E8F5D6;
    padding: 1px 4px;
    border-radius: 3px;
}

/* 수량 + 합계금액 푸터 */
.cart-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.quantity-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f5f5f5;
    border-radius: 6px;
    padding: 2px;
}

.quantity-btn {
    width: 22px;
    height: 22px;
    background: #7ED321;
    color: #fff;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quantity-btn:hover {
    background: #6FC010;
}

.quantity-btn:active {
    transform: scale(0.95);
}

.quantity-btn i {
    font-size: 9px;
}

.quantity-value {
    min-width: 20px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

.cart-item-total-price {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 768px) {
    .cart-table {
        font-size: 12px;
    }

    .cart-table thead th {
        padding: 12px 8px;
        font-size: 12px;
    }

    .cart-table td {
        padding: 12px 8px;
    }

    .col-image {
        width: 50px;
    }

    .col-image img {
        width: 35px;
        height: 35px;
    }

    .col-product {
        min-width: 150px;
    }

    .col-product .product-name {
        font-size: 13px;
    }

    .col-price,
    .col-total {
        width: 100px;
    }

    .col-price .price,
    .col-total .item-total {
        font-size: 13px;
    }

    .col-quantity {
        width: 120px;
    }

    .quantity-controls {
        gap: 6px;
    }

    .qty-btn {
        width: 24px;
        height: 24px;
    }

    .qty-input {
        width: 40px;
        font-size: 13px;
    }

    .col-actions {
        width: 60px;
    }

    .btn-remove {
        width: 32px;
        height: 32px;
    }

    /* 모달 반응형 */
    .cart-modal-content {
        width: 95%;
        min-width: unset;
        max-width: 95%;
        max-height: 90vh;
    }

    .cart-modal-header h3 {
        font-size: 18px;
    }

    .cart-modal-items {
        padding: 0;
    }

    /* 카트 아이템 모바일 */
    .cart-item {
        gap: 10px;
        padding: 14px 10px;
        align-items: center;
    }

    .cart-item-image {
        width: 70px;
        height: 70px;
    }

    .cart-item-content {
        gap: 8px;
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-item-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    .cart-item-controls {
        gap: 8px;
    }

    .quantity-control {
        gap: 6px;
        padding: 3px 6px;
    }

    .quantity-btn {
        width: 26px;
        height: 26px;
    }

    .quantity-btn i {
        font-size: 10px;
    }

    .quantity-value {
        min-width: 28px;
        font-size: 14px;
    }

    .cart-item-total-price {
        font-size: 15px;
        min-width: 70px;
    }

    .cart-item-remove {
        width: 30px;
        height: 30px;
    }

    .cart-item-remove i {
        font-size: 12px;
    }
}

/* ===== ORDER FORM STYLES ===== */

/* Order Form Container */
.order-form-container {
    padding: 16px;
    background: #fff;
}

/* Order Sections */
.order-section {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid #e5e5e5;
}

.order-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.order-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #7ED321;
    margin: 0 0 16px 0;
}

.order-edit-btn {
    padding: 6px 12px;
    background: transparent;
    color: #7ED321;
    border: 1px solid #7ED321;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.order-edit-btn:hover {
    background: #7ED321;
    color: #fff;
}

/* Order Summary Section */
.order-summary-section {
    background: #f9fdf5;
    border-color: #7ED321;
}

.order-summary-items {
    margin-bottom: 16px;
}

.order-summary-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 0 12px 32px;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
}

.order-summary-item:last-child {
    border-bottom: none;
}

.order-item-number {
    position: absolute;
    top: 12px;
    left: 0;
    background: #7ED321;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 메인 라인: 상품명 + 수량 + 금액 - 그리드 레이아웃 */
.order-item-row-main {
    display: grid;
    grid-template-columns: 1fr 60px 100px;
    align-items: center;
    gap: 12px;
}

.order-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-item-quantity {
    font-size: 13px;
    color: #666;
    text-align: center;
}

.order-item-total {
    font-size: 15px;
    font-weight: 700;
    color: #7ED321;
    text-align: right;
}

/* 할인 정보 라인 - 그리드 레이아웃으로 정렬 */
.order-item-row-discount {
    display: grid;
    grid-template-columns: 1fr 60px 100px;
    align-items: center;
    gap: 12px;
    padding-left: 8px;
    font-size: 12px;
    color: #999;
}

.order-item-discount-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.order-item-original-total {
    text-decoration: line-through;
    color: #999;
}

.order-item-arrow {
    color: #7ED321;
    font-weight: 600;
}

.order-item-discounted-total {
    color: #e74c3c;
    font-weight: 600;
}

.order-item-discount-badge {
    display: inline-block;
    background: #E8F5D6;
    color: #7ED321;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
}

.order-summary-totals {
    padding-top: 12px;
    border-top: 2px solid #7ED321;
}

.order-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    color: #666;
}

.order-final-total {
    font-size: 18px;
    font-weight: 700;
    color: #7ED321;
    padding-top: 10px;
}

/* Address Section */
.order-address-display {
    padding: 16px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-address-recipient,
.order-address-location {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.order-address-recipient i,
.order-address-location i {
    color: #7ED321;
    width: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.order-address-recipient span {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.order-address-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-address-line {
    font-size: 14px;
    color: #666;
    display: block;
}

.order-address-line-en {
    font-size: 12px;
    color: #888;
}

.order-address-zip {
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

/* Legacy classes (for backward compatibility) */
.address-recipient {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
}

.address-line {
    font-size: 14px;
    color: #666;
    margin: 4px 0;
}

.address-zip {
    font-size: 13px;
    color: #999;
    margin-top: 8px;
}

.order-no-address {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
    background: #f9f9f9;
    border-radius: 6px;
    margin: 0;
}

/* Payment Section */
.order-payment-section {
    background: #fffbf0;
    border: 2px solid #d4af37;
}

.payment-options {
    display: flex;
    gap: 8px;
}

.payment-option {
    flex: 1 1 0;
    width: 0;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: #fff;
    border: 2px solid #e5e5e5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.payment-option:hover {
    border-color: #7ED321;
    background: #f9fdf5;
}

.payment-option.selected {
    border-color: #7ED321;
    background: #f9fdf5;
    box-shadow: 0 2px 8px rgba(126, 211, 33, 0.15);
}

.payment-option.disabled {
    background: #f5f5f5;
    border-color: #ddd;
    cursor: not-allowed;
    opacity: 0.6;
}

.payment-option.disabled:hover {
    border-color: #ddd;
    background: #f5f5f5;
}

.payment-option input[type="radio"] {
    display: none;
}

.payment-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
}

.payment-label i {
    font-size: 18px;
    color: #7ED321;
}

.payment-text {
    font-size: 10px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.payment-option.disabled .payment-text {
    color: #999;
}

.payment-option.disabled .payment-label i {
    color: #999;
}

/* Order Details Form */
.order-form-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.order-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-form-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.order-form-label .required {
    color: #dc3545;
    margin-left: 4px;
}

.order-form-input,
.order-form-textarea {
    padding: 12px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    transition: all 0.2s ease;
    font-family: inherit;
}

.order-form-input:focus,
.order-form-textarea:focus {
    outline: none;
    border-color: #7ED321;
    box-shadow: 0 0 0 3px rgba(126, 211, 33, 0.1);
}

.order-form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Order Form Footer */
.order-form-footer {
    display: flex;
    gap: 12px;
    padding: 0;
}

.order-cancel-btn,
.order-submit-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.order-cancel-btn {
    background: #fff;
    color: #666;
    border: 2px solid #e5e5e5;
}

.order-cancel-btn:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #333;
}

.order-submit-btn {
    background: #7ED321;
    color: #fff;
}

.order-submit-btn:hover {
    background: #6FC010;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(126, 211, 33, 0.3);
}

.order-submit-btn:active {
    transform: translateY(0);
}

.order-submit-btn:disabled {
    background: #999;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .order-form-container {
        padding: 12px;
    }

    .order-section {
        padding: 16px;
        margin-bottom: 12px;
    }

    .order-section-title {
        font-size: 15px;
    }

    .payment-options {
        flex-direction: column;
        gap: 10px;
    }

    .order-form-footer {
        flex-direction: column;
    }

    .order-final-total {
        font-size: 16px;
    }
}

/* ===== 카트 사이드바 반응형 (태블릿/모바일) ===== */

/* 태블릿 - 사이드바 숨기고 모달로 전환 */
@media (max-width: 1024px) {
    /* 사이드바 숨김 */
    .cart-modal {
        display: none;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        pointer-events: auto;
    }

    .cart-modal.active {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .cart-modal-content {
        width: 90%;
        max-width: 500px;
        height: auto;
        max-height: 80vh;
        border-radius: 16px;
        border: none;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    }

    /* 메인 콘텐츠 원래대로 */
    body main {
        margin-right: 0 !important;
    }

    body .main-footer {
        margin-right: 0 !important;
    }
}

/* 모바일 - 바텀 시트 스타일 */
@media (max-width: 768px) {
    .cart-modal.active {
        align-items: flex-end;
    }

    .cart-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }

    .cart-modal-header {
        padding: 20px 16px 12px;
    }

    .cart-modal-header h3 {
        font-size: 18px;
    }

    .cart-modal-footer {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* 특정 페이지에서 사이드바 숨김 */
body.mypage-page .cart-modal,
body.order-page .cart-modal,
body.orders-page .cart-modal,
body.addresses-page .cart-modal,
body.profile-page .cart-modal,
body.balance-page .cart-modal,
body.rewards-page .cart-modal,
body.coupons-page .cart-modal,
body.close-account-page .cart-modal {
    display: none;
}

body.mypage-page .cart-modal.active,
body.order-page .cart-modal.active,
body.orders-page .cart-modal.active,
body.addresses-page .cart-modal.active,
body.profile-page .cart-modal.active,
body.balance-page .cart-modal.active,
body.rewards-page .cart-modal.active,
body.coupons-page .cart-modal.active,
body.close-account-page .cart-modal.active {
    display: flex;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

body.mypage-page .cart-modal.active .cart-modal-content,
body.order-page .cart-modal.active .cart-modal-content,
body.orders-page .cart-modal.active .cart-modal-content,
body.addresses-page .cart-modal.active .cart-modal-content,
body.profile-page .cart-modal.active .cart-modal-content,
body.balance-page .cart-modal.active .cart-modal-content,
body.rewards-page .cart-modal.active .cart-modal-content,
body.coupons-page .cart-modal.active .cart-modal-content,
body.close-account-page .cart-modal.active .cart-modal-content {
    width: 90%;
    max-width: 500px;
    height: auto;
    max-height: 80vh;
    border-radius: 12px;
}

/* ===== 결제 모달 (카트 사이드바 위에 동일한 위치/크기) ===== */
.checkout-modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 2000;
    display: block;
}

.checkout-modal-overlay {
    display: none;
}

.checkout-modal-content {
    background: #fff;
    width: 100%;
    height: 100%;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    border: none;
}

.checkout-modal-close {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #333;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.checkout-modal-close:hover {
    background: transparent;
    color: #666;
}

.checkout-modal-body {
    flex: 1;
    overflow-y: auto;
}

.checkout-modal-body::-webkit-scrollbar {
    width: 6px;
}

.checkout-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.checkout-modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.checkout-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* === Checkout Header === */
.checkout-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.back-to-cart-btn {
    position: absolute;
    left: 20px;
    background: transparent;
    border: none;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    transition: all 0.2s;
}

.back-to-cart-btn:hover {
    background: transparent;
    color: #666;
}

.checkout-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

/* === Order Sections === */
.order-form-container {
    padding: 0;
}

.order-section {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.order-section:last-of-type {
    border-bottom: none;
}

.order-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Order Summary Items === */
.order-summary-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.order-summary-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-summary-item img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: #f5f5f5;
}

.order-item-info {
    flex: 1;
    min-width: 0;
}

.order-item-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-item-qty {
    font-size: 12px;
    color: #888;
}

.order-item-price {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* === Order Totals === */
.order-totals {
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
}

.order-total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    color: #666;
}

.order-total-row.total {
    border-top: 1px solid #e5e5e5;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

/* === Delivery Address === */
.selected-address {
    display: flex;
    gap: 12px;
    background: #f8f9fa;
    padding: 16px;
    border-radius: 10px;
}

.address-info {
    flex: 1;
}

.address-info strong {
    display: block;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
}

.address-info span {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.address-info p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.change-address-btn {
    align-self: flex-start;
    background: #7ED321;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.change-address-btn:hover {
    background: #6FC010;
}

.no-address {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.no-address p {
    margin: 0 0 12px 0;
    color: #666;
}

.add-address-btn {
    background: #7ED321;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.add-address-btn:hover {
    background: #6FC010;
}

/* === Payment Options === */
.payment-options {
    display: flex;
    gap: 12px;
}

.payment-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.payment-option input {
    display: none;
}

.payment-option i {
    font-size: 24px;
    color: #888;
}

.payment-option span {
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.payment-option.selected {
    border-color: #7ED321;
    background: #E8F5D6;
}

.payment-option.selected i,
.payment-option.selected span {
    color: #5a9e1a;
}

/* === Order Notes === */
.order-notes {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.order-notes:focus {
    outline: none;
    border-color: #7ED321;
}

/* === Submit Button === */
.order-submit-section {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e5e5e5;
}

.submit-order-btn {
    width: 100%;
    padding: 16px;
    background: #7ED321;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.submit-order-btn:hover {
    background: #6FC010;
}

.submit-order-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* === Checkout Back Header === */
.checkout-back-header {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
}

.checkout-back-header .order-cancel-btn {
    flex: none;
    width: auto;
    padding: 10px 16px;
}

/* === Checkout Modal Order Form Overrides === */
#checkoutModal .order-form-container {
    padding: 0;
}

#checkoutModal .order-section {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    border-bottom: 1px solid #f0f0f0;
}

#checkoutModal .order-section:last-of-type {
    border-bottom: none;
}

#checkoutModal .order-summary-section {
    background: #fff;
}

/* === 결제 모달 주문 아이템 2열 레이아웃 === */
#checkoutModal .order-summary-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

#checkoutModal .order-summary-item:last-child {
    border-bottom: none;
}

/* 1열: 이미지 */
#checkoutModal .order-item-image-wrap {
    position: relative;
    flex-shrink: 0;
}

#checkoutModal .order-item-number {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #7ED321;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#checkoutModal .order-item-image {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
}

/* 2열: 상품정보 (세로로 2행 배치) */
#checkoutModal .order-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 2열 1행: 상품명 */
#checkoutModal .order-item-name {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 2열 2행: 수량 + 가격 */
#checkoutModal .order-item-row2 {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
}

#checkoutModal .order-item-quantity {
    font-size: 12px;
    color: #666;
}

#checkoutModal .order-item-total {
    font-size: 13px;
    font-weight: 700;
    color: #7ED321;
}

#checkoutModal .order-item-row-discount {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    font-size: 10px;
}

#checkoutModal .order-payment-section {
    background: #fff;
    border: none;
}

#checkoutModal .checkout-modal-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e5e5e5;
}

#checkoutModal .order-submit-btn {
    width: 100%;
}

/* === Checkout Modal Responsive (태블릿/모바일) === */
@media (max-width: 1024px) {
    .checkout-modal {
        top: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, 0.5);
    }

    .checkout-modal-overlay {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
    }

    .checkout-modal-content {
        width: 90%;
        max-width: 500px;
        height: auto;
        max-height: 80vh;
        border-radius: 16px;
    }
}

@media (max-width: 768px) {
    .checkout-modal {
        align-items: flex-end;
    }

    .checkout-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }

    .checkout-header {
        padding: 16px;
    }

    .order-section {
        padding: 16px;
    }

}
