/**
 * Caper Captcha - 前端验证码组件样式
 *
 * 统一的设计规范：输入框置顶 → 图片区（含右上角刷新按钮）
 *
 * @package Caper_Captcha
 * @since 1.2.0
 */

/* ========== 组件容器 ========== */
.caper-captcha-wrapper {
  display: inline-block;
  max-width: 280px;
  width: 100%;
  margin: 8px 0;
  box-sizing: border-box;
}

.caper-captcha-wrapper .caper-captcha-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

/* ========== 输入框（置顶，宽度 = 图片宽度） ========== */
.caper-captcha-wrapper .caper-captcha-input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #949494;
  font-size: 14px;
  color: #1e293b;
  background: #fff;
  box-sizing: border-box;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.caper-captcha-wrapper .caper-captcha-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

/* ========== 图片容器（相对定位，承载绝对定位的刷新按钮） ========== */
.caper-captcha-wrapper .caper-captcha-image-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1px solid #d1d5db;
  overflow: hidden;
  background: #fff;
}

/* ========== 验证码图片 ========== */
.caper-captcha-wrapper .caper-captcha-img {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  cursor: pointer;
  image-rendering: auto;
}

/* 点击图片刷新提示 */
.caper-captcha-wrapper .caper-captcha-img:hover {
  opacity: 0.88;
}

/* ========== 刷新按钮（右上角浮层） ========== */
.caper-captcha-wrapper .caper-captcha-refresh {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
  font-size: 15px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  transition:
    color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
  z-index: 1;
}

.caper-captcha-wrapper .caper-captcha-refresh:hover {
  background: #fff;
  color: #2563eb;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
  border-color: rgba(37, 99, 235, 0.2);
}

.caper-captcha-wrapper .caper-captcha-refresh:active {
  transform: scale(0.95);
}

/* ========== 加载/错误占位 ========== */
.caper-captcha-wrapper .caper-captcha-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  color: #94a3b8;
}

.caper-captcha-wrapper .caper-captcha-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 12px;
  color: #dc2626;
}

/* wp-login.php 的表单字段兼容（保留原有类名） */
p.caper-captcha-field {
  margin-bottom: 16px;
}
p.caper-captcha-field .caper-captcha-wrapper {
  margin-top: 4px;
}

/* 评论表单兼容 */
p.comment-form-captcha {
  margin-bottom: 16px;
}
p.comment-form-captcha .caper-captcha-wrapper {
  margin-top: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  .caper-captcha-wrapper {
    max-width: 100%;
  }
  .caper-captcha-wrapper .caper-captcha-refresh {
    width: 30px;
    height: 30px;
    font-size: 16px;
    line-height: 28px;
  }
}
