/* 購物車相關樣式 */

/* Vue 初始化前隱藏元素 */
[v-cloak] {
    display: none !important;
}

/* 購物車添加成功提示訊息 */
.cart-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background-color: var(--success-color, #28a745);
    color: white;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 2.5s forwards;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.cart-success-message i {
    font-size: 1.2rem;
}

@keyframes slideIn {
    from {
        transform: translateX(50px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* 購物車預覽模態框 */
.cart-preview {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 320px;
    max-width: 400px; /* 增加電腦版的寬度 */
    width: 400px; /* 設定固定寬度 */
    background-color: #fff;
    border-radius: 8px;
    z-index: 9999; /* 增加 z-index 確保顯示在其他元素之上 */
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); /* 增強陰影效果 */
    margin-top: 10px; /* 增加與購物車圖標的間距 */
}

/* 手機版購物車預覽樣式 */
@media (max-width: 767.98px) {
    .cart-preview {
        max-width: 90%;
        width: 90%;
        right: 5%;
        left: 5%;
        position: fixed;
        top: 50px; /* 調整頂部距離，避免被遮擋 */
        margin-top: 0;
        border-radius: 8px; /* 恢復圓角 */
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        z-index: 9999; /* 確保在手機版上也有足夠高的 z-index */
    }
}

/* 購物車預覽頭部 */
.cart-preview-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-color, #6f42c1);
    color: white;
}

/* 購物車預覽內容區 */
.cart-preview-body {
    padding: 16px;
    overflow-y: auto;
    max-height: 400px;
}

/* 購物車預覽底部 */
.cart-preview-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #dee2e6);
    background-color: var(--background-light, #f8f9fa);
    color: #333;
}

/* 購物車總計 */
.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    margin-bottom: 12px;
}

/* 購物車項目 */
.cart-item {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color, #dee2e6);
    width: 100%;
}

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

/* 購物車項目圖片 */
.cart-item-image {
    width: 50px;
    height: 50px;
    overflow: hidden;
    border-radius: 4px;
    margin-right: 8px;
    flex-shrink: 0;
}

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

/* 購物車項目信息 */
.cart-item-info {
    flex: 1;
    min-width: 0;
    margin-right: 5px;
    text-align: left !important;
}

.cart-item-title {
    color: var(--text-color, #343a40);
    margin: 0 0 2px;
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    font-size: 0.75rem;
    color: var(--text-color, #343a40);
}

/* 購物車項目操作按鈕 */
.cart-item-actions {
    display: flex;
    align-items: center;
    margin-left: 5px;
    flex-shrink: 0;
}

.cart-item-actions .btn {
    padding: 2px 6px;
    font-size: 0.7rem;
}

/* 加入購物車按鈕 */
.add-to-cart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.quantity-control {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.quantity-control .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-input {
    width: 80px;
    text-align: center;
    margin: 0 8px;
    padding-right: 0 !important;
    appearance: textfield;
    -moz-appearance: textfield;
    font-weight: 500;
    box-sizing: border-box;
    letter-spacing: 0;
}

/* 操作成功提示 */
.cart-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px;
    background-color: var(--primary-color, #6f42c1);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    animation: slide-in 0.3s ease-out forwards;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 主題適配 */
[data-theme="ocean"] .cart-preview-header,
[data-theme="ocean"] .cart-success-message {
    background-color: var(--primary-color, #0d6efd);
}

[data-theme="forest"] .cart-preview-header,
[data-theme="forest"] .cart-success-message {
    background-color: var(--primary-color, #198754);
}

[data-theme="sunset"] .cart-preview-header,
[data-theme="sunset"] .cart-success-message {
    background-color: var(--primary-color, #fd7e14);
}
