/* 購物車遮罩層 */
.cart-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

/* 購物車容器 */
.cart-container {
    background: #fff;
    width: 540px;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 購物車標題欄 */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.close-button {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-button:hover {
    background-color: #f5f5f5;
}

.cart-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

/* 購物車內容 */
.cart-content {
    flex: 2;
    padding: 0 24px 24px 24px;
    overflow-y: auto;
}

.section-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin: 20px 0 16px 0;
}

/* 購物車項目 */
.cart-items {
    margin-bottom: 20px;
}

.cart-item {
    display: flex;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cart-item:last-child {
    border-bottom: none;
}

.item-image {
    width: 100px;
    height: 100px;
    margin-right: 8px;
    flex-shrink: 0;
    position: relative;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    background-color: #ffeee6;
}

.item-details {
    flex: 1;
    flex-direction: column;
    margin-right: 12px;
    width: 100%;
}

.item-details-container {
    justify-content: space-between;
    display: flex;
    flex: 1;
    flex-direction: row;
}

.item-details-container:last-child {
    border-bottom: none;
}

.item-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 0 0;
}

.item-description {
    font-size: 14px;
    color: #666;
    margin: 0 0 6px 0;
}

.item-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-current {
    font-size: 16px;
    font-weight: bold;
    color: #e91e63;
}

.price-original {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
}

/* 商品控制項 */
.item-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 3px;
}

.item-info {
    display: flex;
    flex-direction: column;
    width: 100%;
}


.delete-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.delete-btn:hover {
    background-color: #f5f5f5;
    color: #666;
}

.quantity-controls {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

.qty-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: background-color 0.2s;
}

.qty-btn:hover {
    background-color: #f5f5f5;
}

.quantity {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* 添加更多食物按鈕 */
.add-more-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: #6f42c1;
    font-size: 16px;
    cursor: pointer;
    padding: 12px 0;
    width: 100%;
    justify-content: flex-start;
    transition: color 0.2s;
}

.add-more-btn:hover {
    color: #5a32a3;
}

.plus-icon {
    font-size: 20px;
    font-weight: bold;
}

/* 價格明細 */
.price-summary {
    margin: 24px 0 20px 0;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.price-label {
    font-size: 16px;
    color: #666;
}

.price-value {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* 總計區域 */
.total-section {
    padding: 20px 0;
    border-top: 2px solid #f0f0f0;
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 8px;
}

.total-label {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.discount-note {
    font-size: 12px;
    font-weight: normal;
    color: #888;
}

.total-prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.total-original {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
}

.savings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.savings-label {
    font-size: 16px;
    color: #666;
}

.savings-amount {
    font-size: 16px;
    color: #28a745;
    font-weight: bold;
}

/* 結帳按鈕 */
.checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
}

.checkout-btn:hover {
    background: linear-gradient(135deg, #c2185b, #ad1457);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4);
}

/* 空購物車狀態 */
.empty-cart {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 16px;
}

/* 響應式設計 */
@media (max-width: 600px) {
    .cart-container {
        width: 95vw;
        max-height: 95vh;
        border-radius: 12px;
    }

    .cart-content {
        padding: 0 16px 16px 16px;
    }

    .cart-header {
        padding: 16px 20px 12px 20px;
    }
}

/* 購物車管理區域 */
.cart-management {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.clear-cart-btn {
    background: none;
    border: 1px solid #ddd;
    color: #666;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.clear-cart-btn:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
    color: #333;
}

.clear-cart-btn:active {
    background-color: #e9ecef;
}

.cart-info {
    font-size: 12px;
    color: #888;
    text-align: right;
    flex: 1;
    margin-left: 12px;
}

/* 購物車數據加載狀態 */
.cart-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* 購物車同步指示器 */
.cart-sync-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: sync-pulse 2s infinite;
}

@keyframes sync-pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 響應式調整 */
@media (max-width: 600px) {
    .cart-management {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .cart-info {
        text-align: center;
        margin-left: 0;
    }
}

/* 購物車項目詳細信息樣式 */
.item-savings {
    margin-top: 4px;
}

.savings-per-item {
    font-size: 12px;
    color: #28a745;
    font-weight: 500;
    background: rgba(40, 167, 69, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

/* 購物車項目價格顯示優化 */
.item-details .item-description {
    font-size: 13px;
    color: #666;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.item-details .item-price {
    display: flex;
    align-items: center;

    gap: 8px;
    margin-bottom: 2px;
}

/* 數量控制按鈕強化 */
.quantity-controls {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.qty-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background-color: #f5f5f5;
    color: #333;
}

.qty-btn:active {
    background-color: #e9ecef;
    transform: scale(0.95);
}

/* 價格更新動畫 */
@keyframes price-update {
    0% {
        background-color: rgba(233, 30, 99, 0.1);
        transform: scale(1);
    }
    50% {
        background-color: rgba(233, 30, 99, 0.2);
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.price-updating {
    animation: price-update 0.5s ease-in-out;
}

/* 購物車中的價格顏色 */
.item-price .price-current {
    font-size: 16px;
    font-weight: bold;
    color: #6f42c1; /* 改為紫色 */
}

/* 結帳按鈕改為紫色漸變 */
.checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, #6f42c1, #5a32a3); /* 紫色漸變 */
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.3); /* 紫色陰影 */
}

.checkout-btn:hover {
    background: linear-gradient(135deg, #5a32a3, #4a2c87); /* 深紫色懸停效果 */
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(111, 66, 193, 0.4); /* 加深陰影 */
}

.checkout-btn:active {
    transform: translateY(0);
}

/* 總計金額顏色調整 */
.total-current {
    font-size: 18px;
    font-weight: bold;
    color: #333; /* 保持深色以突出總計 */
}

/* 價格更新動畫調整為紫色 */
@keyframes price-update {
    0% {
        background-color: rgba(111, 66, 193, 0.1);
        transform: scale(1);
    }
    50% {
        background-color: rgba(111, 66, 193, 0.2);
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

/* 刪除按鈕使用 Material Icons */
.delete-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.delete-btn:hover {
    background-color: #f5f5f5;
    color: #666;
    transform: scale(1.1);
}

.delete-btn:active {
    transform: scale(0.95);
    background-color: #e9ecef;
}

/* 刪除圖標動畫效果 */
.delete-btn .material-icons {
    font-size: 18px;
    transition: color 0.2s ease;
}

.delete-btn:hover .material-icons {
    color: #dc3545; /* 懸停時變紅色 */
}

/* 主要響應式設計 - 支援更多手機設備 */
@media (max-width: 768px) {
    .cart-container {
        width: 95vw;
        max-height: 90vh;
        border-radius: 12px;
        margin: 10px auto;
    }

    .cart-content {
        padding: 0 16px 16px 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* iOS 流暢滾動 */
    }

    .cart-header {
        padding: 16px 20px 12px 20px;
    }

    .cart-title {
        font-size: 18px; /* 手機上適當縮小標題 */
    }

    .close-button {
        width: 36px;
        height: 36px;
        font-size: 24px; /* 增大關閉按鈕 */
    }

    /* 購物車項目在手機上的調整 */
    .cart-item {
        padding: 12px 0;
    }

    /*.item-image {*/
    /*    width: 90px;*/
    /*    height: 90px;*/
    /*    margin-right: 5px;*/
    /*}*/

    .item-details {
        flex: 1;
        min-width: 0; /* 防止文字溢出 */
        margin-right: 8px;
    }

    .item-name {
        font-size: 15px;
        line-height: 1.3;
    }

    .item-description {
        font-size: 12px;
        line-height: 1.2;
    }

    /* 價格顯示優化 */
    .price-current {
        font-size: 15px;
    }

    .price-original {
        font-size: 13px;
    }

    /* 控制按鈕增大以利觸控操作 */
    .qty-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
        touch-action: manipulation; /* 優化觸控回應 */
    }

    .quantity {
        font-size: 16px;
        min-width: 28px;
    }

    .delete-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
        touch-action: manipulation;
    }

    /* 購物車管理區域 */
    .cart-management {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .cart-info {
        text-align: center;
        margin-left: 0;
        font-size: 14px;
    }

    .clear-cart-btn {
        padding: 10px 16px;
        font-size: 15px;
        touch-action: manipulation;
    }

    /* 價格摘要優化 */
    .section-title {
        font-size: 16px;
    }

    .price-label,
    .price-value {
        font-size: 15px;
    }

    .total-label {
        font-size: 16px;
    }

    .total-current {
        font-size: 16px;
    }

    /* 結帳按鈕增強 */
    .checkout-btn {
        font-size: 18px;
        padding: 18px 16px;
        border-radius: 10px;
        touch-action: manipulation;
        /* 防止雙擊縮放 */
        -webkit-user-select: none;
        user-select: none;
    }

    /* 添加更多食物按鈕 */
    .add-more-btn {
        font-size: 15px;
        padding: 14px 0;
        touch-action: manipulation;
    }
}

/* 小型手機設備 (最大寬度 480px) */
@media (max-width: 480px) {
    .cart-container {
        width: 98vw;
        max-height: 95vh;
        border-radius: 8px;
        margin: 5px auto;
    }

    .cart-header {
        padding: 12px 16px 10px 16px;
    }

    .cart-content {
        padding: 0 12px 12px 12px;
    }

    .cart-title {
        font-size: 16px;
    }

    .close-button {
        right: 16px;
        width: 32px;
        height: 32px;
        font-size: 22px;
    }

    /* 進一步縮小間距和字體 */
    .cart-item {
        padding: 10px 0;
    }

    /*.item-image {*/
    /*    width: 90px;*/
    /*    height: 90px;*/
    /*    margin-right: 3px;*/
    /*}*/

    .item-name {
        font-size: 14px;
    }

    .item-description {
        font-size: 11px;
    }

    .price-current {
        font-size: 14px;
    }

    .qty-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .quantity {
        font-size: 14px;
        min-width: 24px;
    }

    .delete-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .checkout-btn {
        font-size: 16px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .item-image {
        width: 90px;
        height: 90px;
        margin-right: 3px;
    }
}

@media (max-width: 424px) {
    .item-image {
        width: 70px;
        height: 70px;
        margin-right: 3px;
    }
}

@media (max-width: 400px) {
    .item-image {
        width: 50px;
        height: 50px;
    }
}


@media (max-width: 374px) {
    .item-image {
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 357px) {
    .item-image {
        display: none;
    }
}

/* 橫向模式優化 */
@media (max-width: 768px) and (orientation: landscape) {
    .cart-container {
        max-height: 85vh;
    }

    .cart-content {
        max-height: calc(85vh - 120px);
    }
}

/* 高 DPI 螢幕優化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .cart-container {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    }

    .quantity-controls {
        box-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.1);
    }
}

/* 購物車項目到期日樣式 */
.item-expiration {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
    margin: 4px 0;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.02);
}

.expiry-icon {
    font-size: 14px !important;
    color: #666;
}

/* 響應式調整 */
@media (max-width: 600px) {
    .item-expiration {
        font-size: 11px;
        padding: 2px 4px;
    }

    .expiry-icon {
        font-size: 12px !important;
    }
}

@media (max-width: 425px) {
    .item-expiration {
        font-size: 10px;
        padding: 1px 3px;
    }

    .expiry-icon {
        font-size: 11px !important;
    }
}