* {
    box-sizing: border-box;
}

/* ============================================
   購物車頁面樣式
   ============================================ */

.cart-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 40px 15px 80px;
}

.cart-header-action{
    text-align: center;
}

.subtotal-cash.hide,.subtotal-token.hide,.subtotal-plus.hide{
    display: none !important;
}

/* 頁面標題 */
.page-header {
    margin-bottom: 20px;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 500;
}

.breadcrumb-nav a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-nav a:hover {
    color: #CC0303;
}

.breadcrumb-nav .separator {
    color: #999;
    margin: 0 4px;
}

.breadcrumb-nav .current {
    color: #1a1a1a;
    font-weight: 500;
}

.page-title {
    font-size: 42px;
    font-weight: 600;
    color: #000;
    margin: 0;
    position: relative;
    padding-bottom: 20px;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, #CC0303, transparent);
    border-radius: 2px;
}

/* 購物車內容區域 */
.cart-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* 購物車商品列表區域 */
.cart-items-section {
    flex: 1;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cart-items-header {
    display: grid;
    grid-template-columns: 30px 6fr 3fr 1.5fr 1.5fr;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 2px solid #f0f0f0;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    align-items: center;
}

.cart-header-checkbox {
    display: flex;
    align-items: center;
}

.cart-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    user-select: none;
}

.cart-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #CC0303;
    flex: 1;
}

.cart-items-list {
    min-height: 200px;
}

/* 購物車商品項目 */
.cart-item {
    display: grid;
    grid-template-columns: 30px 6fr 3fr 1.5fr 1.5fr;
    gap: 20px;
    padding: 24px 0;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
    transition: background 0.3s ease;
}

.cart-item:hover {
    background: rgba(204, 3, 3, 0.02);
}

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

.cart-item-checkbox {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.cart-item-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #CC0303;
    border-radius: 5px;
}

.cart-item-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.cart-item-image {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f5f5f5;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.cart-item-name {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.4;
    margin: 0;
}

.cart-item-name a {
    color: #1a1a1a;
    text-decoration: none;
    transition: color 0.3s ease;
}

.cart-item-name a:hover {
    color: #CC0303;
}

.cart-item-spec {
    font-size: 14px;
    color: #666;
    display: flex;
    gap: 12px;
}

.cart-item-spec span {
    display: inline-block;
}

.cart-item-price {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 3px;
}

.cart-item-price img{
    width: 26px;
    height: 26px;
    margin-bottom: 3px;
}

/* 桌面端：价格数量行包装器（保持原有布局） */
.cart-item-price-quantity-row {
    display: contents;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.quantity-control-cart {
    display: flex;
    align-items: center;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.quantity-btn-cart {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn-cart:hover {
    background: #CC0303;
    color: #fff;
}

.quantity-input-cart {
    width: 50px;
    height: 32px;
    border: none;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    outline: none;
}

.cart-item-subtotal {
    font-size: 16px;
    font-weight: 600;
    color: #CC0303;
    display: flex;
    align-items: center;
    gap: 3px;
}

.cart-item-subtotal img{
    width: 26px;
    height: 26px;
    margin-bottom: 3px;
}

.cart-item-action {
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-item-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.delete-item-btn:hover {
    background: #fee;
    color: #CC0303;
}

.delete-item-btn svg {
    width: 18px;
    height: 18px;
}

/* 空購物車 */
.cart-empty {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    margin-bottom: 24px;
    opacity: 0.5;
}

.empty-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
}

.empty-desc {
    font-size: 16px;
    color: #666;
    margin: 0 0 32px 0;
}

.empty-btn {
    display: inline-block;
    padding: 12px 32px;
    background: #CC0303;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.empty-btn:hover {
    background: #a00202;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(204, 3, 3, 0.3);
    color: #fff;
}

/* 購物車結算區域 */
.cart-summary-section {
    width: 360px;
    flex-shrink: 0;
}

.cart-summary-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 100px;
}

.summary-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 24px 0;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
}

.summary-content {
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 15px;
}

.summary-label {
    color: #666;
}

.summary-value {
    color: #1a1a1a;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
}

.summary-value .subtotal-token{
    display: flex;
    align-items: center;
    gap: 2px;
}

.summary-value img{
    width: 26px;
    height: 26px;
    margin-bottom: 2px;
}

.summary-value.free-shipping {
    color: #4CAF50;
    font-weight: 600;
}

.summary-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 16px 0;
}

.summary-row.total-row {
    padding-top: 16px;
    border-top: 2px solid #f0f0f0;
    margin-top: 8px;
    flex-wrap: wrap;
    row-gap: 5px;
}

.summary-row.total-row .summary-label {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.summary-row.total-row .summary-value {
    font-size: 22px;
    font-weight: 600;
    color: #CC0303;
    display: flex;
    align-items: center;
    gap: 3px;
}

.summary-row.total-row .summary-value .total-token{
    display: flex;
    align-items: center;
    gap: 2px;
}

.summary-row.total-row .summary-value img{
    width: 28px;
    height: 28px;
    margin-bottom: 2px;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.checkout-btn {
    display: block;
    padding: 16px;
    background: #CC0303;
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.checkout-btn:hover {
    background: #a00202;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(204, 3, 3, 0.3);
    color: #fff;
}

.checkout-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.continue-shopping-btn {
    display: block;
    padding: 14px;
    background: #fff;
    color: #333;
    text-align: center;
    text-decoration: none;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.continue-shopping-btn:hover {
    border-color: #CC0303;
    color: #CC0303;
}

/* ============================================
   自定義刪除確認彈窗
   ============================================ */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.custom-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 420px;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.custom-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.custom-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.custom-modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.custom-modal-close svg {
    width: 20px;
    height: 20px;
}

.custom-modal-content {
    padding: 32px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.custom-modal-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 152, 0, 0.1);
    border-radius: 50%;
}

.custom-modal-icon svg {
    width: 48px;
    height: 48px;
}

.custom-modal-message {
    font-size: 16px;
    color: #333;
    margin: 0;
    line-height: 1.5;
}

.custom-modal-actions {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #f0f0f0;
}

.custom-modal-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.custom-modal-btn.btn-confirm {
    background: #CC0303;
    color: #fff;
}

.custom-modal-btn.btn-confirm:hover {
    background: #a00202;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(204, 3, 3, 0.3);
}

.custom-modal-btn.btn-cancel {
    background: #fff;
    color: #666;
    border: 2px solid #e0e0e0;
}

.custom-modal-btn.btn-cancel:hover {
    border-color: #CC0303;
    color: #CC0303;
    background: rgba(204, 3, 3, 0.05);
}

/* 響應式設計 */
@media screen and (max-width: 1200px) {
    .cart-content {
        flex-direction: column;
    }

    .cart-summary-section {
        width: 100%;
    }

    .cart-summary-card {
        position: relative;
        top: 0;
    }

    .cart-items-header,
    .cart-item {
        grid-template-columns: 50px 2fr 100px 100px 100px 60px;
        gap: 15px;
    }
}

@media screen and (max-width: 968px) {
    .cart-container {
        padding: 30px 20px 60px;
    }

    .page-header {
        margin-bottom: 24px;
    }

    .breadcrumb-nav {
        font-size: 14px;
        margin-bottom: 16px;
    }

    .page-title {
        font-size: 28px;
    }

    .cart-content {
        gap: 0px;
    }

    .cart-items-section {
        padding: 20px;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
        width: 100%;
    }

    .cart-items-header {
        display: none;
    }

    .cart-item {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 16px;
        border: 1px solid #f0f0f0;
        border-radius: 12px;
        margin-bottom: 16px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
        transition: all 0.3s ease;
        position: relative;
    }

    .cart-item:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        transform: translateY(-2px);
    }

    .cart-item-checkbox {
        order: 1;
        justify-content: flex-start;
        margin-bottom: 12px;
        padding-bottom: 12px;
        border-bottom: 1px solid #f5f5f5;
        width: 100%;
    }

    .cart-item-checkbox input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .cart-item-info {
        order: 2;
        display: flex;
        gap: 12px;
        margin-bottom: 16px;
        width: 100%;
    }

    .cart-item-image {
        width: 100px;
        height: 100px;
        border-radius: 10px;
        overflow: hidden;
        flex-shrink: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .cart-item-details {
        flex: 1;
        min-width: 0;
    }

    .cart-item-name {
        font-size: 15px;
        line-height: 1.5;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .cart-item-spec {
        font-size: 13px;
        color: #888;
        gap: 10px;
        flex-wrap: wrap;
    }

    .cart-item-spec span {
        background: #f5f5f5;
        padding: 4px 10px;
        border-radius: 4px;
        font-size: 12px;
    }

    /* 单价和数量同一行 - 使用包装器 */
    .cart-item-price-quantity-row {
        order: 3;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        margin-bottom: 12px;
        padding-bottom: 0px;
        width: 100%;
    }

    .cart-item-price {
        display: flex;
        align-items: center;
        font-size: 16px;
        color: #666;
        flex: 1;
        min-width: 0;
    }

    .cart-item-price::before {
        content: '單價：';
        font-size: 13px;
        color: #999;
        font-weight: 400;
        margin-right: 4px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .cart-item-quantity {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-shrink: 0;
    }

    .quantity-control-cart {
        border: 1.5px solid #e0e0e0;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .quantity-btn-cart {
        width: 36px;
        height: 36px;
        font-size: 18px;
        background: #f8f8f8;
    }

    .quantity-btn-cart:active {
        background: #CC0303;
        color: #fff;
        transform: scale(0.95);
    }

    .quantity-input-cart {
        width: 60px;
        height: 36px;
        font-size: 15px;
        font-weight: 600;
    }

    .cart-item-subtotal {
        order: 5;
        text-align: right;
        font-size: 22px;
        font-weight: 600;
        color: #CC0303;
        margin-bottom: 0;
        padding: 15px 0;
        border-top: 1px solid #f5f5f5;
        width: 100%;
    }

    .cart-item-subtotal::before {
        content: '小計：';
        font-size: 14px;
        color: #666;
        font-weight: 500;
        margin-right: 6px;
    }

    .cart-item-action {
        order: 0;
        position: absolute;
        top: 5px;
        right: 5px;
        z-index: 10;
        justify-content: flex-end;
        margin-top: 0;
    }

    .delete-item-btn {
        width: 30px;
        height: 30px;
        background: rgba(255, 255, 255, 0.95);
        border: 1.5px solid #e0e0e0;
        border-radius: 50%;
        color: #999;
        transition: all 0.3s ease;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(4px);
    }

    .delete-item-btn:active {
        background: #fee;
        border-color: #CC0303;
        color: #CC0303;
        transform: scale(0.95);
    }

    .delete-item-btn svg {
        width: 16px;
        height: 16px;
    }

    /* 結算區域優化 */
    .cart-summary-section {
        width: 100%;
        margin-top: 20px;
    }

    .cart-summary-card {
        position: relative;
        top: 0;
        padding: 20px;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    }

    .summary-title {
        font-size: 18px;
        margin-bottom: 20px;
        padding-bottom: 14px;
    }

    .summary-row {
        padding: 14px 0;
        font-size: 14px;
    }

    .summary-row.total-row {
        padding-top: 18px;
        margin-top: 12px;
    }

    .summary-row.total-row .summary-label {
        font-size: 16px;
    }

    .summary-row.total-row .summary-value {
        font-size: 22px;
    }

    .checkout-btn,
    .continue-shopping-btn {
        padding: 14px;
        font-size: 15px;
        border-radius: 8px;
    }

    .checkout-btn:active {
        transform: scale(0.98);
    }
}

@media screen and (max-width: 768px) {
    .cart-container {
        padding: 16px 12px 50px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .breadcrumb-nav {
        font-size: 13px;
        margin-bottom: 12px;
    }

    .page-title {
        font-size: 24px;
        padding-bottom: 16px;
    }

    .page-title::after {
        width: 60px;
        height: 3px;
    }

    .cart-items-section {
        padding: 16px 12px;
        border-radius: 10px;
    }

    .cart-item {
        padding: 14px;
        border-radius: 10px;
        margin-bottom: 12px;
    }

    .cart-item-checkbox {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .cart-item-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .cart-item-info {
        gap: 10px;
        margin-bottom: 14px;
    }

    .cart-item-image {
        width: 90px;
        height: 90px;
        border-radius: 8px;
    }

    .cart-item-name {
        font-size: 14px;
        line-height: 1.4;
        margin-bottom: 6px;
    }

    .cart-item-spec {
        font-size: 12px;
        gap: 8px;
    }

    .cart-item-spec span {
        padding: 3px 8px;
        font-size: 11px;
    }

    .cart-item-price-quantity-row {
        margin-bottom: 10px;
    
        gap: 12px;
    }

    .cart-item-price {
        font-size: 15px;
    }

    .cart-item-price::before {
        font-size: 13px;
    }

    .cart-item-quantity {
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .quantity-btn-cart {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .quantity-input-cart {
        width: 50px;
        height: 34px;
        font-size: 14px;
    }

    .cart-item-subtotal {
        font-size: 20px;
    }

    .cart-item-subtotal::before {
        font-size: 14px;
    }



    .cart-summary-card {
        padding: 16px;
        border-radius: 10px;
    }

    .summary-title {
        font-size: 16px;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .summary-row {
        padding: 12px 0;
        font-size: 13px;
    }

    .summary-row.total-row {
        padding-top: 16px;
        margin-top: 10px;
    }

    .summary-row.total-row .summary-label {
        font-size: 15px;
    }

    .summary-row.total-row .summary-value {
        font-size: 20px;
    }

    .checkout-btn,
    .continue-shopping-btn {
        padding: 13px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* 空購物車優化 */
    .cart-empty {
        padding: 60px 20px;
    }

    .empty-icon {
        margin-bottom: 20px;
    }

    .empty-icon svg {
        width: 60px;
        height: 60px;
    }

    .empty-title {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .empty-desc {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .empty-btn {
        padding: 10px 28px;
        font-size: 14px;
    }


    .custom-modal-content{
        padding: 20px;
    }
    .custom-modal-header{
        padding: 20px;
    }
    .custom-modal-actions{
        padding: 20px;
    }
    .custom-modal-btn{
        padding: 10px;
        font-size: 14px;
    }
}

/* 超小屏幕優化 (小於 480px) */
@media screen and (max-width: 480px) {
    .cart-container {
        padding: 12px 10px 50px;
    }

    .cart-items-section {
        padding: 12px 10px;
    }

    .cart-item {
        padding: 12px;
        margin-bottom: 10px;
    }

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

    .cart-item-name {
        font-size: 13px;
    }

    .cart-item-spec {
        font-size: 11px;
    }

    .cart-item-spec span {
        padding: 2px 6px;
        font-size: 10px;
    }

    .cart-item-price {
        font-size: 14px;
    }

    .cart-item-subtotal {
        font-size: 17px;
    }

    .quantity-btn-cart {
        width: 32px;
        height: 32px;
    }

    .quantity-input-cart {
        width: 45px;
        height: 32px;
    }

    .cart-summary-card {
        padding: 14px;
    }

    .summary-title {
        font-size: 15px;
    }

    .summary-row {
        font-size: 12px;
        padding: 10px 0;
    }

    .summary-row.total-row .summary-value {
        font-size: 18px;
    }

    .checkout-btn,
    .continue-shopping-btn {
        padding: 12px;
        font-size: 13px;
    }
}

/* 移動端觸摸優化 */
@media (hover: none) and (pointer: coarse) {
    .cart-item {
        -webkit-tap-highlight-color: transparent;
    }

    .quantity-btn-cart,
    .delete-item-btn,
    .checkout-btn,
    .continue-shopping-btn {
        -webkit-tap-highlight-color: rgba(204, 3, 3, 0.1);
        touch-action: manipulation;
    }

    .cart-item-name a {
        -webkit-tap-highlight-color: rgba(204, 3, 3, 0.1);
    }

    .footer-copyright p{
        line-height: 1.5;
    }
}