/* 基础样式 */
.floating-cart-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 999;
    border-top: 1px solid #eee;
    padding-bottom: env(safe-area-inset-bottom);
}

/* 添加底部空间防止遮挡 */
body.has-floating-cart {
    padding-bottom: 100px;
}

.floating-cart-panel.visible {
    transform: translateY(0);
}

/* 联系方式图标容器 */
.floating-contact-icons {
    position: absolute;
    top: -40px;
    right: 20px;
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

/* 联系方式图标 */
.contact-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.contact-icon:hover {
    transform: translateY(-3px);
    opacity: 0.9;
}

/* 图标特定颜色 */
.contact-icon.email {
    background: #ea4335;
}

.contact-icon.whatsapp {
    background: #25D366;
}

.contact-icon.telegram {
    background: #0088cc;
}

/* 图标内的SVG */
.contact-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .floating-contact-icons {
        top: -36px;
        right: 10px;
        padding: 6px 10px;
        gap: 10px;
    }
    
    .contact-icon {
        width: 20px;
        height: 20px;
    }
    
    .contact-icon svg {
        width: 12px;
        height: 12px;
    }
}

/* 小屏幕适配 */
@media (max-width: 375px) {
    .floating-contact-icons {
        top: -32px;
        right: 5px;
        padding: 4px 8px;
        gap: 8px;
    }
}

/* 确保联系图标在浮动购物车可见时显示 */
.floating-cart-panel.visible .floating-contact-icons {
    opacity: 1;
}

/* 容器宽度与主内容一致 */
.floating-cart-panel .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    position: relative;
}

/* 左侧产品信息 */
.floating-cart-panel .product-info {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.floating-cart-panel .product-image {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    border: 1px solid #eee;
    padding: 5px;
}

.floating-cart-panel .product-details {
    flex: 1;
}

.floating-cart-panel .floating-product-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    display: block !important;
}

.floating-cart-panel .floating-product-price {
    font-size: 18px;
    font-weight: 600;
    color: #ee4d2d;
    display: block !important;
}

/* 变体选择器 */
.floating-cart-panel .variations {
    margin: 10px 0;
    display: flex;
    gap: 15px;
}

.floating-cart-panel .variation-buttons {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.floating-cart-panel .variation-button {
    padding: 8px 20px;
    background: #fff;
    border: none;
    border-radius: 4px;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: #f1f1f1;
}

.floating-cart-panel .variation-button:hover {
    background-color: #e4e4e4;
}

.floating-cart-panel .variation-button.selected {
    background: #ff7043;
    color: #fff;
}

/* 右侧购物车控件 */
.floating-cart-panel .cart-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-left: 20px;
    border-left: 1px solid #eee;
}

.floating-cart-panel .quantity {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 40px;
    width: 140px;
    overflow: hidden;
}

.floating-cart-panel .quantity button {
    width: 40px;
    height: 100%;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 20px;
    color: #666;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    user-select: none;
}

.floating-cart-panel .quantity input {
    width: 60px;
    height: 100%;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 14px;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
    flex: 1;
}

/* 隐藏输入框的上下箭头 */
.floating-cart-panel .quantity input::-webkit-outer-spin-button,
.floating-cart-panel .quantity input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.floating-cart-panel .single_add_to_cart_button {
    position: relative;
    transition: all 0.3s ease;
}

.floating-cart-panel .single_add_to_cart_button.loading {
    opacity: 0.7;
}

.floating-cart-panel .single_add_to_cart_button.loading:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: button-loading-spinner 0.8s linear infinite;
}

.floating-cart-panel .single_add_to_cart_button.added {
    background-color: #4CAF50 !important;
}

@keyframes button-loading-spinner {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .floating-cart-panel .container {
        max-width: 100%;
        padding: 15px 20px;
    }
}

@media (max-width: 768px) {
    .floating-cart-panel .container {
        flex-direction: column;
        padding: 8px 12px;
        gap: 8px;
    }

    /* 第一行：产品基本信息 */
    .floating-cart-panel .product-info {
        display: flex;
        align-items: center;
        gap: 10px;
        border-bottom: 1px solid #eee;
        padding-bottom: 8px;
    }

    .floating-cart-panel .product-image {
        width: 40px;
        height: 40px;
        padding: 2px;
        flex-shrink: 0;
    }

    .floating-cart-panel .product-details {
        flex: 1;
        min-width: 0;
    }

    .floating-cart-panel .floating-product-title {
        font-size: 13px;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .floating-cart-panel .floating-product-price {
        font-size: 14px;
    }

    /* 第二行：操作区域 */
    .floating-cart-panel .cart-controls {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    /* 变体选择器 */
    .floating-cart-panel .variations-wrap {
        flex: 1;
        margin: 0;
    }

    .floating-cart-panel .variation-row {
        margin: 0;
    }

    .floating-cart-panel .variation-header {
        display: none; /* 隐藏变体标题 */
    }

    .floating-cart-panel .variation-buttons {
        display: none;
    }

    .floating-cart-panel .variation-select {
        height: 34px;
        padding: 0 8px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 13px;
        width: 100%;
    }

    /* 数量选择器 */
    .floating-cart-panel .quantity {
        height: 34px;
        width: 90px;
        flex-shrink: 0;
    }
    
    .floating-cart-panel .quantity button {
        width: 28px;
    }
    
    .floating-cart-panel .quantity input {
        width: 34px;
        font-size: 13px;
    }

    /* 加入购物车按钮 */
    .floating-cart-panel .single_add_to_cart_button {
        width: 34px;
        height: 34px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .floating-cart-panel .single_add_to_cart_button:before {
        content: "\f07a"; /* 购物车图标 */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 16px;
    }

    .floating-cart-panel .single_add_to_cart_button span {
        display: none; /* 隐藏文字 */
    }

    /* 调整底部空间 */
    body.has-floating-cart {
        padding-bottom: 110px;
    }

    .mobile-layout .floating-product-title {
        font-size: 13px;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #333;
        display: block !important;
    }

    .mobile-layout .floating-product-price {
        font-size: 14px;
        color: #ee4d2d;
        display: block !important;
    }

    .mobile-layout .single_add_to_cart_button {
        width: 34px;
        height: 34px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #ff7043;
        border: none;
        border-radius: 4px;
        color: #fff;
    }

    .mobile-layout .single_add_to_cart_button i {
        font-size: 16px;
    }

    .mobile-layout .single_add_to_cart_button.added {
        background: #4CAF50;
    }
}

/* 更小屏幕的优化 */
@media (max-width: 375px) {
    .floating-cart-panel .container {
        padding: 8px;
    }

    .floating-cart-panel .product-image {
        width: 40px;
        height: 40px;
    }

    .floating-cart-panel .variation-button {
        padding: 3px 10px;
        font-size: 11px;
    }
}

/* 添加变体标题和价格的样式 */
.floating-cart-panel .variation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.floating-cart-panel .variation-price {
    font-size: 16px;
    font-weight: 600;
    color: #ff7043;
}

.floating-cart-panel .variation-price .amount {
    color: #ff7043;
}

/* 调整变体行的间距 */
.floating-cart-panel .variation-row {
    margin-bottom: 15px;
}

.floating-cart-panel .variation-row:last-child {
    margin-bottom: 0;
}

/* 桌面端默认样式 */
.floating-cart-panel .mobile-variation {
    display: none;  /* 默认隐藏移动端下拉选择器 */
}

.floating-cart-panel .variation-buttons {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

/* 移动端样式 */
@media (max-width: 768px) {
    .floating-cart-panel .mobile-variation {
        display: block;  /* 显示移动端下拉选择器 */
    }

    .floating-cart-panel .variation-buttons {
        display: none;  /* 隐藏按钮式选择器 */
    }

    .floating-cart-panel .variation-select {
        width: 100%;
        padding: 6px 10px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 13px;
        background-color: #fff;
        margin-top: 4px;
    }

    /* 优化一行显示布局 */
    .floating-cart-panel .container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 15px;
        gap: 10px;
    }

    .floating-cart-panel .product-info {
        flex: 1;
        min-width: 0;
    }

    .floating-cart-panel .cart-controls {
        border: none;
        padding: 0;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }
}

/* 桌面端和移动端布局控制 */
.floating-cart-panel .mobile-layout {
    display: none;
}

.floating-cart-panel .desktop-layout {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 0;  /* 减小上下padding */
}

/* 桌面端样式 */
.desktop-layout .product-info {
    display: flex;
    align-items: center;
    gap: 15px;  /* 减小间距 */
    flex: 1;
}

.desktop-layout .product-image {
    width: 50px;  /* 减小图片宽度 */
    height: 68px;  /* 保持原图比例 */
    border-radius: 4px;
    border: 1px solid #eee;
    padding: 2px;
    object-fit: cover;  /* 保持图片比例 */
    cursor: pointer;  /* 添加手型光标 */
    transition: opacity 0.2s;
}

.desktop-layout .product-image:hover {
    opacity: 0.8;
}

.desktop-layout .product-details {
    flex: 1;
    min-width: 0;
}

/* 标题和价格一行显示 */
.desktop-layout .title-price-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;  /* 减小底部间距 */
}

.desktop-layout .floating-product-title {
    font-size: 14px;  /* 减小字体 */
    font-weight: 500;
    color: #333;
    margin: 0;
}

.desktop-layout .floating-product-price {
    font-size: 14px;
    font-weight: 600;
    color: #ee4d2d;
    margin: 0;
}

/* 变体按钮样式优化 */
.desktop-layout .variations-wrap {
    margin: 0;  /* 移除多余间距 */
}

.desktop-layout .variation-row {
    margin-bottom: 0;  /* 移除底部间距 */
}

.desktop-layout .variation-header {
    margin-bottom: 5px;  /* 减小间距 */
}

.desktop-layout .variation-buttons {
    display: flex;
    gap: 8px;
    margin: 0;
}

.desktop-layout .variation-button {
    padding: 4px 12px;  /* 减小按钮内边距 */
    font-size: 13px;  /* 减小字体 */
}

/* 右侧控制区域 */
.desktop-layout .cart-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 15px;
    border-left: 1px solid #eee;
}

.desktop-layout .quantity {
    height: 36px;
    width: 120px;
    display: flex;
    align-items: center;
}

.desktop-layout .quantity button {
    width: 36px;
    height: 100%;
    flex-shrink: 0;
}

.desktop-layout .quantity input {
    width: 48px;  /* 确保输入框有足够宽度 */
    height: 100%;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 14px;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.desktop-layout .single_add_to_cart_button {
    height: 36px;  /* 减小高度 */
    padding: 0 20px;
    font-size: 14px;
}

/* 桌面端标题和价格布局 */
.desktop-layout .title-price-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.desktop-layout .floating-product-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.desktop-layout .floating-product-price {
    font-size: 16px;
    font-weight: 600;
    color: #ee4d2d;
}

/* 移动端样式 */
@media (max-width: 768px) {
    .floating-cart-panel .desktop-layout {
        display: none;
    }

    .floating-cart-panel .mobile-layout {
        display: block;
    }

    .mobile-layout .product-info {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
        border-bottom: 1px solid #eee;
        padding-bottom: 8px;
    }

    .mobile-layout .product-image {
        width: 40px;
        height: 40px;
        padding: 2px;
        border: 1px solid #eee;
        border-radius: 4px;
    }

    .mobile-layout .product-details {
        flex: 1;
        min-width: 0;
    }

    .mobile-layout .floating-product-title {
        font-size: 13px;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #333;
    }

    .mobile-layout .floating-product-price {
        font-size: 14px;
        color: #ee4d2d;
        font-weight: 500;
    }

    .mobile-layout .cart-controls {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-layout .variation-select {
        flex: 1;
        height: 34px;
        padding: 0 8px;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 13px;
    }

    .mobile-layout .quantity {
        width: 90px;
        height: 34px;
    }

    .mobile-layout .single_add_to_cart_button {
        width: 34px;
        height: 34px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 使用WooCommerce自带的购物车图标 */
    .mobile-layout .single_add_to_cart_button:before {
        font-family: WooCommerce;
        content: "\e01d";
        font-size: 16px;
    }

    .mobile-layout .single_add_to_cart_button.added:before {
        content: "\e017";
    }

    .mobile-layout .single_add_to_cart_button span {
        display: none;
    }
}

/* 图片弹窗样式 */
.floating-cart-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-cart-lightbox .lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
}

.floating-cart-lightbox .lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    z-index: 1;
}

.floating-cart-lightbox img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.floating-cart-lightbox .close-lightbox {
    position: absolute;
    top: -40px;
    right: 0;
    color: #fff;
    font-size: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.floating-cart-lightbox .close-lightbox:hover {
    opacity: 0.8;
}

/* 移动端购物车按钮样式 */
.mobile-layout .cart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-layout .quantity {
    width: 90px;  /* 固定宽度 */
}

/* 有变体时的购物车按钮样式 */
.mobile-layout .single_add_to_cart_button.has-variations {
    width: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 没有变体时的购物车按钮样式 */
.mobile-layout .single_add_to_cart_button:not(.has-variations) {
    flex: 1;  /* 自动占用剩余空间 */
    padding: 0 15px;
    min-width: 120px;  /* 设置最小宽度 */
}

/* 购物车图标样式 */
.mobile-layout .single_add_to_cart_button.has-variations i {
    font-size: 16px;
}

/* 当有变体选择器时的布局 */
.mobile-layout .variations-wrap + .quantity {
    width: 90px;  /* 固定宽度 */
}

.mobile-layout .variations-wrap {
    flex: 1;  /* 变体选择器占用剩余空间 */
}

/* 当没有变体时的布局 */
.mobile-layout .cart-controls:not(:has(.variations-wrap)) {
    display: flex;
    justify-content: flex-end; /* 靠右对齐 */
    gap: 10px;
    padding-right: 15px; /* 右侧留出一些间距 */
}

.mobile-layout .cart-controls:not(:has(.variations-wrap)) .quantity {
    width: 60%; /* 数量选择器占60%宽度 */
    max-width: 200px; /* 限制最大宽度 */
}

.mobile-layout .cart-controls:not(:has(.variations-wrap)) .single_add_to_cart_button {
    width: 120px; /* 购物车按钮固定宽度 */
    flex: 0 0 auto;
}

/* 有变体时的布局保持不变 */
.mobile-layout .variations-wrap {
    flex: 0 0 40%; /* 固定为40%宽度 */
    min-width: 120px;
}

.mobile-layout .variations-wrap + .quantity,
.mobile-layout .variations-wrap ~ .single_add_to_cart_button {
    flex: 1; /* 平分剩余空间 */
    min-width: 90px;
}

/* 移动端布局调整 */
@media (max-width: 767px) {
    .floating-cart-panel .mobile-layout .cart-controls {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    /* 调整变体选择器宽度为五分之二 */
    .floating-cart-panel .mobile-layout .variations-wrap {
        flex: 0 0 40%; /* 固定为40%宽度 */
        min-width: 120px; /* 确保最小宽度 */
    }

    /* 数量选择器和添加购物车按钮平分剩余空间 */
    .floating-cart-panel .mobile-layout .quantity {
        flex: 1; /* 平分剩余空间 */
        min-width: 90px; /* 确保最小宽度 */
    }

    /* 调整添加到购物车按钮 */
    .floating-cart-panel .mobile-layout .single_add_to_cart_button {
        flex: 1; /* 平分剩余空间 */
        min-width: 90px; /* 确保最小宽度 */
        padding: 0 10px;
        white-space: nowrap;
    }
} 