/* ============================================================
   统一表单控件设计系统（前台 / 后台共用）
   ------------------------------------------------------------
   一套「输入控件」视觉：柔和底色 + 圆角 + 顶部内高光
   + 悬浮提亮 + 聚焦金边光晕 + 弱化占位符 + 细滚动条。
   尺寸通过 CSS 变量区分密度：
     --field-h        控件高度（前台 46 / 后台 38）
     --field-radius   圆角（前台 14 / 后台 10）
     --field-bg       常态底色（前台 var(--bg) / 后台 #FAFBFD）
     --field-fs       字号（前台 15 / 后台 13.5）
     --field-focus    聚焦光环颜色
   前台在 base.css 的 :root 里定义，后台在 admin.css 的 :root 里定义。
   本文件不声明这些变量，只消费，避免覆盖各端密度设置。
   ============================================================ */

/* ---------- 1) 基础：文本型输入框 / 下拉框 ---------- */
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
input[type="file"],
select {
  width: 100%;
  min-height: var(--field-h, 46px);
  height: var(--field-h, 46px);
  padding: 0 15px;
  font-size: var(--field-fs, 15px);
  line-height: 1.5;
  color: var(--txt, #1B2430);
  background: var(--field-bg, var(--bg));
  border: 1px solid var(--line, #E6EAF2);
  border-radius: var(--field-radius, 14px);
  outline: none;
  /* 顶部内高光 + 轻微内阴影，形成「输入面板」的立体感 */
  box-shadow: inset 0 1px 2px rgba(15, 32, 58, .04);
  transition: border-color .2s, background .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}

/* 下拉框：右侧自绘箭头 */
select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236B7686' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.75 6 6.75 11 1.75'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
/* 主题 B（暖护杏白）下箭头换成暖灰 */
body.theme-b select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238A7A6A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.75 6 6.75 11 1.75'/%3E%3C/svg%3E");
}

/* ---------- 2) 悬浮：边框加深 + 底色转白 ---------- */
input[type="text"]:hover,
input[type="tel"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="search"]:hover,
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="month"]:hover,
input[type="week"]:hover,
input[type="time"]:hover,
input[type="file"]:hover,
select:hover {
  border-color: #D8CFA8;                       /* 降级：color-mix 不支持时的静态色 */
  border-color: color-mix(in srgb, var(--accent, #C9A227) 40%, var(--line, #E6EAF2));
  background: var(--card, #FFFFFF);
}

/* ---------- 3) 聚焦：金边 + 光晕 ---------- */
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="time"]:focus,
input[type="file"]:focus,
select:focus {
  border-color: var(--accent, #C9A227);
  background: var(--card, #FFFFFF);
  box-shadow:
    0 0 0 4px var(--field-focus, rgba(201, 162, 39, .13)),
    0 8px 20px rgba(15, 32, 58, .07);
}

/* ---------- 4) 占位符弱化 ---------- */
input[type="text"]::placeholder,
input[type="tel"]::placeholder,
input[type="password"]::placeholder,
input[type="number"]::placeholder,
input[type="email"]::placeholder,
input[type="url"]::placeholder,
input[type="search"]::placeholder,
input[type="date"]::placeholder,
input[type="datetime-local"]::placeholder,
input[type="month"]::placeholder,
input[type="week"]::placeholder,
input[type="time"]::placeholder,
select:invalid {
  color: var(--muted, #6B7686);
  opacity: .72;
}

/* ---------- 5) 文件上传：做成「虚线选择区」 ---------- */
input[type="file"] {
  padding: 0 12px;
  font-size: calc(var(--field-fs, 15px) - .5px);
  color: var(--muted, #6B7686);
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand, #0B1F3A);
  background: linear-gradient(135deg, var(--accent, #C9A227), var(--accent-2, #E7C558));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: filter .18s, transform .18s;
}
input[type="file"]::file-selector-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

/* ---------- 6) 勾选 / 单选：主题色 ---------- */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent, #C9A227);
  cursor: pointer;
  vertical-align: -2px;
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent, #C9A227);
  outline-offset: 2px;
}

/* ---------- 7) 多行文本框：同一套质感 ---------- */
textarea {
  width: 100%;
  display: block;
  min-height: 104px;
  padding: 13px 15px;
  font-family: inherit;
  font-size: var(--field-fs, 15px);
  line-height: 1.75;
  color: var(--txt, #1B2430);
  background: var(--field-bg, var(--bg));
  border: 1px solid var(--line, #E6EAF2);
  border-radius: var(--field-radius, 14px);
  outline: none;
  resize: vertical;
  transition: border-color .2s, background .2s, box-shadow .2s;
  box-shadow: inset 0 1px 2px rgba(15, 32, 58, .04);
  -webkit-appearance: none;
  appearance: none;
}
textarea::placeholder { color: var(--muted, #6B7686); opacity: .72; }
textarea:hover {
  border-color: #D8CFA8;
  border-color: color-mix(in srgb, var(--accent, #C9A227) 40%, var(--line, #E6EAF2));
  background: var(--card, #FFFFFF);
}
textarea:focus {
  border-color: var(--accent, #C9A227);
  background: var(--card, #FFFFFF);
  box-shadow:
    inset 0 1px 2px rgba(15, 32, 58, .03),
    0 0 0 4px var(--field-focus, rgba(201, 162, 39, .13)),
    0 8px 20px rgba(15, 32, 58, .07);
}
textarea[rows="2"] { min-height: 66px; }
textarea[rows="3"] { min-height: 92px; }
textarea[rows="4"] { min-height: 120px; }

/* 代码 / 统计类文本框用等宽字体 */
textarea.ta-mono,
#aiContent {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
  font-size: calc(var(--field-fs, 15px) - 1.5px);
  line-height: 1.7;
  tab-size: 2;
}

/* ---------- 8) 禁用态 / 只读态 ---------- */
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--tint, rgba(11, 31, 58, .03)) !important;
  color: var(--muted, #6B7686);
  cursor: not-allowed;
  box-shadow: none;
}
input[readonly] {
  background: var(--tint, rgba(11, 31, 58, .03));
  color: var(--muted, #6B7686);
}

/* ---------- 9) 浏览器自动填充底色（Chrome 黄底）覆盖 ---------- */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--txt, #1B2430);
  -webkit-box-shadow: 0 0 0 1000px var(--card, #FFFFFF) inset;
  box-shadow: 0 0 0 1000px var(--card, #FFFFFF) inset;
  transition: background-color 9999s ease-out 0s;
  caret-color: var(--txt, #1B2430);
}

/* ---------- 10) 滚动条：细窄、低调 ---------- */
textarea::-webkit-scrollbar { width: 9px; height: 9px; }
textarea::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb {
  background: #C8CFDA;
  background: color-mix(in srgb, var(--muted, #6B7686) 32%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
textarea::-webkit-scrollbar-thumb:hover {
  background: #A9B2C0;
  background: color-mix(in srgb, var(--muted, #6B7686) 55%, transparent);
  background-clip: padding-box;
}
select::-webkit-scrollbar { width: 8px; }
select::-webkit-scrollbar-thumb {
  background: #C8CFDA;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* ---------- 11) 验证码图片与输入框同高对齐 ---------- */
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; min-width: 0; }
/* 验证码是 110x40 的动态图（比例固定），保持自身尺寸不被拉伸，
   外面套一层边框让它和输入框视觉成组。 */
.captcha-img {
  flex: none;
  width: 110px;
  height: 40px;
  border-radius: calc(var(--field-radius, 14px) - 4px);
  border: 1px solid var(--line, #E6EAF2);
  background: #fff;
  cursor: pointer;
  object-fit: contain;
}
/* 输入框比验证码高时，用外层盒子把验证码垂直居中并补齐边框 */
.captcha-row .captcha-wrap {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--field-h, 46px);
  padding: 0 6px;
  border: 1px solid var(--line, #E6EAF2);
  border-radius: var(--field-radius, 14px);
  background: #fff;
}

/* ---------- 12) 数字输入框：微调步进按钮观感 ---------- */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ---------- 13) 日期 / 时间选择器：原生图标统一压暗，聚焦时转金色 ---------- */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: .45;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px;
  transition: opacity .18s, background .18s;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator,
input[type="month"]:hover::-webkit-calendar-picker-indicator,
input[type="week"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator {
  opacity: .75;
  background: rgba(201, 162, 39, .12);
}
input[type="date"]:focus::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:focus::-webkit-calendar-picker-indicator,
input[type="month"]:focus::-webkit-calendar-picker-indicator,
input[type="week"]:focus::-webkit-calendar-picker-indicator,
input[type="time"]:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
}
/* 日期输入框：文本左对齐，图标靠右，避免图标压住文字 */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"] {
  text-align: left;
}
