/**
 * 验证码组件样式
 * 用于登录页面防机器人验证
 */

/* ============ 弹窗容器 ============ */
.captcha-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease-out;
}

.captcha-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-width: 380px;
  width: 90%;
  position: relative;
  animation: slideIn 0.3s ease-out;
}

.captcha-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.captcha-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.captcha-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.captcha-close:hover {
  background: #f5f5f5;
  color: #666;
}

/* ============ Canvas 容器 ============ */
.captcha-canvas-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
}

.captcha-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.captcha-block {
  position: absolute;
  top: 0;
  left: 0;
  transition: left 0.1s linear;
}

/* 加载状态 */
.captcha-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
}

.captcha-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============ 输入框容器 ============ */
.captcha-input-container {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  position: relative;
}

.captcha-input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 4px;
  text-align: center;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: all 0.3s;
  text-transform: uppercase;
  background: #f8f9fa;
}

.captcha-input:focus {
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.captcha-input::placeholder {
  letter-spacing: normal;
  font-weight: normal;
  color: #999;
}

.captcha-submit-btn {
  height: 44px;
  padding: 0 24px;
  background: linear-gradient(to right, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.captcha-submit-btn:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transform: translateY(-1px);
}

.captcha-submit-btn:active {
  transform: translateY(0);
}

.captcha-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 验证消息 */
.captcha-message {
  min-height: 20px;
  margin-bottom: 12px;
  font-size: 14px;
  text-align: center;
  transition: all 0.3s;
}

.captcha-message.success {
  color: #00b894;
  font-weight: 600;
  animation: bounce 0.5s ease-out;
}

.captcha-message.error {
  color: #ff7675;
  font-weight: 600;
  animation: shake 0.5s ease-out;
}

/* ============ 状态样式 ============ */
.captcha-input-container.captcha-success .captcha-input {
  border-color: #00b894;
  background: #e8f8f5;
  color: #00b894;
}

.captcha-input-container.captcha-success .captcha-submit-btn {
  background: linear-gradient(to right, #00b894, #00cec9);
}

.captcha-input-container.captcha-error .captcha-input {
  border-color: #ff7675;
  background: #fff5f5;
  animation: shake 0.5s ease-out;
}

/* ============ 底部操作区 ============ */
.captcha-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.captcha-refresh {
  background: none;
  border: 1px solid #ddd;
  color: #666;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.captcha-refresh:hover {
  border-color: #667eea;
  color: #667eea;
  background: #f8f9fa;
}

.captcha-refresh::before {
  content: '🔄';
  font-size: 16px;
}

.captcha-tips {
  font-size: 12px;
  color: #999;
}

/* ============ 动画定义 ============ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* ============ 响应式设计 ============ */
@media (max-width: 768px) {
  .captcha-content {
    padding: 20px;
    max-width: 340px;
  }

  .captcha-title {
    font-size: 16px;
  }

  .captcha-canvas-wrapper {
    margin-bottom: 16px;
  }

  .captcha-input-container {
    gap: 10px;
  }

  .captcha-input {
    height: 48px;
    font-size: 15px;
    letter-spacing: 3px;
  }

  .captcha-submit-btn {
    height: 48px;
    padding: 0 20px;
    font-size: 14px;
  }

  .captcha-refresh {
    font-size: 13px;
    padding: 6px 12px;
  }

  .captcha-tips {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .captcha-content {
    padding: 16px;
    max-width: 320px;
  }

  .captcha-title {
    font-size: 15px;
  }

  .captcha-input-container {
    gap: 8px;
  }

  .captcha-input {
    height: 50px;
    font-size: 14px;
  }

  .captcha-submit-btn {
    height: 50px;
    padding: 0 16px;
  }
}

/* ============ 触摸设备优化 ============ */
@media (hover: none) and (pointer: coarse) {
  .captcha-input {
    height: 52px;
  }

  .captcha-submit-btn {
    height: 52px;
  }

  .captcha-submit-btn:hover {
    transform: none;
  }

  .captcha-refresh:hover {
    background: none;
  }
}
