/* ============================================================
   顶尖发卡平台 - 原生控件美化层
   作用：在 base.css 已有表单样式基础上，补齐浏览器原生控件的美化
   覆盖：select 下拉箭头、checkbox/radio、number spinners、
        date/file 控件、滚动条、错误态/禁用态、密码眼睛按钮
   原则：复用 :root 设计变量，不改动任何页面 HTML，最小侵入
   ============================================================ */

/* ===== 1. 滚动条美化（WebKit + Firefox） ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #C4D0E0;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #9FB0C8;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active { background: #7E92AC; background-clip: padding-box; border: 2px solid transparent; }
* { scrollbar-width: thin; scrollbar-color: #C4D0E0 transparent; }

/* ===== 2. select 下拉框：去掉原生箭头，换成自定义 SVG 箭头 ===== */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23687B93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 36px !important;
  cursor: pointer;
}
select:disabled { cursor: not-allowed; }
select:focus,
select:focus-visible {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%230FC39A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ===== 3. checkbox / radio 自定义外观（全局，不限定 .field） ===== */
input[type="checkbox"],
input[type="radio"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  border: 1.5px solid #C4D0E0;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: background .15s, border-color .15s, box-shadow .15s;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  vertical-align: middle;
  accent-color: auto;
}
input[type="checkbox"] { border-radius: 5px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--teal); }
input[type="checkbox"]:checked, input[type="radio"]:checked {
  background: var(--teal);
  border-color: var(--teal);
}
input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3L12.5 5' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}
input[type="radio"]:checked { background: #fff; }
input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(15, 195, 154, .18);
}
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  background: #EEF2F7;
  border-color: #D8E0EC;
  cursor: not-allowed;
}
input[type="checkbox"]:disabled:checked {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3L12.5 5' fill='none' stroke='%239FB0C8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ===== 4. number 输入框：隐藏原生上下箭头 ===== */
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; }

/* ===== 5. date / time 控件 ===== */
input[type="date"], input[type="time"], input[type="datetime-local"] {
  appearance: none;
  -webkit-appearance: none;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .45;
  transition: opacity .2s;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator { opacity: .8; }

/* ===== 6. file 文件上传控件美化 ===== */
input[type="file"] {
  padding: 10px 14px;
  border: 1.5px dashed #C4D0E0;
  border-radius: 10px;
  background: #FBFCFE;
  cursor: pointer;
  color: var(--text-2);
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
input[type="file"]::file-selector-button:hover { background: #D3F2E8; }

/* ===== 7. 表单错误态 ===== */
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: #E5484D;
}
.field.has-error input:focus,
.field.has-error select:focus,
.field.has-error textarea:focus {
  border-color: #E5484D;
  box-shadow: 0 0 0 4px rgba(229, 72, 77, .12);
}
.field-error {
  font-size: 12.5px;
  color: #E5484D;
  margin-top: -8px;
  margin-bottom: 14px;
  display: block;
}
.field-success {
  font-size: 12.5px;
  color: var(--teal-dark);
  margin-top: -8px;
  margin-bottom: 14px;
  display: block;
}

/* ===== 8. disabled / readonly 态 ===== */
input:disabled, select:disabled, textarea:disabled {
  background: #F0F4FA;
  color: var(--text-2);
  cursor: not-allowed;
}
input[readonly], textarea[readonly] {
  background: #F0F4FA;
  color: var(--text-2);
  cursor: default;
}

/* ===== 9. range 滑块美化 ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: #E4EAF3;
  outline: none;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--teal);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 195, 154, .4);
  transition: transform .15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--teal);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 195, 154, .4);
}

/* ===== 10. 密码框"显示/隐藏"按钮（全局，JS 注入 .input-wrap） ===== */
.input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}
.input-wrap .toggle-pwd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--text-2);
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.input-wrap .toggle-pwd:hover { color: var(--teal-dark); }
.input-wrap input[type="password"],
.input-wrap input[type="text"] {
  flex: 1 1 auto;
  width: 100%;
  padding-right: 40px;
}

/* ===== 11. 图片点击放大 Lightbox ===== */
.img-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 16, 34, .88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
  animation: fadeIn .18s ease both;
}
.img-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  animation: pop .22s ease both;
}

/* ===== 12. 提交按钮 loading 态 ===== */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after,
.btn-ghost-light.is-loading::after {
  border-color: rgba(15, 195, 154, .25);
  border-top-color: var(--teal);
}

/* ===== 13. textarea 鼠标拖拽调整高度 ===== */
textarea {
  resize: vertical;
  min-height: 100px;
  overflow-y: auto;
}

/* ===== 14. 移动端自适应 ===== */
@media (max-width: 480px) {
  .toast-wrap {
    top: 70px;
    width: calc(100% - 24px);
    left: 12px;
    right: 12px;
    transform: none;
  }
  .toast {
    width: 100%;
    justify-content: center;
    font-size: 13px;
    padding: 11px 14px;
    border-radius: 10px;
  }
  input, select, textarea { font-size: 16px; }
}
