/* ========================================
   Product Quick View Modal Styles
   独立样式文件，避免与 style.css 冲突
   ======================================== */

/* ========================================
   1. Modal 基础样式
   ======================================== */

/* Modal 容器 */
.product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999; /* 低于导航栏，桌面端居中，移动端在导航栏下方 */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    align-items: center;
    justify-content: center;
}

.product-modal.show {
    display: flex;
    opacity: 1;
}

/* 背景遮罩 */
.product-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Modal 主体 */
.product-modal-content {
    position: relative;
    background: #FAF9F6;
    max-width: 1500px; /* 增加宽度以容纳放大区域 */
    width: 95%;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 1;
}

.product-modal.show .product-modal-content {
    transform: scale(1);
}

/* 关闭按钮 */
.product-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    padding: 0;
}

/* X 图标容器 */
.product-modal-close::before,
.product-modal-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2.5px;
    background-color: #333;
    transition: all 0.2s ease;
}

/* 第一条线 (左上到右下) */
.product-modal-close::before {
    transform: rotate(45deg);
}

/* 第二条线 (右上到左下) */
.product-modal-close::after {
    transform: rotate(-45deg);
}

/* 移除默认焦点样式 */
.product-modal-close:focus {
    outline: none;
}

/* 悬停和焦点效果 */
.product-modal-close:hover,
.product-modal-close:focus {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.product-modal-close:hover::before,
.product-modal-close:hover::after,
.product-modal-close:focus::before,
.product-modal-close:focus::after {
    background-color: #000;
}

/* Modal Body */
.product-modal-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 90vh;
}

/* ========================================
   2. 媒体展示区
   ======================================== */

.product-media-section {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #fff;
}

/* 主展示区 */
.product-main-display {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fff;
    border-radius: 8px;
    overflow: hidden; /* 图片需要裁切 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 桌面端（≥1024px）：允许放大区域溢出 */
@media (min-width: 1024px) {
    .product-main-display {
        overflow: visible; /* 允许 zoom-result 显示在右侧 */
    }
    
    /* 但图片和视频仍需要裁切，所以单独设置 */
    .product-main-image,
    .product-main-video {
        border-radius: 8px;
        overflow: hidden;
    }
}

.product-main-image,
.product-main-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.product-main-image.active,
.product-main-video.active {
    display: block;
}

/* ========================================
   3. 缩略图导航条（响应式方向）
   ======================================== */

/* 竖屏设备（<768px）：横向排列 */
@media (max-width: 767px) {
    .product-thumbnails {
        display: flex;
        flex-direction: row;
        gap: 10px;
        margin-top: 15px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }
    
    .product-media-section {
        flex-direction: column;
    }
}

/* 平板端（768px-1279px）：横向排列缩略图 */
@media (min-width: 768px) and (max-width: 1279px) {
    .product-thumbnails {
        display: flex;
        flex-direction: row;
        gap: 10px;
        margin-bottom: 15px;
        overflow-x: auto;
        overflow-y: visible; /* 允许阴影溢出 */
        padding: 4px 0 12px 0; /* 顶4px，底12px，给阴影足够空间 */
        width: 100%;
    }
    
    .product-media-section {
        flex-direction: column;
    }
}

/* 桌面端（≥1280px）：竖向排列缩略图 */
@media (min-width: 1280px) {
    .product-thumbnails {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-right: 15px;
        overflow-y: auto;
        overflow-x: visible; /* 允许阴影溢出 */
        max-height: 600px;
        padding: 0 12px 0 4px; /* 左4px，右12px，给阴影足够空间 */
        width: 110px; /* 增加到 110px：80px缩略图 + 4px边框 + 左右各留空间 */
        min-width: 110px; /* 确保最小宽度 */
        flex-shrink: 0; /* 防止被压缩 */
    }
    
    .product-media-section {
        flex-direction: row;
    }
}

/* 缩略图样式 */
.product-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: #fff;
}

.product-thumbnail.active {
    border-color: #495057;
    box-shadow: 0 2px 8px rgba(73, 80, 87, 0.3);
}

.product-thumbnail:hover {
    border-color: #6c757d;
    /* 移除 scale 效果避免溢出，改用阴影和透明度 */
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
    opacity: 0.9;
}

/* 视频缩略图标识 */
/* 视频缩略图容器 */
.product-thumbnail-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    overflow: hidden;
}

.product-thumbnail-wrapper.active {
    border-color: #495057;
    box-shadow: 0 2px 8px rgba(73, 80, 87, 0.3);
}

.product-thumbnail-wrapper:hover {
    border-color: #6c757d;
    box-shadow: 0 4px 12px rgba(73, 80, 87, 0.2);
}

.product-thumbnail-wrapper .product-thumbnail {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    cursor: pointer;
}

/* 视频播放图标 */
.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    pointer-events: none;
    z-index: 10;
    transition: transform 0.2s ease;
}

.video-play-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* 悬停效果 */
.product-thumbnail-wrapper:hover .video-play-icon {
    transform: translate(-50%, -50%) scale(1.15);
}

.product-thumbnail-wrapper:hover .video-play-icon circle {
    fill: rgba(0, 0, 0, 0.85);
}

/* 自定义滚动条样式 */
.product-thumbnails::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.product-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.product-thumbnails::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.product-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   4. 图片局部放大功能（展示区内 - 电商风格）
   ======================================== */

/* 桌面端图片放大容器 - 只在大屏（≥1024px）启用 */
/* 实际是否启用由 JavaScript 根据触屏检测决定 */
@media (min-width: 1024px) {
    .product-main-image {
        cursor: crosshair;
    }
    
    /* 方形遮罩层（指示放大区域） */
    .zoom-lens {
        position: absolute;
        border: 2px solid rgba(0, 0, 0, 0.3);
        background-color: rgba(255, 255, 255, 0.3);
        cursor: none;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        z-index: 10;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    
    .zoom-lens.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* 右侧放大展示区域 */
    .zoom-result {
        position: absolute; /* 相对于 product-modal-body 定位 */
        /* 位置由 JavaScript 动态计算 */
        border: 1px solid #e9ecef;
        background-color: #fff;
        background-repeat: no-repeat;
        background-size: 200%; /* 2倍放大 */
        opacity: 0;
        visibility: hidden;
        z-index: 100; /* 在产品信息区上方 */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        overflow: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
        pointer-events: none; /* 不响应鼠标事件，避免遮挡下方内容交互 */
    }
    
    .zoom-result.active {
        opacity: 1;
        visibility: visible;
    }
}

/* 小屏设备（<1024px）禁用放大功能 */
@media (max-width: 1023px) {
    .product-main-image {
        cursor: default;
    }
    
    .zoom-lens,
    .zoom-result {
        display: none !important; /* 完全隐藏，不占用空间 */
    }
}

/* ========================================
   5. 视频播放控制
   ======================================== */

.product-main-video {
    cursor: default;
}

.product-main-video::-webkit-media-controls-fullscreen-button {
    display: inline-block;
}

/* ========================================
   6. 产品信息区
   ======================================== */

.product-info-section {
    padding: 30px;
    overflow-y: auto;
    background: #FAF9F6;
}

.product-title {
    font-family: 'League Spartan', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    line-height: 1.3;
}

.product-price {
    font-size: 24px;
    font-weight: bold;
    color: #495057;
    margin-bottom: 20px;
}

.product-price.free {
    color: #28a745;
}

.product-description {
    font-size: 16px;
    line-height: 1.6;
    color: #6c757d;
    margin-bottom: 25px;
}

/* 规格表格 */
.product-specifications {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 14px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.product-specifications th,
.product-specifications td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.product-specifications th {
    font-weight: 600;
    background: #f8f9fa;
    color: #495057;
    width: 35%;
}

.product-specifications td {
    color: #6c757d;
}

.product-specifications tr:last-child td,
.product-specifications tr:last-child th {
    border-bottom: none;
}

.product-specifications tbody tr:hover {
    background: #f8f9fa;
}

/* 变体选择器 */
.variant-selector {
    margin: 20px 0;
    padding: 16px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.variant-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 10px;
}

.variant-label::before {
    content: '📦 ';
    margin-right: 4px;
}

.variant-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 500;
    font-family: 'League Spartan', sans-serif;
    border: 2px solid #7F9688;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.variant-select:hover {
    border-color: #5a7566;
    box-shadow: 0 4px 8px rgba(127, 150, 136, 0.15);
}

.variant-select:focus {
    outline: none;
    border-color: #7F9688;
    box-shadow: 0 0 0 4px rgba(127, 150, 136, 0.15);
}

.variant-select option {
    padding: 10px;
    font-weight: 500;
}

.variant-select option:disabled {
    color: #9ca3af;
    font-style: italic;
}

.variant-select option:checked {
    background: #7F9688;
    color: white;
}

/* 操作按钮区 */
.product-actions {
    margin-top: 25px;
}

.product-actions .btn-add-to-cart {
    width: 100%; /* 全宽按钮 */
    padding: 14px 30px; /* 稍微增加垂直内边距，让按钮更突出 */
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    text-align: center;
    background: #7F9688;
    color: #fff;
}

.product-actions .btn-add-to-cart:hover:not(:disabled) {
    background: rgba(127, 150, 136, 0.85);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(127, 150, 136, 0.4);
}

.product-actions .btn-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   7. 响应式布局
   ======================================== */

/* 平板端（768px-991px）：单栏布局 */
@media (min-width: 768px) and (max-width: 991px) {
    /* 平板端 Modal 下移，避开导航栏 */
    .product-modal {
        top: 60px; /* 平板端导航栏高度为 60px */
        height: calc(100vh - 60px);
        align-items: flex-start; /* 从顶部对齐，不居中 */
    }
    
    /* 平板端隐藏遮罩，保持导航栏可交互 */
    .product-modal-backdrop {
        display: none;
    }
    
    .product-modal-content {
        width: 90%;
        max-width: 900px;
        height: calc(100vh - 60px);
        max-height: calc(100vh - 60px);
        border-top: 1px solid #e9ecef; /* 区分导航栏和内容 */
    }
    
    .product-modal-body {
        flex-direction: column;
        max-height: calc(100vh - 60px);
        overflow-y: auto; /* 允许垂直滚动 */
        overflow-x: hidden; /* 禁止横向滚动 */
        padding: 0; /* 移除padding，让子元素独立控制 */
    }
    
    .product-media-section {
        width: 100%;
        padding: 30px;
        flex-shrink: 0; /* 防止内容被压缩 */
        border-bottom: 1px solid #e9ecef;
    }
    
    .product-info-section {
        width: 100%;
        padding: 30px;
        max-height: none; /* 移除高度限制 */
        overflow-y: visible; /* 不需要独立滚动 */
        flex-shrink: 0; /* 防止内容被压缩 */
        border-left: none; /* 移除左边框 */
    }
}

/* 中等平板/小桌面（992px-1279px）：单栏布局 */
@media (min-width: 992px) and (max-width: 1279px) {
    /* Modal 下移，避开导航栏 */
    .product-modal {
        top: 80px; /* 导航栏高度为 80px */
        height: calc(100vh - 80px);
        align-items: flex-start; /* 从顶部对齐，不居中 */
    }
    
    /* 隐藏遮罩，保持导航栏可交互 */
    .product-modal-backdrop {
        display: none;
    }
    
    .product-modal-content {
        width: 90%;
        max-width: 1000px;
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        border-top: 1px solid #e9ecef; /* 区分导航栏和内容 */
    }
    
    .product-modal-body {
        flex-direction: column;
        max-height: calc(100vh - 80px);
        overflow-y: auto; /* 允许垂直滚动 */
        overflow-x: hidden; /* 禁止横向滚动 */
        padding: 0;
    }
    
    .product-media-section {
        width: 100%;
        padding: 30px;
        flex-shrink: 0; /* 防止内容被压缩 */
        border-bottom: 1px solid #e9ecef;
    }
    
    .product-info-section {
        width: 100%;
        padding: 30px;
        max-height: none; /* 移除高度限制 */
        overflow-y: visible; /* 不需要独立滚动 */
        flex-shrink: 0; /* 防止内容被压缩 */
        border-left: none; /* 移除左边框 */
    }
}

/* 桌面端（≥1280px）：两栏布局 + zoom功能 */
@media (min-width: 1280px) {
    .product-modal-body {
        position: relative; /* 为 zoom-result 提供定位上下文 */
        flex-direction: row;
        overflow-y: auto;
    }
    
    .product-media-section {
        flex: 1 1 50%; /* 减少宽度，为放大区域留出空间 */
        padding: 30px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .product-info-section {
        flex: 1 1 35%; /* 减少宽度，为放大区域留出空间 */
        max-height: 90vh;
        overflow-y: auto;
        border-left: 1px solid #e9ecef;
    }
}

/* 小屏手机（481px-767px）：单栏堆叠 */
@media (min-width: 481px) and (max-width: 767px) {
    /* Modal 下移，避开导航栏 */
    .product-modal {
        top: 50px; /* 导航栏高度为 50px */
        height: calc(100vh - 50px);
        align-items: flex-start;
    }
    
    /* 隐藏遮罩，保持导航栏可交互 */
    .product-modal-backdrop {
        display: none;
    }
    
    .product-modal-content {
        width: 100%;
        height: calc(100vh - 50px);
        max-height: calc(100vh - 50px);
        border-radius: 0;
        max-width: 100%;
        border-top: 1px solid #e9ecef;
    }
    
    .product-modal-body {
        flex-direction: column;
        max-height: calc(100vh - 50px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .product-media-section,
    .product-info-section {
        padding: 20px;
        flex-shrink: 0;
    }
    
    .product-media-section {
        width: 100%;
    }
    
    .product-info-section {
        max-height: none;
        overflow-y: visible;
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .product-title {
        font-size: 24px;
    }
    
    .product-price {
        font-size: 20px;
    }
    
    .product-modal-close {
        width: 48px;
        height: 48px;
        top: 10px;
        right: 10px;
        background: rgba(255, 255, 255, 0.98);
        z-index: 150;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    }
    
    .product-modal-close::before,
    .product-modal-close::after {
        width: 22px;
        height: 3px;
    }
    
    .product-modal-close:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 1);
    }
    
    .product-modal-close:active::before,
    .product-modal-close:active::after {
        background-color: #000;
    }
}

/* 更小屏手机（361px-480px）*/
@media (min-width: 361px) and (max-width: 480px) {
    /* Modal 下移，避开导航栏 */
    .product-modal {
        top: 45px; /* 导航栏高度为 45px */
        height: calc(100vh - 45px);
        align-items: flex-start;
    }
    
    .product-modal-backdrop {
        display: none;
    }
    
    .product-modal-content {
        width: 100%;
        height: calc(100vh - 45px);
        max-height: calc(100vh - 45px);
        border-radius: 0;
        max-width: 100%;
        border-top: 1px solid #e9ecef;
    }
    
    .product-modal-body {
        flex-direction: column;
        max-height: calc(100vh - 45px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .product-media-section,
    .product-info-section {
        padding: 18px;
        flex-shrink: 0;
    }
    
    .product-media-section {
        width: 100%;
    }
    
    .product-info-section {
        max-height: none;
        overflow-y: visible;
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .product-title {
        font-size: 22px;
    }
    
    .product-price {
        font-size: 19px;
    }
    
    .product-modal-close {
        width: 46px;
        height: 46px;
        top: 8px;
        right: 8px;
    }
    
    .product-modal-close::before,
    .product-modal-close::after {
        width: 20px;
        height: 2.5px;
    }
}

/* 超小屏手机（≤360px）*/
@media (max-width: 360px) {
    /* Modal 下移，避开导航栏 */
    .product-modal {
        top: 40px; /* 导航栏高度为 40px */
        height: calc(100vh - 40px);
        align-items: flex-start;
    }
    
    .product-modal-backdrop {
        display: none;
    }
    
    .product-modal-content {
        width: 100%;
        height: calc(100vh - 40px);
        max-height: calc(100vh - 40px);
        border-radius: 0;
        max-width: 100%;
        border-top: 1px solid #e9ecef;
    }
    
    .product-modal-body {
        flex-direction: column;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .product-media-section,
    .product-info-section {
        padding: 15px;
        flex-shrink: 0;
    }
    
    .product-media-section {
        width: 100%;
    }
    
    .product-info-section {
        max-height: none;
        overflow-y: visible;
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .product-title {
        font-size: 20px;
    }
    
    .product-price {
        font-size: 18px;
    }
    
    .product-modal-close {
        width: 44px;
        height: 44px;
        top: 6px;
        right: 6px;
    }
    
    .product-modal-close::before,
    .product-modal-close::after {
        width: 18px;
        height: 2.5px;
    }
}

/* ========================================
   8. 加载和动画效果
   ======================================== */

/* 图片加载占位 */
.product-main-display::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #495057;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-main-display.loading::before {
    opacity: 1;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 平滑淡入淡出 */
.product-main-image,
.product-main-video {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   9. 可访问性增强
   ======================================== */

/* 焦点样式 */
.product-thumbnail:focus,
.product-actions .btn:focus {
    outline: 2px solid #495057;
    outline-offset: 2px;
}

/* 键盘导航提示 */
.keyboard-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.product-modal.show .keyboard-hint {
    opacity: 1;
}

/* 移动端隐藏键盘提示 */
@media (max-width: 767px) {
    .keyboard-hint {
        display: none;
    }
}

/* 触屏设备隐藏键盘提示 */
.product-modal.touch-device .keyboard-hint {
    display: none !important;
}

/* ========================================
   10. 性能优化
   ======================================== */

/* GPU 加速 */
.product-modal-content,
.product-main-image,
.product-main-video,
.product-thumbnail {
    will-change: transform;
}

.product-modal.show .product-modal-content,
.product-modal.show .product-main-image,
.product-modal.show .product-main-video {
    will-change: auto;
}

/* 减少重绘 */
.product-modal *,
.product-modal *::before,
.product-modal *::after {
    box-sizing: border-box;
}

/* ========================================
   11. 打印样式
   ======================================== */

@media print {
    .product-modal {
        display: none !important;
    }
}

