/*
 * AR扫描模块样式
 */

/* AR容器 */
.ar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

/* 控制按钮固定在底部 */
.ar-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 10, 15, 0.95);
  border-top: 1px solid var(--border-color);
  padding: var(--space-sm) var(--space-md);
  z-index: 100;
  max-width: 600px;
  margin: 0 auto;
}

/* 摄像头包装器 */
.camera-wrapper {
  position: relative;
  width: 100%;
  height: 60vh;
  min-height: 300px;
  max-height: 500px;
  background: linear-gradient(135deg, 
    rgba(10, 10, 20, 0.95) 0%, 
    rgba(20, 10, 30, 0.9) 50%, 
    rgba(10, 10, 20, 0.95) 100%
  );
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border-color);
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.2);
}

/* 装饰性背景元素 */
.camera-wrapper::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, 
    rgba(168, 85, 247, 0.1) 0%, 
    rgba(168, 85, 247, 0) 70%
  );
  border-radius: 50%;
  animation: pulse 4s ease-in-out infinite;
}

.camera-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, 
    transparent 0%, 
    rgba(255, 215, 0, 0.05) 50%, 
    transparent 100%
  );
  pointer-events: none;
}

/* 脉冲动画 */
@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.3;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.3;
  }
}

/* 响应式调整 */
@media (max-width: 768px) {
  .camera-wrapper {
    height: 55vh;
    min-height: 280px;
    max-height: 400px;
  }
  
  .ar-controls {
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-xs);
  }
  
  .ar-controls button {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
  }
  
  .camera-switch {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
  }
  
  .scan-frame {
    width: 100%;
    height: 60%;
  }
  
  .scan-tip {
    font-size: 0.8rem;
    text-align: center;
    padding: var(--space-xs) var(--space-sm);
  }
  
  .chakra-item {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }
  
  .chakra-name {
    width: auto;
    flex: 1;
  }
  
  .chakra-bar {
    width: 100%;
    order: 3;
    margin-top: var(--space-xs);
  }
  
  .crystal-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  
  .crystal-card {
    padding: var(--space-sm);
  }
  
  .crystal-icon {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  
  .crystal-name {
    font-size: 0.85rem;
  }
  
  .crystal-purpose {
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .camera-wrapper {
    height: 50vh;
    min-height: 250px;
  }
  
  .scan-frame {
    width: 100%;
    height: 55%;
  }
  
  .crystal-grid {
    grid-template-columns: 1fr;
  }
  
  .chakra-chart {
    gap: var(--space-sm);
  }
  
  .chakra-item {
    padding: var(--space-sm);
  }
}

.camera-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像 */
}

.camera-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* AR叠加层 */
.ar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* 扫描框 */
.scan-frame {
  width: 100%;
  height: auto;
  position: relative;
  top: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame img {
  width: 120%;
  height: auto;
  filter: drop-shadow(0 0 20px gold) sepia(1) saturate(3) hue-rotate(30deg);
  animation: scanPulse 2s ease-in-out infinite;
}

/* 扫描框动画 */
@keyframes scanPulse {
  0% {
    filter: drop-shadow(0 0 20px var(--primary-color));
  }
  50% {
    filter: drop-shadow(0 0 40px var(--primary-color)) drop-shadow(0 0 60px rgba(168, 85, 247, 0.5));
  }
  100% {
    filter: drop-shadow(0 0 20px var(--primary-color));
  }
}

/* 扫描线 */
.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--primary-color) 50%, 
    transparent 100%
  );
  animation: scan 2s linear infinite;
  animation-play-state: paused;
  box-shadow: 0 0 10px var(--primary-color);
}

/* 扫描中状态 */
.scan-frame.scanning .scan-line {
  animation-play-state: running;
}

@keyframes scan {
  0% {
    top: 0;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

/* 扫描提示 */
.scan-tip {
  margin-top: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.6);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
}

/* AR控制按钮 */
.ar-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-sm);
  width: 100%;
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.camera-switch {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-normal);
  font-size: 0.875rem;
  text-align: center;
}

.camera-switch:hover {
  background: var(--bg-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* 脉轮图表 */
.chakra-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.chakra-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  font-size: 0.65rem;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.chakra-item:hover {
  background: var(--bg-hover);
  transform: translateX(5px);
}

.chakra-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* 为每个脉轮设置特定颜色 */
.chakra-item[data-chakra="crown"] .chakra-color {
  background: var(--crown-color);
  color: var(--crown-color);
}

.chakra-item[data-chakra="third-eye"] .chakra-color {
  background: var(--third-eye-color);
  color: var(--third-eye-color);
}

.chakra-item[data-chakra="throat"] .chakra-color {
  background: var(--throat-color);
  color: var(--throat-color);
}

.chakra-item[data-chakra="heart"] .chakra-color {
  background: var(--heart-color);
  color: var(--heart-color);
}

.chakra-item[data-chakra="solar"] .chakra-color {
  background: var(--solar-color);
  color: var(--solar-color);
}

.chakra-item[data-chakra="sacral"] .chakra-color {
  background: var(--sacral-color);
  color: var(--sacral-color);
}

.chakra-item[data-chakra="root"] .chakra-color {
  background: var(--root-color);
  color: var(--root-color);
}

.chakra-name {
  width: 50px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chakra-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  min-width: 30px;
  margin: 0 4px;
}

.chakra-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease, background-color 0.3s ease;
  background: linear-gradient(90deg, var(--crown-color), var(--third-eye-color));
  box-shadow: 0 0 6px rgba(155, 89, 182, 0.5);
}

/* 为每个脉轮设置特定颜色 */
.chakra-item[data-chakra="crown"] .chakra-fill {
  background: var(--crown-color);
}

.chakra-item[data-chakra="third-eye"] .chakra-fill {
  background: var(--third-eye-color);
}

.chakra-item[data-chakra="throat"] .chakra-fill {
  background: var(--throat-color);
}

.chakra-item[data-chakra="heart"] .chakra-fill {
  background: var(--heart-color);
}

.chakra-item[data-chakra="solar"] .chakra-fill {
  background: var(--solar-color);
}

.chakra-item[data-chakra="sacral"] .chakra-fill {
  background: var(--sacral-color);
}

.chakra-item[data-chakra="root"] .chakra-fill {
  background: var(--root-color);
}

.chakra-value {
  width: 35px;
  text-align: right;
  font-weight: 600;
  color: var(--primary-color);
  flex-shrink: 0;
  white-space: nowrap;
}

/* 应用说明书 */
.app-instructions {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin: var(--space-sm) 0;
  border: 1px solid var(--border-color);
  width: 100%;
  box-sizing: border-box;
}

.app-instructions h4 {
  text-align: center;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  font-size: 1rem;
}

.instructions-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-xs);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
}

.instruction-item:hover {
  background: var(--bg-hover);
  transform: translateX(5px);
}

.instruction-step {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 0.8rem;
}

.instruction-text {
  flex: 1;
}

.instruction-text strong {
  color: var(--primary-color);
  display: block;
  margin-bottom: 2px;
  font-size: 0.8rem;
}

.instruction-text p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
}

/* 水晶推荐 */
.crystal-recommend {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-md);
}

.crystal-recommend h4 {
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
  text-align: center;
  color: var(--text-primary);
}

.crystal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-sm);
}

.crystal-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all var(--transition-normal);
  font-size: 0.7rem;
}

.crystal-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

.crystal-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-sm);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.crystal-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.crystal-purpose {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* 响应式 */
@media (max-width: 768px) {
  .scan-frame {
    width: 100%;
    height: 190px;
  }
  
  .chakra-item {
    flex-wrap: wrap;
  }
  
  .chakra-name {
    width: auto;
    flex: 1;
  }
  
  .chakra-bar {
    width: 100%;
    order: 3;
    margin-top: var(--space-sm);
  }
  
  .crystal-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
