/**
 * 购物车样式
 */

/* 购物车图标 */
.cart-icon {
    position: relative;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
}

.cart-icon:hover {
    transform: scale(1.1);
}

.cart-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    transition: all 0.3s ease;
}

/* 遮罩层 */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 购物车侧边栏 */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-sidebar.open {
    transform: translateX(0);
}

/* 购物车头部 */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.cart-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.cart-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* 购物车商品容器 */
.cart-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.cart-items-container::-webkit-scrollbar {
    width: 6px;
}

.cart-items-container::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.cart-items-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.cart-items-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 空购物车 */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
    padding: 40px 20px;
}

.cart-empty i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.cart-empty p {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #6b7280;
}

.cart-empty small {
    font-size: 14px;
    color: #9ca3af;
}

/* 购物车商品项 */
.cart-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.cart-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #6366f1;
}

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

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

.cart-item-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    color: #9ca3af;
    font-size: 24px;
}

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

.cart-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cart-item-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-price .price {
    font-size: 16px;
    font-weight: 700;
    color: #6366f1;
}

.cart-item-price .price-free {
    font-size: 14px;
    font-weight: 600;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
}

/* 商品控制 */
.cart-item-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 4px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: white;
    color: #6366f1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background: #6366f1;
    color: white;
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-value {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: #111827;
}

.cart-item-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.cart-item-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* 购物车底部 */
.cart-footer {
    border-top: 1px solid #e5e7eb;
    padding: 20px;
    background: #f9fafb;
}

.cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 2px solid #6366f1;
}

.cart-total span:first-child {
    font-size: 16px;
    font-weight: 600;
    color: #4b5563;
}

.cart-total-price {
    font-size: 24px;
    font-weight: 700;
    color: #6366f1;
}

.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-actions .btn-block {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
}

.cart-actions .btn-outline {
    border: 2px solid #e5e7eb;
    color: #6b7280;
}

.cart-actions .btn-outline:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

/* 响应式 */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        max-width: 100%;
    }

    .cart-item {
        padding: 12px;
    }

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

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

/* 动画 */
@keyframes cartItemSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cart-item {
    animation: cartItemSlideIn 0.3s ease;
}

/* 确认对话框 */
.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.confirm-dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.confirm-dialog {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirm-dialog-overlay.active .confirm-dialog {
    transform: scale(1);
}

.confirm-dialog-header {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    padding: 24px 28px;
    border-radius: 20px 20px 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.confirm-dialog-header i {
    font-size: 28px;
    color: white;
}

.confirm-dialog-header h3 {
    margin: 0;
    color: white;
    font-size: 20px;
    font-weight: 700;
}

.confirm-dialog-body {
    padding: 32px 28px;
}

.confirm-dialog-body p {
    margin: 0;
    color: #374151;
    font-size: 16px;
    line-height: 1.6;
}

.confirm-dialog-footer {
    padding: 20px 28px 28px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-btn-cancel,
.confirm-btn-ok {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.confirm-btn-cancel {
    background: #f3f4f6;
    color: #6b7280;
}

.confirm-btn-cancel:hover {
    background: #e5e7eb;
    color: #374151;
}

.confirm-btn-ok {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.confirm-btn-ok:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* 移动端适配 */
@media (max-width: 480px) {
    .confirm-dialog {
        width: 95%;
        max-width: none;
    }

    .confirm-dialog-header {
        padding: 20px;
    }

    .confirm-dialog-header h3 {
        font-size: 18px;
    }

    .confirm-dialog-body {
        padding: 24px 20px;
    }

    .confirm-dialog-footer {
        padding: 16px 20px 20px;
        flex-direction: column;
    }

    .confirm-btn-cancel,
    .confirm-btn-ok {
        width: 100%;
        justify-content: center;
    }
}
