/* ========== 摩瑪建材 購物車樣式 ========== */

/* 購物車按鈕（Header 內） */
.cart-btn {
    position: relative;
    background: var(--gold);
    color: var(--bg-primary);
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.cart-btn:hover {
    background: var(--gold-light);
    transform: translateY(-2px);
}

.cart-btn-icon {
    font-size: 18px;
}

.cart-btn-text {
    display: inline;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e53e3e;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.cart-badge.hidden {
    display: none;
}

/* 購物車遮罩 */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cart-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* 購物車側邊面板 */
.cart-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-secondary, #141414);
    border-left: 1px solid var(--border, rgba(201, 169, 98, 0.2));
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
}

.cart-panel.open {
    right: 0;
}

/* 購物車標題列 */
.cart-header {
    padding: 20px;
    border-bottom: 1px solid var(--border, rgba(201, 169, 98, 0.2));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card, #1a1a1a);
}

.cart-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gold, #c9a962);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-close {
    background: none;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    font-size: 28px;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.cart-close:hover {
    color: var(--text-primary, #f5f5f5);
}

/* 購物車商品列表 */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #a0a0a0);
}

.cart-empty-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.4;
}

.cart-empty-text {
    font-size: 16px;
    margin-bottom: 20px;
}

.cart-empty-btn {
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
}

.cart-empty-btn:hover {
    background: var(--gold-light, #e8d5a3);
}

/* 購物車商品項目 */
.cart-item {
    background: var(--bg-card, #1a1a1a);
    border: 1px solid var(--border, rgba(201, 169, 98, 0.2));
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    transition: all 0.3s ease;
}

.cart-item:hover {
    border-color: var(--gold, #c9a962);
}

.cart-item-img {
    width: 80px;
    height: 80px;
    background: var(--bg-primary, #0a0a0a);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-img-placeholder {
    font-size: 32px;
    color: var(--gold-dark, #8b7355);
    opacity: 0.5;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cart-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #f5f5f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-price {
    font-size: 16px;
    color: var(--gold-light, #e8d5a3);
    font-weight: 600;
}

.cart-item-subtotal {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
}

.cart-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-muted, #666);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.3s;
    padding: 0;
    line-height: 1;
}

.cart-item-remove:hover {
    color: #e53e3e;
}

/* 數量控制 */
.cart-qty {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary, #0a0a0a);
    border-radius: 6px;
    padding: 4px;
}

.cart-qty button {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-secondary, #141414);
    color: var(--text-primary, #f5f5f5);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-qty button:hover {
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
}

.cart-qty span {
    min-width: 30px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #f5f5f5);
}

/* 購物車摘要 */
.cart-summary {
    padding: 20px;
    border-top: 1px solid var(--border, rgba(201, 169, 98, 0.2));
    background: var(--bg-card, #1a1a1a);
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary, #a0a0a0);
}

.cart-summary-row.total {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #f5f5f5);
    padding-top: 15px;
    margin-top: 10px;
    border-top: 1px solid var(--border, rgba(201, 169, 98, 0.2));
}

.cart-summary-row.total .cart-summary-value {
    color: var(--gold-light, #e8d5a3);
    font-size: 22px;
}

/* 購物車操作按鈕 */
.cart-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.cart-action-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
}

.cart-action-btn.primary {
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
}

.cart-action-btn.primary:hover {
    background: var(--gold-light, #e8d5a3);
}

.cart-action-btn.secondary {
    background: transparent;
    color: var(--text-secondary, #a0a0a0);
    border: 1px solid var(--border, rgba(201, 169, 98, 0.2));
}

.cart-action-btn.secondary:hover {
    border-color: var(--gold, #c9a962);
    color: var(--gold, #c9a962);
}

/* 加入購物車按鈕（產品卡片） */
.add-to-cart-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--gold, #c9a962);
    color: var(--gold, #c9a962);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
    margin-top: 10px;
}

.add-to-cart-btn:hover {
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
}

/* 數量選擇器 */
.qty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-top: 10px;
    border: 1px solid var(--border, rgba(201, 169, 98, 0.3));
    border-radius: 8px;
    overflow: hidden;
}

.qty-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--gold, #c9a962);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
}

.qty-input {
    width: 50px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--border, rgba(201, 169, 98, 0.3));
    border-right: 1px solid var(--border, rgba(201, 169, 98, 0.3));
    background: transparent;
    color: var(--text-primary, #f5f5f5);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-input:focus {
    outline: none;
    background: rgba(201, 169, 98, 0.1);
}

/* Toast 提示 */
.cart-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.cart-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* 響應式 */
@media (max-width: 768px) {
    .cart-panel {
        width: 100%;
        right: -100%;
    }

    .cart-btn-text {
        display: none;
    }

    .cart-btn {
        padding: 10px 12px;
    }

    .cart-item {
        padding: 12px;
    }

    .cart-item-img {
        width: 60px;
        height: 60px;
    }
}

/* ========== 庫存狀態樣式 ========== */

/* 庫存狀態標籤 */
.stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    letter-spacing: 0.03em;
    z-index: 5;
    text-transform: uppercase;
}

.stock-badge.in-stock {
    background: rgba(74, 156, 109, 0.95);
    color: #fff;
}

.stock-badge.low-stock {
    background: rgba(214, 158, 46, 0.95);
    color: #fff;
}

.stock-badge.out-stock {
    background: rgba(229, 62, 62, 0.95);
    color: #fff;
}

/* 無貨時產品卡片樣式 */
.product-card.out-of-stock {
    opacity: 0.65;
}

.product-card.out-of-stock .product-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.product-card.out-of-stock:hover {
    transform: none;
    box-shadow: none;
}

/* 無貨按鈕樣式 */
.add-to-cart-btn:disabled,
.add-to-cart-btn.disabled {
    background: var(--text-muted, #666) !important;
    border-color: var(--text-muted, #666) !important;
    color: var(--bg-secondary, #141414) !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.add-to-cart-btn:disabled:hover,
.add-to-cart-btn.disabled:hover {
    background: var(--text-muted, #666) !important;
    transform: none !important;
}

/* 庫存數量提示 */
.stock-count {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    margin-top: 4px;
    margin-bottom: 4px;
}

.stock-count.low {
    color: #d69e2e;
}

.stock-count.out {
    color: #e53e3e;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .stock-badge {
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* ========== 骨架屏 / 載入狀態 ========== */

/* 骨架屏動畫 */
@keyframes skeleton-pulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.7; }
    100% { opacity: 0.4; }
}

.skeleton-pulse {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* 骨架卡片 */
.skeleton-card {
    background: var(--bg-card, #1a1a1a);
    border: 1px solid var(--border, rgba(201, 169, 98, 0.2));
    overflow: hidden;
}

.skeleton-image {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #1f1f1f 0%, #2a2a2a 50%, #1f1f1f 100%);
}

.skeleton-info {
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.skeleton-text {
    height: 14px;
    background: #2a2a2a;
    border-radius: 3px;
}

/* 載入錯誤 */
.loading-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary, #a0a0a0);
}

.loading-error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.loading-error-msg {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary, #a0a0a0);
}

.loading-error-retry {
    background: var(--gold, #c9a962);
    color: var(--bg-primary, #0a0a0a);
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
}

.loading-error-retry:hover {
    background: var(--gold-light, #e8d5a3);
}

/* 離線模式橫幅 */
.offline-banner {
    background: rgba(214, 158, 46, 0.15);
    border: 1px solid rgba(214, 158, 46, 0.3);
    color: #d69e2e;
    padding: 0.6rem 1rem;
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}
