/**
 * Minicart 侧栏抽屉样式
 * 实现购物车侧栏展开功能
 */

/* 购物车触发按钮样式 */
.cart-trigger {
    background: transparent !important;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    transition: all 0.3s ease;
    position: relative;
}

/* 购物车计数动画效果 */
.cart-count.cart-updated {
    animation: cartCountPulse 0.3s ease;
}

@keyframes cartCountPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* 商品移除加载状态 */
.minicart-item.removing {
    opacity: 0.5;
    pointer-events: none;
}

.minicart-item.removing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--e-global-color-primary);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Minicart 抽屉容器 */
.minicart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s ease, opacity 0.3s ease;
}

.minicart-drawer.open {
    visibility: visible;
    opacity: 1;
}

/* WordPress adminbar调整 */
body.admin-bar .minicart-drawer {
    top: 32px;
    height: calc(100% - 32px);
}

@media screen and (max-width: 782px) {
    body.admin-bar .minicart-drawer {
        top: 46px;
        height: calc(100% - 46px);
    }
}

/* 遮罩层 */
.minicart-drawer .minicart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

/* 抽屉内容区域 */
.minicart-drawer .minicart-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 600px;
    height: 100%;
    background-color: #111111;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 20px;
    color: #fff;
}

.minicart-drawer.open .minicart-content,
.minicart-drawer.closing .minicart-content {
    transform: translateX(0);
}

.minicart-drawer.closing .minicart-content {
    transform: translateX(100%);
}

/* 抽屉头部 */
.minicart-drawer .minicart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
}

.minicart-drawer .minicart-title {
    margin: 0;
    font-size: 26px;
    font-weight: 600;
}

.minicart-drawer .minicart-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.minicart-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.close-icon {
    font-size: 20px;
    color: #666666;
}

/* 抽屉主体内容 */
.minicart-drawer .minicart-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.minicart-drawer .minicart-items {
    padding: 0;
}

/* 购物车商品项 */
.minicart-drawer .minicart-item {
    display: flex;
    align-items: flex-start;
    padding: 15px 20px 15px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 12px;
}

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

.minicart-drawer .item-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
}

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

.minicart-drawer .item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 商品标题和总价布局 */
.minicart-drawer .item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 4px;
}

/* 价格显示区域 */
.minicart-drawer .item-unit-price {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #999999;
    margin-bottom: 4px;
}

.minicart-drawer .unit-price-label,
.minicart-drawer .unit-price {
    font-size: 12px;
}

.minicart-drawer .unit-price-label {
    color: #999999;
}

.minicart-drawer .unit-price {
    color: #cccccc;
    font-weight: 500;
}

.minicart-drawer .item-total-price {
    flex-shrink: 0;
}

.minicart-drawer .total-price {
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
}

.minicart-drawer .item-name {
    flex: 1;
    min-width: 0;
}

.minicart-drawer .item-name a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    display: block;
}

.minicart-drawer .item-name a:hover {
    color: var(--e-global-color-primary);
}

.minicart-drawer .item-quantity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #666666;
    font-size: 13px;
    flex-wrap: nowrap !important;
    min-width: 0;
    gap: 8px;
    white-space: nowrap;
    overflow: visible;
    flex-shrink: 0;
}

/* 数量控制器样式 - 根据Figma设计稿调整 */
.minicart-drawer .quantity-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #222222;
    border-radius: 100px;
    width: 108px;
    height: 42px;
    padding: 0 14px;
    gap: 0;
    flex-shrink: 0;
}

.minicart-drawer button.quantity-btn {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: none !important;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1 !important;
}

.minicart-drawer .quantity-btn svg {
    width: 16px;
    height: auto;
    transition: opacity 0.2s ease;
}

.minicart-drawer .quantity-btn:hover svg,
.minicart-drawer .quantity-btn:active svg {
    opacity: 0.7;
}

.minicart-drawer .quantity-btn:disabled,
.minicart-drawer .quantity-btn.disabled,
.minicart-drawer .quantity-btn:disabled:hover,
.minicart-drawer .quantity-btn.disabled:hover {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    background-color: #2a2a2a;
    transform: none;
}

.minicart-drawer .quantity-btn:disabled svg,
.minicart-drawer .quantity-btn.disabled svg {
    opacity: 0.3;
    fill: #666666;
}

/* 加载动画图标样式 */
.minicart-drawer .quantity-btn .loading-icon {
    width: 16px;
    height: 16px;
    color: #ffffff;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    flex-shrink: 0;
}

/* 确保按钮有相对定位以支持绝对定位的子元素 */
.minicart-drawer .quantity-btn.updating {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.minicart-drawer .quantity-number {
    min-width: 20px;
    text-align: center;
    font-weight: 400;
    font-size: 16px;
    color: #ffffff;
    user-select: none;
    line-height: 1.625;
}

.minicart-drawer .item-remove {
    flex-shrink: 0;
}

.minicart-drawer .remove-item {
    color: #999999;
    text-decoration: none;
    font-size: 12px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.minicart-drawer .remove-item:hover {
    color: #ff4444;
    background-color: rgba(255, 68, 68, 0.1);
}

/* 空购物车状态 */
.minicart-drawer .minicart-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666666;
}

.minicart-drawer .minicart-empty p {
    margin: 0;
    font-size: 16px;
}

/* 抽屉底部 */
.minicart-drawer .minicart-footer {
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.minicart-drawer .minicart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
}

.minicart-drawer .total-amount {
    color: var(--e-global-color-primary);
    font-size: 26px;
}

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

.minicart-drawer .minicart-actions .btn {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.minicart-drawer .btn-primary {
    border-radius: 4px;
    border: 1px solid #FAD38F;
    background: linear-gradient(144deg, #FAD38F 17.97%, #D1A75D 97.36%);
    color: #482906;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .minicart-drawer .minicart-content {
        width: 100%;
        max-width: 350px;
    }

    .minicart-drawer .item-quantity {
        gap: 6px;
    }

    .minicart-drawer .quantity-controls {
        width: 96px;
        height: 38px;
        padding: 0 12px;
    }

    .minicart-drawer .quantity-btn {
        width: 14px;
        height: 14px;
    }

    .minicart-drawer .quantity-btn svg {
        width: 14px;
    }

    .minicart-drawer .quantity-number {
        min-width: 18px;
        font-size: 14px;
    }

    .minicart-drawer .item-unit-price {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .minicart-drawer .unit-price-label,
    .minicart-drawer .unit-price {
        font-size: 11px;
    }

    .minicart-drawer .total-price {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    body .minicart-drawer .minicart-content {
        width: 100%;
        max-width: none;
    }

    .minicart-drawer .minicart-header {
        padding: 15px 0;
    }

    .minicart-drawer .minicart-item {
        padding: 12px 15px 12px 0;
        gap: 10px;
    }

    .minicart-drawer .minicart-footer {
        padding: 15px;
    }

    .minicart-drawer .minicart-actions {
        flex-direction: column;
    }

    .minicart-drawer .item-image {
        width: 50px;
        height: 50px;
    }

    .item-quantity {
        gap: 4px;
    }

    .quantity-controls {
        width: 88px;
        height: 36px;
        padding: 0 10px;
    }

    .quantity-btn {
        width: 12px;
        height: 12px;
    }

    .quantity-btn svg {
        width: 12px;
    }

    .quantity-number {
        min-width: 16px;
        font-size: 12px;
    }

    .minicart-drawer .item-header {
        gap: 8px;
    }

    .item-unit-price {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .unit-price-label,
    .unit-price {
        font-size: 11px;
    }

    .total-price {
        font-size: 13px;
    }
}

/* 滚动条样式 */
.minicart-drawer .minicart-body::-webkit-scrollbar {
    width: 6px;
}

.minicart-drawer .minicart-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.minicart-drawer .minicart-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.minicart-drawer .minicart-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}