/**
 * @name: cart.css
 * @description: 購物車頁面樣式
 */

/* =========================================
   進度條
   ========================================= */
.cart-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1rem;
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color, #e9ecef);
}

.cart-step-node {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 auto;
    opacity: 0.45;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.cart-step-node.is-active,
.cart-step-node.is-done {
    opacity: 1;
}

.cart-step-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bs-secondary-bg, #f1f3f5);
    color: var(--bs-secondary-color, #6c757d);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.cart-step-node.is-active .cart-step-icon {
    background: #c30d23;
    color: #fff;
    border-color: rgba(195, 13, 35, 0.25);
    box-shadow: 0 0 0 4px rgba(195, 13, 35, 0.1);
    transform: scale(1.05);
}

.cart-step-node.is-done .cart-step-icon {
    background: #28a745;
    color: #fff;
}

.cart-step-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.cart-step-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.cart-step-sub {
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
}

.cart-step-line {
    flex: 1 1 auto;
    height: 2px;
    background: var(--border-color, #dee2e6);
    margin: 0 0.5rem;
    position: relative;
    top: -10px;
}

.cart-step-node.is-done + .cart-step-line {
    background: #28a745;
}

@media (max-width: 768px) {
    .cart-progress {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .cart-step-line {
        height: 16px;
        width: 2px;
        margin: 0 auto;
    }
    .cart-step-node {
        justify-content: flex-start;
    }
    .cart-step-sub {
        display: none;
    }
}

/* =========================================
   商品列表表格
   ========================================= */
.cart-table-responsive {
    overflow-x: auto;
}

.cart-items-table {
    min-width: 760px;
    margin-bottom: 0;
}

.cart-items-table thead th {
    background: var(--bg-tertiary, #f8f9fa);
    border-bottom: 2px solid var(--border-color, #dee2e6);
    font-size: 0.85rem;
    color: var(--text-secondary, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem;
}

/* Dark mode thead：明確覆寫底色與字色 */
[data-theme="dark"] .cart-items-table thead th {
    background: #2a2a2a;
    color: #d4af37;
    border-bottom-color: #3a3a3a;
}

.cart-items-table td {
    vertical-align: middle;
    padding: 0.75rem;
}

.cart-col-img { width: 80px; }
.cart-col-model { width: 140px; }
.cart-col-qty { width: 130px; }
.cart-col-price { width: 110px; }
.cart-col-total { width: 130px; }
.cart-col-action { width: 100px; }

.cart-item-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 0.375rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.cart-item-model {
    font-weight: 600;
    color: var(--bs-primary, #0d6efd);
}

.cart-item-name {
    color: var(--text-color, #212529);
    line-height: 1.3;
}

.cart-item-note-preview {
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
    margin-top: 0.25rem;
    font-style: italic;
}

/* 數量加減控制已抽離成通用元件 .qty-control，定義在 default.css */

/* 金額 */
.cart-price,
.cart-subtotal {
    font-weight: 600;
}

.cart-subtotal {
    color: #c30d23;
    font-size: 1.05rem;
}

.cart-tbd {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: rgba(255, 193, 7, 0.15);
    color: #b88600;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
}

/* 表格 footer */
.cart-items-table tfoot td {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color, #e9ecef);
    background: var(--bg-tertiary, #fafbfc);
    color: var(--text-primary, #212529);
}

.cart-items-table tfoot .cart-total-row td {
    background: rgba(195, 13, 35, 0.06);
    border-top: 2px solid #c30d23;
    color: var(--text-primary, #212529);
}

/* Dark mode tfoot：背景與文字皆顯式設定，避免白字白底 */
[data-theme="dark"] .cart-items-table tfoot td {
    background: #2a2a2a;
    color: #f0f0f0;
}

[data-theme="dark"] .cart-items-table tfoot .cart-total-row td {
    background: rgba(195, 13, 35, 0.22);
    color: #ffeaa0;
}

/* 操作按鈕 */
.cart-action-btn {
    background: transparent;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 0.375rem;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color, #495057);
    cursor: pointer;
    transition: all 0.15s ease;
    margin: 0 2px;
}

.cart-action-btn:hover {
    background: var(--bs-tertiary-bg, #f1f3f5);
    border-color: var(--bs-primary, #0d6efd);
    color: var(--bs-primary, #0d6efd);
}

.cart-action-btn.is-note-active {
    border-color: #c30d23;
    color: #c30d23;
    background: rgba(195, 13, 35, 0.05);
}

.cart-action-btn.is-remove:hover {
    border-color: #dc3545;
    color: #dc3545;
}

/* =========================================
   報價按鈕：亮綠底 + 黑字
   ========================================= */
.btn-quote {
    background-color: #3ed576;
    border-color: #3ed576;
    color: #000;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn-quote:hover,
.btn-quote:focus {
    background-color: #2bc063;
    border-color: #2bc063;
    color: #000;
    transform: translateY(-1px);
}

.btn-quote:active {
    background-color: #25a956 !important;
    border-color: #25a956 !important;
    color: #000 !important;
    transform: translateY(0);
}

.btn-quote:disabled,
.btn-quote.disabled {
    background-color: #c8e6c9;
    border-color: #c8e6c9;
    color: #555;
    opacity: 0.65;
}

/* =========================================
   付款方式
   ========================================= */
.cart-payment-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cart-payment-option {
    flex: 1 1 200px;
    cursor: pointer;
    margin: 0;
}

.cart-payment-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cart-payment-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color, #dee2e6);
    border-radius: 0.5rem;
    background: var(--card-bg, #fff);
    transition: all 0.2s ease;
}

.cart-payment-card i {
    font-size: 1.75rem;
    color: var(--text-muted, #6c757d);
}

.cart-payment-card span {
    font-weight: 600;
}

.cart-payment-option input[type="radio"]:checked + .cart-payment-card {
    border-color: #c30d23;
    background: rgba(195, 13, 35, 0.04);
    box-shadow: 0 0 0 3px rgba(195, 13, 35, 0.08);
}

.cart-payment-option input[type="radio"]:checked + .cart-payment-card i {
    color: #c30d23;
}

/* =========================================
   訂單摘要 (Step3)
   ========================================= */
.cart-summary {
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color, #e9ecef);
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.95rem;
}

.cart-summary-row.is-total {
    border-top: 1px solid var(--border-color, #dee2e6);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-weight: 700;
    font-size: 1.15rem;
}

.cart-summary-row.is-total .value {
    color: #c30d23;
}

/* =========================================
   法律文件頁尾連結 (服務合約 / 隱私權聲明)
   ========================================= */
.cart-legal-links {
    font-size: 0.9rem;
}

.cart-legal-link {
    color: var(--text-muted, #6c757d);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    transition: color 0.15s ease;
}

.cart-legal-link:hover,
.cart-legal-link:focus {
    color: #c30d23;
    text-decoration: underline;
}

.cart-legal-sep {
    color: var(--text-muted, #ced4da);
    margin: 0 0.25rem;
}

/* =========================================
   合約 Modal (確認購買 / 報價彈窗)
   ========================================= */
/* 視窗整體：modal-dialog 保留 Bootstrap centered 的 min-height（撐滿視口）
   讓 flex align-items: center 自然垂直置中；
   實際視覺尺寸由 modal-content 的 max-height: 60vh 控制，
   超出時由內框「文字框」自帶卷軸顯示，header / footer 不滾動。 */
.cart-contract-modal .modal-content {
    height: auto;
    max-height: 60vh;
    border-radius: 0.6rem;
    border: 1px solid var(--border-color, #e9ecef);
    background: var(--card-bg, #fff);
    overflow: hidden;       /* 子層自行滾動 */
}

.cart-contract-modal .modal-header {
    background: linear-gradient(135deg, rgba(195, 13, 35, 0.06), rgba(195, 13, 35, 0.02));
    border-bottom: 1px solid var(--border-color, #e9ecef);
    padding: 0.75rem 1.25rem;
}

.cart-contract-modal .modal-title {
    color: #c30d23;
    font-weight: 600;
    font-size: 1rem;
}

.cart-contract-modal .modal-body {
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 0;          /* 允許子層 flex 收縮 */
    overflow: hidden;
}

.cart-contract-intro {
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 0;
    padding: 0.55rem 0.75rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-left: 3px solid #c30d23;
    border-radius: 0.3rem;
    flex: 0 0 auto;
}

/* 合約文字框：有邊框、有卷軸，類似 textarea 的視覺效果 */
.cart-contract-box {
    flex: 1 1 auto;
    min-height: 8rem;
    max-height: 32vh;
    overflow-y: auto;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 0.4rem;
    padding: 0.7rem 0.9rem;
    background: var(--bs-tertiary-bg, #fafbfc);
}

.cart-contract-content {
    line-height: 1.55;
    font-size: 0.8rem;
    color: var(--text-color, #212529);
}

.cart-contract-content h1 { font-size: 0.95rem; }
.cart-contract-content h2 { font-size: 0.88rem; }
.cart-contract-content h3 { font-size: 0.82rem; }
.cart-contract-content h4 { font-size: 0.8rem; }

.cart-contract-content h1,
.cart-contract-content h2,
.cart-contract-content h3,
.cart-contract-content h4 {
    margin-top: 0.85rem;
    margin-bottom: 0.35rem;
    color: var(--text-color, #212529);
    font-weight: 600;
}

.cart-contract-content > *:first-child { margin-top: 0; }
.cart-contract-content p { margin-bottom: 0.4rem; }
.cart-contract-content ul,
.cart-contract-content ol { padding-left: 1.35rem; margin-bottom: 0.4rem; }
.cart-contract-content li { margin-bottom: 0.18rem; }

.cart-contract-modal .modal-footer {
    border-top: 1px solid var(--border-color, #e9ecef);
    padding: 0.6rem 1.25rem;
}

.cart-contract-modal .modal-footer .btn {
    font-size: 0.88rem;
    padding: 0.35rem 0.9rem;
}

/* 右側操作按鈕群組（取消 / 同意 / 關閉），與左側列印按鈕分置兩端 */
.cart-contract-footer-actions {
    display: flex;
    gap: 0.5rem;
}

/* dark mode 微調文字框背景 */
[data-theme="dark"] .cart-contract-box {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.12);
}

/* 視窗太矮時（如手機橫向）放寬，避免內容過於擁擠 */
@media (max-height: 600px) {
    .cart-contract-modal .modal-content {
        max-height: 85vh;
    }
    .cart-contract-box {
        max-height: 50vh;
    }
}

[data-theme="dark"] .cart-contract-modal .modal-content {
    background: var(--card-bg);
}

[data-theme="dark"] .cart-contract-modal .modal-header {
    background: linear-gradient(135deg, rgba(195, 13, 35, 0.18), rgba(195, 13, 35, 0.04));
}

[data-theme="dark"] .cart-contract-intro {
    background: rgba(255, 255, 255, 0.04);
}

/* =========================================
   完成頁
   ========================================= */
.cart-order-info {
    display: inline-block;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    text-align: left;
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.cart-order-info .label {
    color: var(--text-muted, #6c757d);
    display: inline-block;
    min-width: 80px;
}

.cart-order-info .value {
    font-weight: 600;
    color: var(--text-color, #212529);
}

/* =========================================
   Dark mode：底色 / 邊框 / 文字一併覆寫
   ========================================= */
[data-theme="dark"] .cart-progress {
    background: #242424;
    border-color: #3a3a3a;
}

[data-theme="dark"] .cart-step-title {
    color: #f0f0f0;
}

[data-theme="dark"] .cart-step-sub {
    color: #a0a0a0;
}

[data-theme="dark"] .cart-step-line {
    background: #3a3a3a;
}

[data-theme="dark"] .cart-step-icon {
    background: #2e2e2e;
    color: #c0c0c0;
}

[data-theme="dark"] .cart-summary {
    background: #242424;
    border-color: #3a3a3a;
    color: #f0f0f0;
}

[data-theme="dark"] .cart-summary-row.is-total {
    border-top-color: #3a3a3a;
}

[data-theme="dark"] .cart-payment-card {
    background: #242424;
    border-color: #3a3a3a;
    color: #f0f0f0;
}

[data-theme="dark"] .cart-payment-card i {
    color: #c0c0c0;
}

[data-theme="dark"] .cart-payment-option input[type="radio"]:checked + .cart-payment-card {
    background: rgba(195, 13, 35, 0.18);
    border-color: #c30d23;
}

[data-theme="dark"] .cart-service-contract-card {
    background: #242424;
    border-color: #3a3a3a;
    color: #f0f0f0;
}

[data-theme="dark"] .cart-order-info {
    background: #242424;
    color: #f0f0f0;
}

[data-theme="dark"] .cart-order-info .label {
    color: #a0a0a0;
}

[data-theme="dark"] .cart-order-info .value {
    color: #f0f0f0;
}

[data-theme="dark"] .cart-items-table tbody td {
    color: #f0f0f0;
}


[data-theme="dark"] .cart-tbd {
    background: rgba(255, 193, 7, 0.18);
    color: #ffd14a;
}

/* User 自訂的合約 modal 也補上 dark 樣式（原本用 --card-bg 不會生效） */
[data-theme="dark"] .cart-contract-modal .modal-content {
    background: #242424;
    color: #f0f0f0;
}

[data-theme="dark"] .cart-contract-intro {
    background: rgba(255, 255, 255, 0.04);
    color: #f0f0f0;
}

[data-theme="dark"] .cart-contract-content,
[data-theme="dark"] .cart-contract-content h1,
[data-theme="dark"] .cart-contract-content h2,
[data-theme="dark"] .cart-contract-content h3,
[data-theme="dark"] .cart-contract-content h4 {
    color: #f0f0f0;
}

[data-theme="dark"] .cart-contract-modal .modal-footer {
    border-top-color: #3a3a3a;
}

/* =========================================
   Step 3：訂單明細表 + 金額明細
   ========================================= */
.cart-step3-table {
    min-width: 600px;
}

.cart-step3-summary {
    max-width: 380px;
    margin-left: auto;
}

.cart-tax-note {
    text-align: right;
}

/* =========================================
   Step 3：付款方式大按鈕
   ========================================= */
.cart-pay-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cart-pay-btn {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.35rem;
    border: 2px solid var(--border-color, #dee2e6);
    border-radius: 0.6rem;
    background: var(--card-bg, #fff);
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.cart-pay-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.cart-pay-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cart-pay-btn-icon {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    background: var(--bs-tertiary-bg, #f1f3f5);
    color: var(--text-muted, #6c757d);
    transition: background 0.18s ease, color 0.18s ease;
}

.cart-pay-btn-body {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.cart-pay-btn-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-color, #212529);
}

.cart-pay-btn-sub {
    font-size: 0.8rem;
    color: var(--text-muted, #6c757d);
}

.cart-pay-btn-spinner {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #c30d23;
}

/* 貨到付款：hover 綠 */
.cart-pay-cod:hover:not(:disabled) {
    border-color: #28a745;
}
.cart-pay-cod:hover:not(:disabled) .cart-pay-btn-icon {
    background: rgba(40, 167, 69, 0.12);
    color: #28a745;
}

/* 刷卡支付：hover 品牌紅 */
.cart-pay-credit:hover:not(:disabled) {
    border-color: #c30d23;
}
.cart-pay-credit:hover:not(:disabled) .cart-pay-btn-icon {
    background: rgba(195, 13, 35, 0.1);
    color: #c30d23;
}

/* =========================================
   貨到付款確認視窗：金額區塊
   ========================================= */
.cart-cod-amount {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--border-color, #e9ecef);
    border-radius: 0.5rem;
}

.cart-cod-amount-label {
    color: var(--text-muted, #6c757d);
    font-size: 0.95rem;
}

.cart-cod-amount-value {
    font-weight: 700;
    font-size: 1.35rem;
    color: #c30d23;
}

/* Step 3 新元件 — Dark mode */
[data-theme="dark"] .cart-pay-btn {
    background: #242424;
    border-color: #3a3a3a;
}
[data-theme="dark"] .cart-pay-btn-title {
    color: #f0f0f0;
}
[data-theme="dark"] .cart-pay-btn-sub {
    color: #a0a0a0;
}
[data-theme="dark"] .cart-pay-btn-icon {
    background: #2e2e2e;
    color: #c0c0c0;
}
[data-theme="dark"] .cart-cod-amount {
    background: #242424;
    border-color: #3a3a3a;
}
[data-theme="dark"] .cart-cod-amount-label {
    color: #a0a0a0;
}

/* ==========================================
   Step 2 使用者訊息 — 左右版面（表單 5/6 + 形象插圖 1/6）
   圖片插入方式同會員申請頁：放圖至 /img/cart/ 即自動顯示
   ========================================== */
.cart-step2-aside {
    /* 與左側表單之間留間距；此欄僅在 lg 以上顯示 (d-lg-flex) */
    padding-left: 1.5rem;
}

/* 圖框：未放圖時顯示品牌漸層預留框 */
.cart-aside-frame {
    flex: 1;
    position: relative;
    min-height: 360px;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(160deg,
        var(--primary-color, #c30d23) 0%,
        rgba(195, 13, 35, 0.62) 58%,
        rgba(195, 13, 35, 0.38) 100%);
}

/* 圖片未放入時的預留說明 */
.cart-aside-ph {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.92);
}
.cart-aside-ph i {
    font-size: 2rem;
    opacity: 0.9;
}
.cart-aside-ph-label {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.45;
}

/* 實際圖片：載入成功後淡入覆蓋預留說明 */
.cart-aside-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.45s ease;
}
.cart-aside-img.loaded {
    opacity: 1;
}

/* 暗色模式：金色品牌漸層 */
[data-theme="dark"] .cart-aside-frame {
    background: linear-gradient(160deg,
        var(--primary-color, #d4af37) 0%,
        rgba(212, 175, 55, 0.55) 58%,
        rgba(212, 175, 55, 0.32) 100%);
}
[data-theme="dark"] .cart-aside-ph {
    color: rgba(20, 20, 20, 0.9);
}
