/* 完整版 2FA 验证器样式 - 最终版 */

/* 复制成功动画 */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.copy-success {
  animation: pulse 0.3s ease-in-out;
}

/* 验证码样式 */
#totp-code, #inline-totp-code {
  letter-spacing: 0.25em;
  min-height: 3.5rem;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

#inline-totp-code {
  min-height: 2.5rem;
}

/* 数字变化动画 */
.digit {
  display: inline-block;
  transition: all 0.3s ease;
}

.digit-change {
  transform: translateY(-2px);
  opacity: 0.8;
}

/* 验证码复制效果 */
@keyframes highlight {
  0% { color: #3b82f6; }
  30% { color: #10b981; }
  100% { color: #3b82f6; }
}

@keyframes highlightDark {
  0% { color: #60a5fa; }
  30% { color: #34d399; }
  100% { color: #60a5fa; }
}

.code-copied .digit {
  animation: highlight 0.8s ease-in-out;
}

.dark .code-copied .digit {
  animation: highlightDark 0.8s ease-in-out;
}

/* 验证码容器效果 */
#code-container, #inline-code-container {
  cursor: pointer;
  transition: all 0.3s ease;
}

#code-container:hover, #inline-code-container:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#code-container:active, #inline-code-container:active {
  transform: translateY(1px);
}

/* 复制按钮光效 */
#copy-code-big, #copy-inline-code {
  position: relative;
  overflow: hidden;
}

#copy-code-big::after, #copy-inline-code::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0) 100%);
  transition: left 0.5s ease-in-out;
}

#copy-code-big:hover::after, #copy-inline-code:hover::after {
  left: 100%;
}

/* 小复制按钮样式 */
#copy-content, #copy-secret, #copy-link {
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

#copy-content:hover, #copy-secret:hover, #copy-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
  transform: scale(1.1);
}

.dark #copy-content:hover, 
.dark #copy-secret:hover, 
.dark #copy-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 重新扫描按钮 */
#rescan-button {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#rescan-button:hover {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 扫描界面容器 */
#scanning-interface {
  transition: all 0.3s ease;
}

/* 过渡效果 */
body, button, input, div, select {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
}

/* 移动端优化 */
@media (max-width: 640px) {
  #totp-code {
    font-size: 1.75rem;
  }
  
  #inline-totp-code {
    font-size: 1.5rem;
  }
  
  #qr-reader {
    height: 200px;
  }
  
  /* 摄像头控制按钮在小屏幕上的布局 */
  #camera-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  #camera-controls button {
    flex: 1;
    min-width: 100px;
  }
}

/* 选择性文本选择 */
body {
  user-select: none;
}

#secret-key, 
#totp-code, 
#inline-totp-code,
#qr-decoded-content, 
#qr-result-link,
#extracted-secret {
  user-select: all;
}

/* 提示框样式 */
.copy-tooltip {
  position: fixed;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 100;
  max-width: 200px;
  text-align: center;
}

.copy-tooltip.show {
  opacity: 1;
}

/* 按钮点击效果 */
button:active {
  transform: translateY(1px);
}

/* QR扫描器样式 */
#qr-reader {
  position: relative;
  overflow: hidden;
}

#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

#qr-reader img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 扫描结果样式 */
#qr-decoded-content,
#extracted-secret {
  word-break: break-all;
  line-height: 1.5;
}

#extracted-secret {
  font-weight: 600;
}

/* 结果区域布局优化 */
.result-item {
  margin-bottom: 1rem;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

/* 内联验证码特殊样式 */
#inline-totp-container {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 1rem;
  margin-top: 1rem;
}

.dark #inline-totp-container {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* 扫描成功状态样式 */
.scan-success {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 状态切换动画 */
#scanning-interface.hidden {
  opacity: 0;
  transform: translateY(-10px);
}

#qr-result-container {
  animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 确保hidden类优先级 */
.hidden {
  display: none !important;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  #code-container, #inline-code-container {
    border-width: 3px;
  }
  
  .copy-tooltip {
    background-color: #000;
    border: 1px solid #fff;
  }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .digit-change {
    transform: none;
  }
  
  #copy-code-big::after,
  #copy-inline-code::after {
    display: none;
  }
  
  .scan-success {
    animation: none;
  }
  
  #qr-result-container {
    animation: none;
  }
}

/* 辅助功能改进 */
@media (prefers-reduced-motion: no-preference) {
  .smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* 焦点样式 */
button:focus-visible,
input:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* 深色模式下的焦点样式 */
.dark button:focus-visible,
.dark input:focus-visible {
  outline-color: #60a5fa;
}