/**
 * 토스페이먼츠 공통 스타일
 *
 * 상품 페이지, 장바구니, 마이페이지 등에서 사용
 *
 * @package Terra_TossPay
 */

/* =============================================================================
   테마 색상 오버라이드 (토스 디자인 시스템)
   ============================================================================= */
:root {
    /* Elementor 전역 색상 */
    --e-global-color-primary: #191F28 !important;
    --e-global-color-secondary: #191F28 !important;
    --e-global-color-text: #333D4B !important;
    --e-global-color-accent: #191F28 !important;
    /* WordPress 색상 */
    --wp--preset--color--primary: #191F28 !important;
    --wp--preset--color--secondary: #191F28 !important;
    --wp--preset--color--vivid-red: #191F28 !important;
    --wp--preset--color--luminous-vivid-orange: #191F28 !important;
    /* Hello Elementor 테마 색상 */
    --hello-elementor-color: #191F28 !important;
}

/* =============================================================================
   Hello Elementor 테마 기본 분홍색(#c36) 오버라이드 → 검은색
   (Elementor에서 수정 시 덮어씌워짐)
   ============================================================================= */
/* 모든 링크 색상 - 테마 기본값보다 높은 우선순위 */
html body a,
html body a:link,
html body a:visited {
    color: #191F28;
}

html body a:hover,
html body a:active,
html body a:focus {
    color: #4E5968;
}

/* 버튼 색상 (테마 기본) */
html body button:not(.woocommerce button):not([class*="elementor"]),
html body [type="button"]:not(.woocommerce [type="button"]),
html body [type="submit"]:not(.woocommerce [type="submit"]) {
    border-color: #191F28;
    color: #191F28;
}

html body button:not(.woocommerce button):not([class*="elementor"]):hover,
html body button:not(.woocommerce button):not([class*="elementor"]):focus,
html body [type="button"]:not(.woocommerce [type="button"]):hover,
html body [type="submit"]:not(.woocommerce [type="submit"]):hover {
    background-color: #191F28;
    color: #fff;
}

/* 사이트 헤더 - 사이트명, 메뉴 */
html body .site-header a,
html body .site-branding a,
html body .site-title a,
html body .main-navigation a,
html body .menu-item a,
html body header a,
html body nav a {
    color: #191F28;
}

html body .site-header a:hover,
html body .main-navigation a:hover,
html body .menu-item a:hover,
html body header a:hover,
html body nav a:hover {
    color: #4E5968;
}

/* WooCommerce 카테고리, 태그 링크 */
html body .woocommerce .posted_in a,
html body .woocommerce .tagged_as a,
html body .woocommerce-product-details__short-description a,
html body .product_meta a,
html body .woocommerce-breadcrumb a {
    color: #191F28;
}

html body .woocommerce .posted_in a:hover,
html body .woocommerce .tagged_as a:hover,
html body .product_meta a:hover,
html body .woocommerce-breadcrumb a:hover {
    color: #4E5968;
}

/* 상품평 링크 */
html body .woocommerce-review-link,
html body .woocommerce-Reviews-title a,
html body .woocommerce-review__author {
    color: #191F28;
}

/* 푸터 링크 */
html body .site-footer a,
html body footer a {
    color: #191F28;
}

html body .site-footer a:hover,
html body footer a:hover {
    color: #4E5968;
}

/* =============================================================================
   Hello Elementor 테마 전역 색상 오버라이드 (WooCommerce 콘텐츠 영역만)
   ============================================================================= */
/* WooCommerce 콘텐츠 내 일반 링크만 (버튼, 네비게이션 제외) */
body.woocommerce-page .woocommerce-MyAccount-content a:not(.button):not(.checkout-button),
body.woocommerce-cart .woocommerce a:not(.button):not(.checkout-button),
body.woocommerce-checkout .woocommerce a:not(.button):not(.checkout-button) {
    color: #0064FF !important;
}

body.woocommerce-page .woocommerce-MyAccount-content a:not(.button):not(.checkout-button):hover,
body.woocommerce-cart .woocommerce a:not(.button):not(.checkout-button):hover,
body.woocommerce-checkout .woocommerce a:not(.button):not(.checkout-button):hover {
    color: #0050CC !important;
}

/* 버튼 링크는 반드시 흰색 글자 */
.woocommerce a.button,
.woocommerce a.button.alt,
.woocommerce-account .woocommerce a.button,
.woocommerce-account .button,
.woocommerce-account a.button {
    color: #fff !important;
}

.woocommerce a.button:hover,
.woocommerce a.button.alt:hover,
.woocommerce-account .woocommerce a.button:hover,
.woocommerce-account .button:hover,
.woocommerce-account a.button:hover {
    color: #fff !important;
}

/* 모든 버튼 */
body.woocommerce-page button,
body.woocommerce-page input[type="submit"],
body.woocommerce-cart button,
body.woocommerce-cart input[type="submit"],
body.woocommerce-checkout button,
body.woocommerce-checkout input[type="submit"],
body.woocommerce-account button,
body.woocommerce-account input[type="submit"] {
    background-color: #0064FF !important;
    border-color: #0064FF !important;
    color: #fff !important;
}

body.woocommerce-page button:hover,
body.woocommerce-page input[type="submit"]:hover,
body.woocommerce-cart button:hover,
body.woocommerce-cart input[type="submit"]:hover,
body.woocommerce-checkout button:hover,
body.woocommerce-checkout input[type="submit"]:hover,
body.woocommerce-account button:hover,
body.woocommerce-account input[type="submit"]:hover {
    background-color: #0050CC !important;
    border-color: #0050CC !important;
    color: #fff !important;
}

/* WooCommerce 버튼 (모든 상황) */
.woocommerce a.button,
.woocommerce a.button.alt,
.woocommerce button.button,
.woocommerce button.button.alt,
.woocommerce input.button,
.woocommerce input.button.alt,
.woocommerce #respond input#submit,
.woocommerce #respond input#submit.alt,
.woocommerce .cart .button,
.woocommerce .checkout-button,
.woocommerce a.checkout-button,
.wc-proceed-to-checkout a.checkout-button,
.woocommerce #place_order,
.woocommerce-cart .wc-proceed-to-checkout a.checkout-button,
.woocommerce-page a.button,
.woocommerce-page button.button,
.woocommerce-page input.button {
    background-color: #0064FF !important;
    background: linear-gradient(135deg, #0064FF 0%, #0050CC 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
}

.woocommerce a.button:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button:hover,
.woocommerce button.button.alt:hover,
.woocommerce input.button:hover,
.woocommerce input.button.alt:hover,
.woocommerce #respond input#submit:hover,
.woocommerce .cart .button:hover,
.woocommerce .checkout-button:hover,
.woocommerce a.checkout-button:hover,
.wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce #place_order:hover,
.woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce-page a.button:hover,
.woocommerce-page button.button:hover,
.woocommerce-page input.button:hover {
    background-color: #0050CC !important;
    background: linear-gradient(135deg, #0050CC 0%, #003d99 100%) !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 100, 255, 0.3) !important;
}

/* WooCommerce 가격 색상 (장바구니, 체크아웃만 파란색) */
.woocommerce-cart .price,
.woocommerce-cart .amount,
.woocommerce-checkout .price,
.woocommerce-checkout .amount {
    color: #0064FF !important;
}

/* 연관 상품, 상품 목록 가격 - 통일된 스타일 */
.woocommerce .related .price,
.woocommerce .upsells .price,
.woocommerce .cross-sells .price,
.woocommerce ul.products .price,
.wc-block-grid .wc-block-grid__product-price {
    font-size: 0.875em;
    font-weight: 700;
    color: #191F28 !important;
}

/* 금액 부분만 굵게 */
.woocommerce .related .price .woocommerce-Price-amount,
.woocommerce .upsells .price .woocommerce-Price-amount,
.woocommerce .cross-sells .price .woocommerce-Price-amount,
.woocommerce ul.products .price .woocommerce-Price-amount,
.wc-block-grid .wc-block-grid__product-price .woocommerce-Price-amount {
    font-weight: 700;
    color: #0064FF !important;
}

/* 월, 연, 첫결제 등 단위/라벨 글자 - 연한색 통일 */
.woocommerce ul.products .price small,
.woocommerce .related .price small,
.tosspay-price-dual small,
.tosspay-price-single small,
.tosspay-recurring-price small,
.tosspay-initial-price strong,
.tosspay-recurring-price small {
    font-weight: 400 !important;
    color: #8B95A1 !important;
}

/* 기존 스타일 유지용 */
.woocommerce .related .amount,
.woocommerce .upsells .amount,
.woocommerce .cross-sells .amount,
.woocommerce ul.products .amount,
.wc-block-grid .wc-block-grid__product-price {
    color: #191F28 !important;
}

/* =============================================================================
   상품 페이지 구독 가격 표시 (첫결제/이후)
   ============================================================================= */
/* 전체 텍스트 기본 검은색 */
.tosspay-initial-price,
.tosspay-recurring-price,
.tosspay-price-single,
.tosspay-price-dual {
    color: #191F28 !important;
}

/* 가격 부분 - 파란색, 굵게 */
.tosspay-initial-price .woocommerce-Price-amount,
.tosspay-recurring-price .woocommerce-Price-amount,
.tosspay-price-single .woocommerce-Price-amount,
.tosspay-price-dual .woocommerce-Price-amount {
    color: #0064FF !important;
    font-weight: 700;
}

/* 단위(/월, /연) - 연한색 */
.tosspay-price-single small,
.tosspay-price-dual small,
.tosspay-recurring-price small {
    color: #8B95A1 !important;
    font-weight: 400 !important;
}

/* "첫결제" 라벨 스타일 - 월/연과 통일 */
.tosspay-initial-price strong {
    color: #8B95A1 !important;
    font-weight: 400 !important;
    margin-right: 4px;
}

/* "이후" 텍스트 스타일 */
.tosspay-recurring-price small {
    color: #6B7684;
    font-size: 13px;
}

/* 쿠폰 적용 버튼 */
.woocommerce .coupon button,
.woocommerce .coupon input[type="submit"],
.woocommerce-cart .coupon button {
    background-color: #0064FF !important;
    background: #0064FF !important;
    color: #fff !important;
}

/* 장바구니 업데이트 버튼 */
.woocommerce button[name="update_cart"],
.woocommerce-cart button[name="update_cart"] {
    background: #f2f4f6 !important;
    color: #333 !important;
    border: 1px solid #e5e8eb !important;
}

.woocommerce button[name="update_cart"]:hover,
.woocommerce-cart button[name="update_cart"]:hover {
    background: #e5e8eb !important;
    color: #000 !important;
}


/* =============================================================================
   결제 컨테이너
   ============================================================================= */
#tosspay-payment-container,
#tosspay-billing-container {
    text-align: center;
    padding: 30px;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
}

#tosspay-billing-container h3 {
    margin-bottom: 10px;
}

#tosspay-billing-container p {
    color: #666;
    margin-bottom: 20px;
}

#tosspay-billing-button {
    background: #0064ff;
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#tosspay-billing-button:hover {
    background: #0050cc;
}

/* =============================================================================
   바로구매 버튼
   ============================================================================= */
.wp-block-woocommerce-add-to-cart-form form.cart:has(.tosspay-buy-now-button) {
    grid-template-columns: min-content max-content max-content;
}

.wp-block-woocommerce-add-to-cart-form form.cart > .tosspay-buy-now-button {
    grid-column: 3 / 4;
    grid-row: 1;
    justify-self: start;
}

.tosspay-buy-now-button.wp-element-button {
    background-color: #0064ff !important;
    color: #fff !important;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tosspay-buy-now-button.wp-element-button:hover {
    background-color: #0050cc !important;
    color: #fff !important;
}

/* 바로구매 버튼 (연관상품/목록) */
.wc-block-product .tosspay-buy-now-loop.wp-element-button {
    background-color: #0064ff !important;
    color: #fff !important;
    text-decoration: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    width: fit-content;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    border-radius: 4px;
}

.wc-block-product .tosspay-buy-now-loop.wp-element-button:hover {
    background-color: #0050cc !important;
    color: #fff !important;
}

/* =============================================================================
   구독 정보 표시
   ============================================================================= */
.tosspay-subscription-info {
    background: #f0f7ff;
    border: 1px solid #cce0ff;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
}

.tosspay-subscription-info p {
    margin: 5px 0;
}

.tosspay-subscription-info .subscription-period {
    font-size: 16px;
}

.tosspay-subscription-info .subscription-trial {
    color: #0064ff;
    font-size: 14px;
}

/* =============================================================================
   장바구니 구독 표시
   ============================================================================= */
.cart_item .variation dt {
    font-weight: 600;
    color: #333;
}

.cart_item .variation dd p {
    margin: 0;
    color: #0064ff;
}

/* =============================================================================
   결제수단 라벨
   ============================================================================= */
.payment_method_tosspay label,
.payment_method_tosspay_billing label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.payment_method_tosspay img,
.payment_method_tosspay_billing img {
    max-height: 24px;
    width: auto;
}

/* 정기결제 설명 박스 */
.payment_box.payment_method_tosspay_billing {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%) !important;
    border: 1px solid #d0e3ff !important;
    border-radius: 8px !important;
    padding: 16px 20px !important;
    margin-top: 12px !important;
}

.payment_box.payment_method_tosspay_billing::before {
    display: none !important;
}

.payment_box.payment_method_tosspay_billing p {
    margin: 0;
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 10px;
}

.payment_box.payment_method_tosspay_billing p::before {
    content: "💳";
    font-size: 20px;
}

/* =============================================================================
   로딩 상태
   ============================================================================= */
.tosspay-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0064ff;
    border-radius: 50%;
    animation: tosspay-spin 1s linear infinite;
}

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

/* =============================================================================
   구독 상태 배지
   ============================================================================= */
.subscription-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-trial {
    background-color: #fff3cd;
    color: #856404;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
}

.status-paused {
    background-color: #e2e3e5;
    color: #383d41;
}

.status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

.status-expired {
    background-color: #d6d8db;
    color: #1b1e21;
}

/* =============================================================================
   구독 액션 버튼
   ============================================================================= */
.subscription-action {
    margin-right: 5px;
    padding: 5px 10px !important;
    font-size: 12px !important;
}

/* =============================================================================
   상품 페이지 수량 입력
   ============================================================================= */
.woocommerce div.product form.cart .quantity,
.woocommerce .quantity {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e5e8eb;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    height: 48px;
}

.woocommerce div.product form.cart .quantity .qty,
.woocommerce .quantity .qty {
    width: 44px;
    height: 100%;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: #191F28;
    -moz-appearance: textfield;
    appearance: textfield;
    padding: 0;
    margin: 0;
}

.woocommerce div.product form.cart .quantity .qty::-webkit-outer-spin-button,
.woocommerce div.product form.cart .quantity .qty::-webkit-inner-spin-button,
.woocommerce .quantity .qty::-webkit-outer-spin-button,
.woocommerce .quantity .qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.woocommerce div.product form.cart .quantity .qty:focus,
.woocommerce .quantity .qty:focus {
    outline: none;
}

/* 수량 버튼 (+/-) */
.woocommerce .quantity button,
.woocommerce .quantity .minus,
.woocommerce .quantity .plus {
    width: 36px;
    height: 100%;
    background: #f8f9fa !important;
    border: none !important;
    color: #4E5968 !important;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1;
}

.woocommerce .quantity button:hover,
.woocommerce .quantity .minus:hover,
.woocommerce .quantity .plus:hover {
    background: #e5e8eb !important;
    color: #191F28 !important;
}

.woocommerce .quantity .minus {
    border-right: 1px solid #e5e8eb !important;
}

.woocommerce .quantity .plus {
    border-left: 1px solid #e5e8eb !important;
}

/* 장바구니/바로구매 버튼과 높이 맞춤 */
.woocommerce div.product form.cart button.single_add_to_cart_button,
.woocommerce div.product form.cart .tosspay-buy-now-button {
    height: 48px;
    line-height: 48px;
    padding: 0 24px !important;
}

/* =============================================================================
   상품평 별점 (노란색)
   ============================================================================= */
.woocommerce .star-rating,
.woocommerce .star-rating span,
.woocommerce p.stars a,
.woocommerce .woocommerce-product-rating .star-rating,
.comment-form-rating .stars a {
    color: #FFB800 !important;
}

/* 별점 before/after 색상 */
.woocommerce .star-rating::before,
.woocommerce .star-rating span::before {
    color: #FFB800 !important;
}

/* 빈 별 (배경) */
.woocommerce .star-rating::before {
    color: #e0e0e0 !important;
}

/* 채워진 별 */
.woocommerce .star-rating span::before {
    color: #FFB800 !important;
}

/* 리뷰 작성 시 별 선택 */
.woocommerce p.stars a::before,
.woocommerce p.stars a:hover ~ a::before,
.woocommerce p.stars.selected a.active ~ a::before {
    color: #e0e0e0 !important;
}

.woocommerce p.stars:hover a::before,
.woocommerce p.stars.selected a.active::before,
.woocommerce p.stars.selected a:not(.active)::before {
    color: #FFB800 !important;
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 768px) {
    .subscription-action {
        display: block;
        margin: 5px 0;
        width: 100%;
    }

    .woocommerce div.product form.cart .quantity,
    .woocommerce .quantity {
        height: 42px;
    }

    .woocommerce div.product form.cart .quantity .qty,
    .woocommerce .quantity .qty {
        width: 36px;
        font-size: 14px;
    }

    .woocommerce .quantity button,
    .woocommerce .quantity .minus,
    .woocommerce .quantity .plus {
        width: 32px;
        font-size: 14px;
    }

    .woocommerce div.product form.cart button.single_add_to_cart_button,
    .woocommerce div.product form.cart .tosspay-buy-now-button {
        height: 42px;
        line-height: 42px;
        padding: 0 16px !important;
        font-size: 14px;
    }
}

/* =============================================================================
   샵 페이지 - 정기결제 상품 (장바구니/바로구매 버튼)
   ============================================================================= */
/* 버튼 컨테이너 */
.tosspay-period-buttons {
    display: inline-flex;
    gap: 6px;
}

/* 장바구니/바로구매 버튼 - 기존 WooCommerce 버튼과 동일 */
.woocommerce ul.products li.product .tosspay-period-buttons a.button,
.woocommerce ul.products li.product .tosspay-period-buttons .button,
.tosspay-period-buttons a.button,
.tosspay-period-buttons .button {
    display: inline-block;
    font-size: inherit !important;
    font-weight: 700 !important;
    line-height: inherit !important;
    padding: calc(0.667em + 2px) calc(1.333em + 2px) !important;
    cursor: pointer;
    text-decoration: none !important;
    background-color: #0064FF !important;
    background: linear-gradient(135deg, #0064FF 0%, #0050CC 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    margin-top: 0 !important;
}

.woocommerce ul.products li.product .tosspay-period-buttons a.button:hover,
.woocommerce ul.products li.product .tosspay-period-buttons .button:hover,
.tosspay-period-buttons a.button:hover,
.tosspay-period-buttons .button:hover {
    background: linear-gradient(135deg, #0050CC 0%, #003d99 100%) !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 100, 255, 0.3) !important;
}

/* 가격 구분선 */
.tosspay-price-dual .tosspay-price-divider {
    color: #ccc;
    margin: 0 4px;
}

/* 정기결제 가격 표시 - 다른 상품과 동일 */
.woocommerce ul.products li.product .tosspay-price-dual,
.woocommerce ul.products li.product .tosspay-price-single,
.woocommerce ul.products li.product .tosspay-recurring-price {
    display: block;
    font-size: 0.875em;
    font-weight: 700;
    line-height: 1.5;
    color: #191F28 !important;
}

.woocommerce ul.products li.product .tosspay-price-dual .woocommerce-Price-amount,
.woocommerce ul.products li.product .tosspay-price-single .woocommerce-Price-amount,
.woocommerce ul.products li.product .tosspay-recurring-price .woocommerce-Price-amount {
    font-weight: 700;
    color: #0064FF !important;
}

/* 첫결제 가격 표시 */
.tosspay-price-dual .tosspay-initial-label {
    font-size: 12px;
    color: #0064ff;
    font-weight: 600;
}
