/* ============================================
   购物袋抽屉样式
   ============================================ */

/* CSS 变量定义 - 便于主题更改和维护 */
:root {
    --cart-color-primary: #0071e3;
    --cart-color-primary-hover: #0077ed;
    --cart-color-text-primary: #1d1d1f;
    --cart-color-text-secondary: #86868b;
    --cart-color-background: #ffffff;
    --cart-color-background-light: #fafafc;
    --cart-color-border: rgba(0, 0, 0, 0.06);
    --cart-color-overlay: rgba(0, 0, 0, 0.4);
    --cart-color-badge: #ff3b30;
}

/* 购物袋遮罩层 */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--cart-color-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    /* 毛玻璃效果 - 兼容性处理：设置后备背景色 */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 购物袋抽屉 - 基础样式 */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 32rem; /* 512px - PC端默认宽度 */
    height: 100%;
    /* 后备背景色：确保在不支持backdrop-filter的浏览器中内容可读 */
    background-color: var(--cart-color-background);
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(255, 255, 255, 0.95) 50%,
        rgba(250, 250, 252, 0.98) 100%
    );
    /* 毛玻璃效果 - 兼容性处理：后备背景色已设置 */
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    box-shadow: 
        -4px 0 24px rgba(0, 0, 0, 0.12),
        2px 0 8px rgba(0, 0, 0, 0.04),
        inset -1px 0 0 rgba(255, 255, 255, 0.8);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-left-radius: 1.5rem;
    border-bottom-left-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.5);
}

.cart-drawer.active {
    transform: translateX(0);
}

/* 移动端：从底部滑出 */
@media (max-width: 991.98px) {
    .cart-drawer {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        max-width: 100%;
        width: 100%;
        height: 85vh;
        max-height: 85vh;
        border-top-left-radius: 1.5rem;
        border-top-right-radius: 1.5rem;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        transform: translateY(100%);
        box-shadow: 
            0 -4px 24px rgba(0, 0, 0, 0.12),
            0 2px 8px rgba(0, 0, 0, 0.04),
            inset 0 1px 0 rgba(255, 255, 255, 0.8);
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.5);
    }
    
    .cart-drawer.active {
        transform: translateY(0);
    }
}

/* 中等屏幕（≥992px）- 增大购物袋宽度 */
@media (min-width: 992px) {
    .cart-drawer {
        max-width: 34rem; /* 544px */
    }
}

/* 大屏幕（≥1200px）- 进一步增大购物袋宽度 */
@media (min-width: 1200px) {
    .cart-drawer {
        max-width: 36rem; /* 576px */
    }
}

/* 超大屏幕（≥1400px）- 最大宽度 */
@media (min-width: 1400px) {
    .cart-drawer {
        max-width: 38rem; /* 608px */
    }
}

/* 购物袋头部 */
.cart-drawer-header {
    padding: 1.5rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--cart-color-border);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 后备背景色：确保在不支持backdrop-filter的浏览器中内容可读 */
    background-color: var(--cart-color-background);
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.7) 100%
    );
    /* 毛玻璃效果 - 兼容性处理：后备背景色已设置 */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

.cart-drawer-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cart-drawer-title h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--cart-color-text-primary);
    letter-spacing: -0.02em;
}

.cart-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    background-color: var(--cart-color-primary);
    color: #fff;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.cart-drawer-close {
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    background: transparent;
    color: #86868b;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.cart-drawer-close:hover,
.cart-drawer-close:focus {
    background-color: var(--cart-color-border);
    color: var(--cart-color-text-primary);
    transform: rotate(90deg);
    outline: none;
}

/* 购物袋内容区域 */
.cart-drawer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

/* 空购物袋状态 */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    min-height: 20rem;
}

.cart-empty-icon {
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--cart-color-border);
    border-radius: 50%;
    margin-bottom: 1.5rem;
    color: var(--cart-color-text-secondary);
    font-size: 2rem;
}

.cart-empty-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--cart-color-text-primary);
    margin: 0 0 0.5rem;
}

.cart-empty-hint {
    font-size: 0.9375rem;
    color: var(--cart-color-text-secondary);
    margin: 0;
}

/* 购物袋商品列表 */
.cart-items-list {
    list-style: none;
    margin: 0;
    padding: 1rem 0;
}

.cart-item {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--cart-color-border);
    display: flex;
    gap: 1rem;
    transition: background-color 0.2s ease;
}

.cart-item:hover {
    background-color: var(--cart-color-border);
}

.cart-item-image {
    width: 5rem;
    height: 5rem;
    border-radius: 0.75rem;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #f5f5f7;
}

.cart-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-item-name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--cart-color-text-primary);
    margin: 0;
    line-height: 1.4;
    /* 文本溢出处理：使用 WebKit 前缀属性限制文本行数
     * 注意：-webkit-line-clamp 不是 CSS 规范的一部分，但这是目前最常用的跨浏览器方法
     * 未来可以关注 W3C 官方推荐的文本溢出解决方案
     */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-meta {
    font-size: 0.875rem;
    color: var(--cart-color-text-secondary);
    margin: 0;
}

.cart-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.cart-item-price {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--cart-color-text-primary);
}

.cart-item-remove {
    width: 2rem;
    height: 2rem;
    border: 0;
    background: transparent;
    color: var(--cart-color-text-secondary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 0;
}

.cart-item-remove:hover,
.cart-item-remove:focus {
    background-color: var(--cart-color-border);
    color: var(--cart-color-text-primary);
    outline: none;
}

/* 购物袋底部 */
.cart-drawer-footer {
    flex-shrink: 0;
    padding: 1.5rem;
    border-top: 1px solid var(--cart-color-border);
    /* 后备背景色：确保在不支持backdrop-filter的浏览器中内容可读 */
    background-color: var(--cart-color-background);
    background: linear-gradient(
        to top,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.7) 100%
    );
    /* 毛玻璃效果 - 兼容性处理：后备背景色已设置 */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.5) inset;
}

.cart-summary {
    margin-bottom: 1.25rem;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.cart-summary-row:last-child {
    margin-bottom: 0;
}

.cart-summary-label {
    font-size: 0.9375rem;
    color: var(--cart-color-text-secondary);
}

.cart-summary-value {
    font-size: 0.9375rem;
    color: var(--cart-color-text-primary);
    font-weight: 500;
}

.cart-summary-total .cart-summary-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--cart-color-text-primary);
}

.cart-summary-total .cart-summary-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--cart-color-text-primary);
}

.cart-summary-divider {
    height: 1px;
    background: linear-gradient(
        to right,
        transparent 0%,
        var(--cart-color-border) 20%,
        var(--cart-color-border) 80%,
        transparent 100%
    );
    margin: 1rem 0;
}

.cart-checkout-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--cart-color-primary);
    color: #fff;
    border: 0;
    border-radius: 0.75rem;
    font-size: 1.0625rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
}

.cart-checkout-btn:hover,
.cart-checkout-btn:focus {
    background-color: var(--cart-color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
    outline: none;
}

.cart-checkout-btn:active {
    transform: translateY(0);
}

.cart-checkout-btn:disabled {
    background-color: var(--cart-color-text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 购物袋按钮徽章 */
.nav-cart-btn {
    position: relative;
}

.cart-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.25rem;
    background-color: var(--cart-color-badge);
    color: #fff;
    border-radius: 0.5625rem;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.125rem;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.cart-badge.show {
    display: flex;
}

