/**
 * base.css - 基础样式重置与统一
 * 基于 normalize.css，进一步统一各浏览器表单元素表现
 */

/* ==================== 盒模型统一 ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ==================== 基础重置 ==================== */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.5;
  color: #333;
  background-color: #fff;
}

/* ==================== 表单元素统一 ==================== */

/* Input 基础样式统一 */
input,
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background-color: #fff;
  color: #1f2937;
  font-size: 1rem;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* 聚焦状态统一 */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 禁用状态统一 */
input:disabled,
textarea:disabled,
select:disabled {
  background-color: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 1; /* iOS 需要 */
}

/* Placeholder 颜色统一 */
input::placeholder,
textarea::placeholder {
  color: #9ca3af;
  opacity: 1; /* Firefox */
}

/* 数字输入框去除箭头 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* 搜索输入框去除清除按钮 */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

/* 日期选择器图标统一 */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"] {
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 0.75rem;
  width: 1rem;
  height: 1rem;
  opacity: 0.5;
  cursor: pointer;
}

/* Select 下拉箭头统一 */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* IE 隐藏下拉箭头 */
select::-ms-expand {
  display: none;
}

/* Textarea 统一 */
textarea {
  resize: vertical;
  min-height: 5rem;
}

/* Checkbox & Radio 统一 */
input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: 1px solid #d1d5db;
  background-color: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  vertical-align: middle;
  margin-right: 0.5rem;
}

input[type="checkbox"] {
  border-radius: 0.25rem;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M10 3L4.5 8.5 2 6' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

input[type="radio"]:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' viewBox='0 0 6 6'%3E%3Ccircle fill='%23fff' cx='3' cy='3' r='3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* File Input 统一 */
input[type="file"] {
  padding: 0.5rem;
  border: 1px dashed #d1d5db;
  background-color: #f9fafb;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: #9ca3af;
}

/* Range Slider 统一 */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 0.5rem;
  padding: 0;
  background: #e5e7eb;
  border-radius: 0.25rem;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

input[type="range"]::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Color Picker 统一 */
input[type="color"] {
  width: 3rem;
  height: 2.5rem;
  padding: 0.25rem;
  cursor: pointer;
}

/* ==================== Button 统一 ==================== */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.375rem;
  background-color: #3b82f6;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

button:hover {
  background-color: #2563eb;
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

button:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

/* ==================== 链接统一 ==================== */
a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}
 
a:hover {
  color: inherit;
  text-decoration: initial;
}

/* ==================== 图片统一 ==================== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==================== 表格统一 ==================== */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  font-weight: 600;
  background-color: #f9fafb;
}

/* ==================== 列表统一 ==================== */
ul,
ol {
  padding: 0;
  margin: 0;
  list-style: none;
}

/* ==================== 工具类 ==================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}
