/**
 * Body Pillow Plugin - 前端样式
 */

/* 删除了旧版本的展示样式，只保留新版本的表单字段样式 */

/* 图片画廊样式 */
.body-pillow-gallery-container {
    position: relative;
    overflow: hidden;
}

.body-pillow-gallery {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 10px 0;
    margin-top: 10px;
    /* 隐藏滚动条但保持滚动功能 */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.body-pillow-gallery::-webkit-scrollbar {
    height: 6px;
}

.body-pillow-gallery::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.body-pillow-gallery::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.body-pillow-gallery::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.body-pillow-gallery a {
    display: block;
    flex: 0 0 120px;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    outline: none;
    position: relative;
}

.body-pillow-gallery a.selected {
    border-color: #007cba;
    box-shadow: 0 0 10px rgba(0, 124, 186, 0.3);
}

.body-pillow-gallery a:active,
.body-pillow-gallery a:focus {
    outline: none;
    box-shadow: none;
}

.body-pillow-gallery a:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.2);
}

.body-pillow-gallery img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 8px;
}

.body-pillow-gallery a:hover img {
    transform: scale(1.05);
}

/* 图片选中状态 */
.body-pillow-gallery img.selected {
    border: none !important;
}

.body-pillow-gallery a:has(img.selected),
.body-pillow-gallery a img.selected {
    border-color: #007cba !important;
}

.body-pillow-gallery a:has(img.selected) {
    border: 3px solid #007cba !important;
    background: rgba(0, 124, 186, 0.1);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3) !important;
    transform: translateY(-2px);
}

/* 为不支持 :has() 的浏览器提供备用方案 */
.body-pillow-gallery a.selected-parent {
    border: 3px solid #007cba !important;
    background: rgba(0, 124, 186, 0.1);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3) !important;
    transform: translateY(-2px);
}

/* 选中状态指示器 */
.body-pillow-gallery a:has(img.selected):after,
.body-pillow-gallery a.selected-parent:after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #007cba;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .body-pillow-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .body-pillow-image-link img {
        height: 100px;
    }
}

@media (max-width: 480px) {
    .body-pillow-gallery {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 购物车和订单样式 */
.body-pillow-order-meta {
    margin: 5px 0;
    font-size: 13px;
    color: #666;
}

.body-pillow-order-meta strong {
    color: #333;
}

/* 购物车页面的自定义数据样式 */
.cart .woocommerce-cart-form .cart_item .body-pillow-meta {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.cart .woocommerce-cart-form .cart_item .body-pillow-meta strong {
    color: #333;
}

/* 结账页面的自定义数据样式 */
.checkout .woocommerce-checkout-review-order .body-pillow-meta {
    font-size: 12px;
    color: #666;
    margin-left: 10px;
}

/* 验证消息样式 */
.body-pillow-validation-message {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 禁用状态的添加到购物车按钮 */
.single_add_to_cart_button:disabled,
.single_add_to_cart_button.body-pillow-disabled,
button[name="add-to-cart"]:disabled,
button[name="add-to-cart"].body-pillow-disabled,
.add_to_cart_button:disabled,
.add_to_cart_button.body-pillow-disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    background-color: #ccc !important;
    border-color: #ccc !important;
    color: #999 !important;
    pointer-events: none !important;
}

.single_add_to_cart_button:disabled:hover,
.single_add_to_cart_button.body-pillow-disabled:hover,
button[name="add-to-cart"]:disabled:hover,
button[name="add-to-cart"].body-pillow-disabled:hover,
.add_to_cart_button:disabled:hover,
.add_to_cart_button.body-pillow-disabled:hover {
    background-color: #ccc !important;
    border-color: #ccc !important;
    color: #999 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* 选择反馈样式增强 */
.body-pillow-selection-feedback {
    font-weight: 500;
    line-height: 1.4;
}

/* 验证消息增强 */
.body-pillow-validation-message {
    font-weight: 500;
    border-left: 4px solid;
}

.body-pillow-validation-message.body-pillow-warning {
    border-left-color: #ffc107;
}

.body-pillow-validation-message.body-pillow-success {
    border-left-color: #28a745;
}

/* 表单字段样式 */
.body-pillow-form-fields {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    min-height: 250px; /* 设置最小高度以包含选择更多图片按钮 */
    position: relative;
}

.body-pillow-form-fields h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1em;
    font-weight: 600;
}

.body-pillow-options-table {
    width: 100%;
    border-collapse: collapse;
}

.body-pillow-options-table td {
    padding: 12px 8px;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

.body-pillow-options-table tr:last-child td {
    border-bottom: none;
}

.body-pillow-options-table label {
    display: block;
    margin-bottom: 0;
    font-weight: 600;
    color: #495057;
}

.body-pillow-options-table select {
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
    color: #495057;
    transition: all 0.3s ease;
}

.body-pillow-options-table select:hover {
    border-color: #007cba;
}

.body-pillow-options-table select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* 响应式表单 */
@media (max-width: 768px) {
    .body-pillow-options-table {
        display: block;
    }
    
    .body-pillow-options-table tr {
        display: block;
        margin-bottom: 15px;
        padding: 10px 0;
        border-bottom: 1px solid #e9ecef;
    }
    
    .body-pillow-options-table td {
        display: block;
        width: 100% !important;
        padding: 5px 0;
        border: none;
    }
    
    .body-pillow-options-table select {
        max-width: none;
        margin-top: 5px;
    }
}

/* 购物车产品图片增强样式 */
.woocommerce-cart-form table.cart .product-thumbnail {
    width: 100px !important;
    text-align: center;
    vertical-align: middle;
}

.body-pillow-cart-thumbnail {
    display: inline-block;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.body-pillow-cart-thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    text-decoration: none;
}

.body-pillow-cart-thumbnail img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    transition: all 0.3s ease;
    border: 2px solid #fff;
}

.body-pillow-cart-thumbnail:hover img {
    transform: scale(1.05);
    border-color: #007cba;
}

.body-pillow-no-image {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #6c757d;
    font-size: 11px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
    cursor: default;
}

.body-pillow-no-image:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: #adb5bd;
}

/* 迷你购物车图片样式 */
.woocommerce-mini-cart .mini_cart_item img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.woocommerce-mini-cart .mini_cart_item a:hover img {
    transform: scale(1.1);
}

.woocommerce-mini-cart .mini_cart_item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.woocommerce-mini-cart .mini_cart_item:last-child {
    border-bottom: none;
}

/* 购物车表格响应式增强 */
@media (max-width: 768px) {
    .woocommerce-cart-form table.cart .product-thumbnail {
        width: 80px !important;
    }
    
    .body-pillow-cart-thumbnail img,
    .body-pillow-no-image {
        width: 60px !important;
        height: 60px !important;
    }
    
    .woocommerce-cart-form table.cart th.product-thumbnail,
    .woocommerce-cart-form table.cart td.product-thumbnail {
        padding: 5px !important;
    }
}

@media (max-width: 480px) {
    .woocommerce-cart-form table.cart .product-thumbnail {
        width: 60px !important;
    }
    
    .body-pillow-cart-thumbnail img,
    .body-pillow-no-image {
        width: 50px !important;
        height: 50px !important;
    }
    
    .body-pillow-no-image {
        font-size: 10px;
    }
}

/* 3D模型上传相关样式 */
.body-pillow-3d-models {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.body-pillow-3d-models h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1em;
    font-weight: 600;
}

.body-pillow-3d-model-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.body-pillow-3d-model-item:last-child {
    margin-bottom: 0;
}

.body-pillow-3d-model-title {
    font-weight: 600;
    color: #343a40;
    margin-bottom: 10px;
}

.body-pillow-3d-model-info {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 8px;
}

.body-pillow-3d-model-actions {
    margin-top: 10px;
}

.body-pillow-3d-model-download {
    display: inline-block;
    padding: 6px 12px;
    background: #007cba;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

.body-pillow-3d-model-download:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .body-pillow-3d-models {
        padding: 15px;
        margin: 15px 0;
    }
    
    .body-pillow-3d-model-item {
        padding: 12px;
    }
}

/* 平面模型相关样式 */
.body-pillow-2d-models {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.body-pillow-2d-models h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1em;
    font-weight: 600;
}

.body-pillow-2d-model-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

.body-pillow-2d-model-item:last-child {
    margin-bottom: 0;
}

.body-pillow-2d-model-title {
    font-weight: 600;
    color: #343a40;
    margin-bottom: 10px;
}

.body-pillow-2d-model-info {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 8px;
}

.body-pillow-2d-model-preview {
    margin: 10px 0;
    text-align: center;
}

.body-pillow-2d-model-preview img {
    max-width: 200px;
    max-height: 150px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.body-pillow-2d-model-actions {
    margin-top: 10px;
}

.body-pillow-2d-model-download {
    display: inline-block;
    padding: 6px 12px;
    background: #28a745;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
    margin-right: 8px;
}

.body-pillow-2d-model-download:hover {
    background: #218838;
    color: white;
    text-decoration: none;
}

.body-pillow-2d-model-view {
    display: inline-block;
    padding: 6px 12px;
    background: #007cba;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

.body-pillow-2d-model-view:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .body-pillow-2d-models {
        padding: 15px;
        margin: 15px 0;
    }
    
    .body-pillow-2d-model-item {
        padding: 12px;
    }
    
    .body-pillow-2d-model-preview img {
        max-width: 150px;
        max-height: 100px;
    }
}