/* 自定义工具类 */
@layer utilities {
    .content-auto { 
        content-visibility: auto; 
    }
    
    .model-container { 
        @apply relative w-full h-screen bg-light overflow-hidden; 
    }
    
    .ar-button { 
        @apply fixed bottom-8 left-8 py-2 px-4 rounded bg-primary text-white shadow-lg flex items-center justify-center transition-all duration-300 hover:scale-110 active:scale-95 z-50 text-sm; 
    }
    
    .loading-overlay { 
        @apply absolute inset-0 bg-white/80 flex flex-col items-center justify-center z-40 transition-opacity duration-500; 
    }
}

/* 基础样式重置和定义 */
body {
    @apply bg-dark text-dark overflow-hidden;
}

/* 按钮容器样式 */
#button-container {
    @apply fixed bottom-8 right-8 z-40 flex flex-col gap-3;
}

/* 加载动画样式 */
.loading-overlay .animate-spin {
    @apply w-16 h-16 border-4 border-primary border-t-transparent rounded-full;
}

.loading-overlay p {
    @apply mt-4 text-lg font-medium;
}

.loading-overlay #loading-progress {
    @apply text-sm text-gray-600 mt-2;
}

/* 模型容器样式 */
#model-container canvas {
    display: block;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .ar-button {
        @apply bottom-6 left-6 py-1.5 px-3 text-xs;
    }
    
    #button-container {
        @apply bottom-6 right-6 gap-2;
    }
}

/* 侧边栏样式 */
/* 侧边栏按钮样式 */
.hover-menu {
    position: fixed;
    left: 10px;
    top: 5%;
    transform: translateY(-50%);
    background: white;
    border-radius: 10px;
    width: auto;
    min-width: 100px;
    /* 按钮高度 */
    height: 75px;
    min-height: auto;
    padding: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    border: none;
}

.hover-menu:hover {
    transform: translateY(-50%);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* 完全隐藏悬浮内容 */
.hover-menu img.logo {
    display: none;
}

/* 移除悬浮内容显示效果，保持按钮简洁 */
.hover-menu:hover img.logo {
    opacity: 0;
    transform: translateY(-50%) translateX(10px);
}

.hover-menu svg.icon {
    width: 24px;
    height: 24px;
    transition: none;
}

/* 确保SVG图标在鼠标悬浮时不发生任何变化 */
.hover-menu:hover svg.icon {
    transform: none !important;
    fill: black !important;
}

/* 确保SVG图标元素内的黑色填充不变 */
.hover-menu svg.icon rect {
    fill: black !important;
}

.hover-menu:hover svg.icon rect {
    fill: black !important;
}

/* 侧边栏面板样式 */
.side-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.side-panel[open="true"] {
    transform: translateX(0);
}

.side-panel .background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(249,249,249,1) 100%);
    z-index: -1;
}

.side-panel .content {
    position: relative;
    padding: 30px;
    height: 100%;
    box-sizing: border-box;
}

.side-panel .content svg.icon {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.side-panel .content svg.icon:hover {
    transform: rotate(90deg);
}

.side-panel .content img.logo {
    width: 200px;
    height: 24px;
    margin-bottom: 30px;
}

.side-panel .content h1 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
}

.side-panel .content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
}

.side-panel .content ul li {
    font-size: 15px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.6;
    position: relative;
    padding-left: 20px;
}

.side-panel .content ul li:before {
    content: "•";
    color: #EE7800;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.side-panel .divider {
    height: 1px;
    background: #eee;
    margin: 20px 0;
}

.side-panel .feature {
    margin-bottom: 30px;
}

.side-panel .feature h2 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.side-panel .feature h2 img {
    width: 24px;
    height: 24px;
    margin-right: 10px;
}

.side-panel .feature ul {
    margin-left: 34px;
}

/* 响应式设计 - 侧边栏相关 */
@media (max-width: 768px) {
    .side-panel {
        width: 100%;
    }
    
    .hover-menu {
        left: 10px;
        width: 50px;
        height: 50px;
        border: none;
    }
    
    .hover-menu:hover {
        transform: translateY(-50%);
    }
    
    /* 完全隐藏小屏幕上的悬浮内容 */
    .hover-menu img.logo {
        display: none;
    }
    
    /* 确保小屏幕上SVG图标在鼠标悬浮时保持黑色 */
    .hover-menu:hover svg.icon {
        transform: none !important;
        fill: black !important;
    }
    
    .hover-menu svg.icon rect {
        fill: black !important;
    }
    
    .hover-menu:hover svg.icon rect {
        fill: black !important;
    }
}

/* antp图标样式 - 确保在按钮左侧显示 */
.antp-icon {
    width: 150px;
    height: 150px;
    margin-right: 10px;
    vertical-align: middle;
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay[active="true"] {
    opacity: 1;
    pointer-events: auto;
}

/* AR二维码按钮样式 */
#ardata-canvas-container #new-qr-button-container {
    position: absolute !important;
    bottom: 20px !important;
    left: 20px !important;
    z-index: 100 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;  /* 禁止换行 */
    align-items: center !important;
    white-space: nowrap !important;
}

#new-qr-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background-color: rgba(0, 0, 0, 0.2);  /* 与其他按钮一致的半透明黑色背景 */
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;  /* 白色文字 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);  /* 与其他按钮一致的阴影 */
    transition: all 0.3s ease;
}

#new-qr-button:hover {
    background-color: #45a049;  /* 与其他按钮一致的悬停颜色 */
    color: #fff;
}

#new-qr-button i.fa-qrcode {
    font-size: 18px;
}

/* 悬浮二维码容器样式 */
#ardata-canvas-container #new-qr-float-container {
    position: absolute !important;
    bottom: 80px !important;
    left: 20px !important;
    z-index: 101 !important;
    background: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
    padding: 20px !important;
    display: none;  /* 移除!important，允许JavaScript控制显示 */
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}

/* 二维码指示箭头 */
.qr-arrow {
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

/* 二维码容器样式 */
#new-qr-code {
    width: 240px;
    height: 240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

#new-qr-code img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
}

/* 二维码状态提示样式 */
.qr-status-message {
    width: 180px;
    height: 180px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    text-align: center;
}

/* 响应式调整 - 移动端优化按钮 */
@media (max-width: 768px) {
    /* 按钮容器 - 更小的间距，禁止换行 */
    #ardata-canvas-container #new-qr-button-container {
        bottom: 12px !important;
        left: 12px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }
    
    /* 所有按钮 - 只显示图标，圆形小按钮 */
    #new-qr-button,
    #fullscreen-button,
    #reset-view-button,
    #share-button,
    .ardata-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 0 !important;
        border-radius: 50% !important;  /* 圆形按钮 */
        font-size: 16px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
        flex-shrink: 0 !important;  /* 防止被压缩 */
        overflow: hidden !important;
        white-space: nowrap !important;
        cursor: pointer !important;  /* 确保显示指针 */
        pointer-events: auto !important;  /* 确保可点击 */
        touch-action: manipulation !important;  /* 优化触摸响应 */
        -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;  /* 触摸反馈 */
    }
    
    /* 隐藏按钮文字，只保留图标 */
    #new-qr-button i,
    #fullscreen-button i,
    #reset-view-button i,
    #share-button i,
    .ardata-btn i {
        margin: 0 !important;
        font-size: 18px !important;
    }
    
    /* 隐藏按钮中的文字节点 */
    #new-qr-button::after,
    #fullscreen-button::after,
    #reset-view-button::after,
    #share-button::after {
        content: none !important;
    }
    
    /* 二维码悬浮容器 */
    #ardata-canvas-container #new-qr-float-container {
        bottom: 60px !important;
        left: 12px !important;
        padding: 12px !important;
    }
    
    /* 二维码尺寸 */
    #new-qr-code {
        width: 180px !important;
        height: 180px !important;
    }
    
    /* 确保图标在按钮中央 */
    #new-qr-button .fa,
    #fullscreen-button .fa,
    #reset-view-button .fa,
    #share-button .fa,
    .ardata-btn .fa {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        line-height: 40px !important;
        text-align: center !important;
    }
    
    /* 分享链接容器在移动端的位置和样式优化 */
    #ardata-canvas-container #share-link-container {
        position: fixed !important;  /* 使用fixed避免被容器裁切 */
        bottom: 60px !important;
        left: 12px !important;
        right: 12px !important;
        max-width: calc(100vw - 24px) !important;
        width: auto !important;
        padding: 16px !important;
        box-sizing: border-box !important;
        z-index: 10000 !important;  /* 确保在所有内容之上 */
    }
    
    /* 分享链接内容区域 */
    .share-link-content,
    .embed-code-section {
        width: 100% !important;
        min-width: 0 !important;
    }
    
    /* 输入框和文本域 */
    #share-link-input,
    #embed-code-input {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 14px !important;
        padding: 8px !important;
    }
    
    /* 复制按钮 */
    #copy-link-button,
    #copy-embed-button {
        width: 100% !important;
        margin-top: 8px !important;
    }
    
    /* 分享箭头位置调整 */
    .share-arrow {
        left: 60px !important;  /* 对齐分享按钮 */
    }
    
    /* 移动端只保留AR按钮和还原按钮，隐藏全屏和分享按钮 */
    #fullscreen-button,
    #share-button {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        min-width: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 0 !important;
    }
}

/* 物体打散侧边栏容器 - 3D窗口左侧中间 */
#ardata-canvas-container .explode-sidebar-container {
    position: absolute !important;        /* 绝对定位，相对于3D容器 */
    top: 50% !important;                  /* 垂直居中定位 */
    left: 0 !important;                   /* 贴着3D容器左边 */
    width: 60px !important;               /* 侧边栏宽度 */
    height: 200px !important;             /* 固定高度，不占据整个左侧 */
    transform: translateY(-50%) !important; /* 垂直居中对齐 */
    display: flex !important;             /* 弹性布局 */
    align-items: center !important;       /* 垂直居中 */
    justify-content: center !important;   /* 水平居中 */
    z-index: 100 !important;              /* 层级与按钮容器一致 */
    pointer-events: none !important;      /* 容器不拦截鼠标事件 */
    user-select: none !important;         /* 禁止文本选择 */
    background: transparent !important;   /* 透明背景 */
}

/* 侧边栏内容 */
#ardata-canvas-container .explode-sidebar-content {
    display: flex !important;             /* 弹性布局 */
    flex-direction: column !important;    /* 垂直排列 */
    align-items: center !important;       /* 水平居中 */
    gap: 10px !important;                 /* 元素间距 */
    pointer-events: auto !important;      /* 内容允许鼠标事件 */
}

/* 滑块包装器 */
#ardata-canvas-container .explode-slider-wrapper {
    display: flex !important;             /* 弹性布局 */
    align-items: center !important;       /* 居中对齐 */
    justify-content: center !important;   /* 居中对齐 */
    height: 150px !important;             /* 滑块区域高度 */
    width: 40px !important;               /* 滑块区域宽度 */
}

/* 垂直滑块样式 - 使用现代标准写法 */
#ardata-canvas-container .explode-vertical-slider {
    appearance: none !important;          /* 移除浏览器默认样式 */
    width: 6px !important;                /* 滑块轨道宽度 */
    height: 120px !important;             /* 滑块高度 */
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), rgba(255,255,255,0.5)) !important; /* 渐变轨道 */
    border: none !important;              /* 移除边框 */
    border-radius: 3px !important;        /* 轨道圆角 */
    outline: none !important;             /* 移除焦点轮廓 */
    cursor: pointer !important;           /* 鼠标指针样式 */
    transition: all 0.2s ease !important; /* 平滑过渡效果 */
    /* 垂直滑块实现 - 现代标准方式 */
    writing-mode: vertical-lr !important; /* 垂直书写模式（标准） */
    direction: rtl !important;            /* 从右到左方向，配合vertical-lr实现垂直滑块 */
    touch-action: none !important;        /* 阻止触摸时的浏览器默认行为（如滚动） */
}

/* WebKit浏览器垂直滑块按钮样式 */
.explode-vertical-slider::-webkit-slider-thumb {
    -webkit-appearance: none;  /* 移除默认样式 */
    appearance: none;          /* 移除默认样式 */
    width: 14px;               /* 按钮宽度 */
    height: 14px;              /* 按钮高度 */
    background: #3498db;       /* 蓝色背景 */
    border-radius: 50%;        /* 圆形按钮 */
    cursor: pointer;           /* 鼠标指针样式 */
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.5), 0 0 0 2px rgba(255, 255, 255, 0.9); /* 阴影和白色边框 */
    transition: all 0.2s ease; /* 平滑过渡效果 */
}

/* WebKit滑块按钮悬停效果 */
.explode-vertical-slider::-webkit-slider-thumb:hover {
    background: #2980b9;      /* 悬停时深蓝色背景 */
    transform: scale(1.2);    /* 放大1.2倍 */
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.7), 0 0 0 3px rgba(255, 255, 255, 1); /* 增强阴影和边框 */
}

/* WebKit滑块按钮激活效果 */
.explode-vertical-slider::-webkit-slider-thumb:active {
    transform: scale(1.3);    /* 点击时放大1.3倍 */
    background: #1c6ea4;      /* 更深的蓝色 */
}

/* Firefox浏览器垂直滑块按钮样式 */
.explode-vertical-slider::-moz-range-thumb {
    width: 14px;               /* 按钮宽度 */
    height: 14px;              /* 按钮高度 */
    background: #3498db;       /* 蓝色背景 */
    border-radius: 50%;        /* 圆形按钮 */
    cursor: pointer;           /* 鼠标指针样式 */
    border: 2px solid rgba(255, 255, 255, 0.9); /* 白色边框 */
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.5); /* 阴影效果 */
    transition: all 0.2s ease; /* 平滑过渡效果 */
}

/* Firefox滑块按钮悬停效果 */
.explode-vertical-slider::-moz-range-thumb:hover {
    background: #2980b9;      /* 悬停时深蓝色背景 */
    transform: scale(1.2);    /* 放大1.2倍 */
    border: 3px solid rgba(255, 255, 255, 1); /* 增强白色边框 */
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.7); /* 增强阴影效果 */
}

/* Firefox滑块按钮激活效果 */
.explode-vertical-slider::-moz-range-thumb:active {
    transform: scale(1.3);    /* 点击时放大1.3倍 */
    background: #1c6ea4;      /* 更深的蓝色 */
}

/* 打散值显示样式 */
.explode-value-display {
    background: rgba(0, 0, 0, 0.7); /* 半透明黑色背景 */
    color: #fff;              /* 白色文字 */
    padding: 4px 8px;         /* 内边距 */
    border-radius: 4px;       /* 圆角边框 */
    font-size: 11px;          /* 字体大小 */
    font-weight: bold;        /* 粗体文字 */
    white-space: nowrap;      /* 不换行 */
    text-align: center;       /* 文字居中 */
}

/* 响应式调整 - 物体打散侧边栏 */
@media (max-width: 768px) {
    .explode-sidebar-container {
        width: 50px;              /* 移动设备上侧边栏宽度减小 */
    }
    
    .explode-slider-wrapper {
        height: 120px;            /* 移动设备上滑块区域高度减小 */
        width: 35px;              /* 滑块区域宽度减小 */
        position: relative;       /* 为伪元素定位 */
        cursor: pointer;          /* 指针样式 */
    }
    /* 使用伪元素扩大触摸热区（不可见，不影响视觉尺寸） */
    .explode-slider-wrapper::before {
        content: '';
        position: absolute;
        top: -18px;               /* 扩大触摸热区 */
        left: -18px;
        right: -18px;
        bottom: -18px;
        pointer-events: auto;     /* 确保可以触摸 */
        background: transparent;  /* 完全透明 */
    }
    
    .explode-vertical-slider {
        height: 100px;            /* 移动设备上滑块高度减小 */
        width: 5px;               /* 滑块轨道宽度减小 */
    }
    
    .explode-vertical-slider::-webkit-slider-thumb {
        width: 12px;              /* 移动设备上按钮略小 */
        height: 12px;
    }
    
    .explode-vertical-slider::-moz-range-thumb {
        width: 12px;              /* 移动设备上按钮略小 */
        height: 12px;
    }
}

@media (max-width: 480px) {
    .explode-sidebar-container {
        width: 45px;              /* 小屏幕上侧边栏宽度进一步减小 */
    }
    
    .explode-slider-wrapper {
        height: 100px;            /* 小屏幕上滑块区域高度进一步减小 */
        width: 30px;              /* 滑块区域宽度进一步减小 */
        position: relative;       /* 为伪元素定位 */
        cursor: pointer;          /* 指针样式 */
    }
    /* 小屏幕上进一步扩大触摸热区 */
    .explode-slider-wrapper::before {
        content: '';
        position: absolute;
        top: -22px;               /* 扩大触摸热区 */
        left: -22px;
        right: -22px;
        bottom: -22px;
        pointer-events: auto;
        background: transparent;
    }
    
    .explode-vertical-slider {
        height: 80px;             /* 小屏幕上滑块高度进一步减小 */
        width: 4px;               /* 滑块轨道宽度进一步减小 */
    }
    
    .explode-vertical-slider::-webkit-slider-thumb {
        width: 10px;              /* 小屏幕上按钮更小 */
        height: 10px;
    }
    
    .explode-vertical-slider::-moz-range-thumb {
        width: 10px;              /* 小屏幕上按钮更小 */
        height: 10px;
    }
}