/**
 * 购物车样式文件
 */

/* 购物车按钮 - 优化版本 */
.btn-add-to-cart {
    background: #1480c1;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.1s ease; /* 减少到100ms */
    position: relative;
    overflow: hidden;
}

.btn-add-to-cart:hover {
    background: #0f6ba0;
    transform: translateY(-1px);
}

.btn-add-to-cart:disabled,
.btn-add-to-cart.processing {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none; /* 禁用时不移位 */
}

.btn-add-to-cart.processing {
    pointer-events: none; /* 防止点击事件 */
}

.btn-add-to-cart.added {
    background: #28a745;
    animation: cartAdded 0.3s ease; /* 减少到300ms */
}

@keyframes cartAdded {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); } /* 减少缩放幅度 */
    100% { transform: scale(1); }
}

/* 加载状态优化 - 超高速版本 */
.cart-loading {
    display: inline-block;
    animation: spin 0.5s linear infinite; /* 超快旋转 */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 按钮状态切换优化 - 超高速版本 */
.btn-add-to-cart .cart-text,
.btn-add-to-cart .cart-loading {
    transition: opacity 0.05s ease; /* 超快速切换 */
}

.btn-add-to-cart:disabled .cart-text {
    opacity: 0;
}

.btn-add-to-cart:disabled .cart-loading {
    opacity: 1;
}

/* 购物车下拉菜单 */
.cart-dropdown {
    position: relative;
    display: inline-block;
}

.cart-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cart-toggle:hover {
    background: #e9ecef;
}

.cart-icon {
    font-size: 18px;
}

.cart-count {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.cart-total {
    font-weight: bold;
    color: #1480c1;
}

.cart-content {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.cart-dropdown.active .cart-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 购物车为空 */
.cart-empty {
    padding: 30px 20px;
    text-align: center;
    color: #6c757d;
}

.cart-empty a {
   
    text-decoration: none;
    font-weight: bold;
}

.cart-empty a:hover {
    text-decoration: underline;
}

/* 购物车商品列表 */
.cart-items {
    max-height: 300px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #f1f3f4;
    transition: background 0.3s ease;
}

.cart-item:hover {
    background: #f8f9fa;
}

.item-thumbnail {
    width: 60px;
    height: 60px;
    margin-right: 12px;
    flex-shrink: 0;
}

.item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.item-details {
    flex: 1;
    min-width: 0;
}

.item-details h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    line-height: 1.3;
}

.item-details h4 a {
    color: #333;
    text-decoration: none;
}

.item-details h4 a:hover {
    color: #1480c1;
}

.item-price {
    margin: 0 0 8px 0;
    font-weight: bold;
    color: #1480c1;
}

/* 数量控制器 */
.item-quantity {
    display: flex;
    align-items: center;
    gap: 5px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.3s ease;
}

.qty-btn:hover {
    background: #f8f9fa;
    border-color: #1480c1;
}

.qty-input {
    width: 40px;
    height: 24px;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
}

.qty-input:focus {
    outline: none;
    border-color: #1480c1;
}

/* 删除按钮 */
.item-actions {
    margin-left: 10px;
}

.remove-item {
    width: 24px;
    height: 24px;
    border: none;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.3s ease;
}

.remove-item:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* 购物车底部 */
.cart-footer {
    padding: 15px;
    border-top: 1px solid #f1f3f4;
    background: #f8f9fa;
}

.cart-summary {
    margin-bottom: 15px;
    text-align: center;
}

.cart-summary p {
    margin: 0;
    font-size: 16px;
}

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

.cart-actions a {
    flex: 1;
    padding: 10px;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-view-cart {
    background: #6c757d;
    color: white;
}

.btn-view-cart:hover {
    background: #5a6268;
    color: white;
}

.btn-checkout {
    background: #28a745;
    color: white;
}

.btn-checkout:hover {
    background: #218838;
    color: white;
}

/* 消息提示 - 优化版本 */
.cart-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(100%); /* 初始位置在右侧外 */
    transition: transform 0.15s ease; /* 快速滑入 */
}

.cart-message.show {
    transform: translateX(0); /* 滑入到正常位置 */
}

.cart-message-success {
    background: #28a745;
}

.cart-message-error {
    background: #dc3545;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .cart-content {
        width: 300px;
    }
    
    .cart-item {
        padding: 12px;
    }
    
    .item-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .cart-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .cart-content {
        width: 280px;
        right: -50px;
    }
    
    .cart-toggle {
        padding: 6px 8px;
    }
    
    .cart-icon {
        font-size: 16px;
    }
    
    .cart-count {
        width: 18px;
        height: 18px;
        font-size: 11px;
    }
}

/* 购物车页面样式 */
.cart-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.cart-table th,
.cart-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.cart-table th {
    background: #f8f9fa;
    font-weight: bold;
}

.cart-table .product-thumbnail {
    width: 80px;
}

.cart-table .product-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.cart-table .product-name {
    font-weight: bold;
}

.cart-table .product-price {
    color: #1480c1;
    font-weight: bold;
}

.cart-table .product-total {
    color: #28a745;
    font-weight: bold;
}

.cart-summary-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 4px;
    margin-top: 20px;
}

.cart-summary-box h3 {
    margin-top: 0;
    margin-bottom: 15px;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cart-summary-total {
    font-size: 18px;
    font-weight: bold;
    color: #28a745;
    border-top: 1px solid #dee2e6;
    padding-top: 10px;
    margin-top: 10px;
}

/* 购物车模态窗口样式 - WooCommerce风格 */
.cart-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    display: block !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.cart-modal.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.cart-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.cart-modal-container {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 420px !important;
    height: 100% !important;
    background: #fff !important;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
}

.cart-modal.active .cart-modal-container {
    transform: translateX(0) !important;
}

.cart-modal-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.cart-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1480c1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.cart-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cart-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.cart-modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.cart-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1000 !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent;
}

.cart-modal-close:hover {
    background: #f5f5f5;
    color: #1480c1;
}

.cart-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.cart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #666;
}

.cart-empty-state svg {
    color: #ccc;
    margin-bottom: 20px;
}

.cart-empty-state p {
    font-size: 18px;
    margin: 0 0 30px 0;
    color: #666;
}

.btn-continue-shopping {
    display: inline-block;
    padding: 12px 24px;
    background: #1480c1;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-continue-shopping:hover {
    background: #0f6ba0;
    color: #fff;
    transform: translateY(-1px);
}

.cart-items-list {
    padding: 0;
}

.cart-modal-item {
    display: flex;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    gap: 15px;
    transition: background 0.2s ease, opacity 0.3s ease;
}

.cart-modal-item:hover {
    background: #f9f9f9;
}

.cart-modal-item.updating {
    opacity: 0.7;
    pointer-events: none;
}

.cart-modal-item.updating .subtotal-value,
.cart-modal-item.updating .total-value {
    transition: opacity 0.2s ease;
}

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

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

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    margin: 0 0 0px 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.cart-item-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cart-item-title a:hover {
    color: #1480c1;
}

.cart-item-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0px;
    font-size: 13px;
}

.price-label {
    color: #666;
}

.price-value {
    font-weight: 600;
    color: #ef4444;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0px;
    font-size: 13px;
}

.cart-item-quantity label {
    color: #666;
    font-weight: 500;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quantity-controls .qty-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    color: #666;
    transition: all 0.2s ease;
}

.quantity-controls .qty-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #1480c1;
    color: #1480c1;
}

.quantity-controls .qty-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.quantity-controls .qty-btn.loading {
    position: relative;
    color: transparent;
}

.quantity-controls .qty-btn.loading::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid #1480c1;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.quantity-controls .qty-input {
    width: 50px;
    height: 26px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}

.quantity-controls .qty-input:focus {
    outline: none;
    border-color: #1480c1;
    box-shadow: 0 0 0 2px rgba(20, 128, 193, 0.1);
}

.quantity-controls .qty-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.cart-item-subtotal {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.subtotal-label {
    color: #666;
}

.subtotal-value {
    color: #ef4444;
    transition: opacity 0.2s ease;
}

.total-value {
    transition: opacity 0.2s ease;
}

.cart-item-remove {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
}

.remove-item-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.remove-item-btn:hover {
    background: #fee;
    color: #c82333;
}

.cart-modal-footer {
    padding: 20px;
    border-top: 1px solid #e5e5e5;
    background: #f9f9f9;
    position: sticky;
    bottom: 0;
}

.cart-total-section {
    margin-bottom: 20px;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-top: 2px solid #ddd;
    border-bottom: 2px solid #ddd;
}

.total-label {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.total-value {
    font-size: 24px;
    font-weight: 700;
    color: #ef4444;
}

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

.btn-view-cart-full,
.btn-checkout {
    display: block;
    flex: 1;
    padding: 14px 20px;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s ease;
}

.btn-view-cart-full {
    background: #fff;
    color: #333;
    border: 2px solid #ddd;
}

.btn-view-cart-full:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #333;
}

.btn-checkout {
    background: #1480c1;
    color: #fff;
    border: 2px solid #1480c1;
}

.btn-checkout:hover {
    background: #0f6ba0;
    border-color: #0f6ba0;
    color: #fff;
    transform: translateY(-1px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .cart-modal-container {
        max-width: 100%;
    }
    
    .cart-modal-header {
        padding: 15px;
    }
    
    .cart-modal-header h2 {
        font-size: 20px;
    }
    
    .cart-modal-item {
        padding: 15px;
        flex-wrap: wrap;
    }
    
    .cart-item-image {
        width: 70px;
        height: 70px;
    }
    
    .cart-item-info {
        flex: 1;
        min-width: calc(100% - 100px);
    }
    
    .cart-item-remove {
        position: absolute;
        top: 15px;
        right: 15px;
    }
    
    .cart-modal-footer {
        padding: 15px;
    }
    
    .total-value {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .cart-item-image {
        width: 60px;
        height: 60px;
    }
    
    .cart-item-title {
        font-size: 13px;
    }
    
    .quantity-controls .qty-input {
        width: 45px;
        height: 24px;
        font-size: 12px;
    }
    
    .quantity-controls .qty-btn {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
}
