/* =============================================================================
 *  03-controls.css — 卡片与表单控件
 * ========================================================================== */

/* ------------------------------- 卡片 ------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.card > .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: .2px;
}
.card-title .hint { font-size: 10.5px; color: var(--ink-3); font-weight: 400; }

/* 可折叠卡片 */
details.card { padding: 0; }
details.card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-radius: var(--r-lg);
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary:hover { background: var(--field); }
details.card > summary .card-title { margin: 0; }
/* 折叠箭头：只做绕自身中心的旋转。
   之前写成 rotate(45deg) translate(-2px,-2px) → rotate(-135deg) translate(-2px,-2px)，
   两个函数之间插值会让位移方向跟着转了 180°，看起来就像「从左上方飞进来」。 */
details.card > summary::after {
  content: '';
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  border-bottom-right-radius: 1.5px;
  transform-origin: 50% 50%;
  transform: rotate(45deg);
  transition: transform .26s cubic-bezier(.34, 1.28, .5, 1), border-color .18s;
  margin-left: 8px;
}
details.card[open] > summary::after {
  transform: rotate(225deg);
  border-color: var(--ink-2);
}
details.card > summary:hover::after { border-color: var(--ink-2); }
details.card[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card-body { padding: 14px; }

/* 卡片内的小折叠块（质感与氛围等） */
.sub-details {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.sub-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
  padding: 4px 0;
  border-radius: 4px;
  transition: color .16s;
}
.sub-details > summary::-webkit-details-marker { display: none; }
.sub-details > summary:hover { color: var(--ink); }
.sub-details > summary::after {
  content: '';
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  border-bottom-right-radius: 1.5px;
  transform: rotate(45deg);
  transform-origin: 50% 50%;
  transition: transform .26s cubic-bezier(.34, 1.28, .5, 1);
  margin-left: 8px;
}
.sub-details[open] > summary::after { transform: rotate(225deg); }

/* ------------------------------- 字段 ------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lbl {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 400;
  white-space: nowrap;
}
.chip {
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  background: var(--field);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 5px;
  white-space: nowrap;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tip { font-size: 10.5px; color: var(--ink-3); line-height: 1.65; margin-top: 8px; }
.block-sub { padding-top: 2px; }

/* ------------------------------- 输入框 ------------------------------- */
.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
/* 注意：这里必须用 background-color，不能用 background 简写。
   简写会把 select 的箭头（background-image / background-position）一起重置成
   「无图 + 0% 0%」，失焦时箭头就会从左上角滑回右侧，看起来像「飞入」。 */
.input:hover { background-color: var(--field-hover); }
.input:focus {
  background-color: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(33, 112, 245, .12);
}
.input.area {
  height: auto; min-height: 66px;
  padding: 9px 11px;
  line-height: 1.6;
  resize: vertical;
}
.input::placeholder { color: var(--ink-3); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23949ba6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 28px;
  cursor: pointer;
  /* 只过渡颜色类属性；background-position 一旦参与过渡，
     状态切换时箭头就会从 0% 0%（左上角）滑到右侧，产生「飞入」错觉。 */
  transition: border-color .16s, box-shadow .16s, background-color .16s;
}
select.input.slim { width: 136px; flex: 0 0 136px; font-size: 11.5px; padding-left: 8px; padding-right: 24px; }

input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 颜色 */
.clr { display: flex; align-items: center; gap: 8px; }
input[type=color] {
  width: 38px; height: 36px; flex: 0 0 38px;
  padding: 0;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 4px; }
input[type=color]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
  /* 白色色块在白底上也要能看出边界 */
  box-shadow: 0 0 0 1px rgba(16, 24, 40, .12) inset;
}
.clr .hex {
  width: 92px; flex: 0 0 92px; height: 36px;
  padding: 0 9px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .3px;
  outline: none;
}
.clr .hex:focus { background: #fff; border-color: var(--blue); }
.clr input[type=range] { flex: 1; min-width: 0; }

/* ------------------------------- 滑杆 ------------------------------- */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px;
  background: transparent;
  outline: none;
  cursor: pointer;
  --p: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(90deg,
    var(--blue) 0%, var(--blue) var(--p, 50%),
    #dcdfe6 var(--p, 50%), #dcdfe6 100%);
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .06);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #b9c0cb;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .35);
  transition: transform .1s, border-color .1s;
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); border-color: var(--blue); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.04); border-color: var(--blue); }

/* Firefox */
input[type=range]::-moz-range-track {
  height: 6px; border-radius: 99px;
  background: #dcdfe6;
}
input[type=range]::-moz-range-progress {
  height: 6px; border-radius: 99px;
  background: var(--blue);
}
input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #b9c0cb;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .35);
}
input[type=range]:hover::-moz-range-thumb { border-color: var(--blue); }

/* ------------------------------- 开关 ------------------------------- */
.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--ink-2);
}
.switch input { display: none; }
.switch i {
  position: relative;
  width: 34px; height: 20px;
  flex: 0 0 34px;
  background: #e2e6ec;
  border-radius: 99px;
  transition: background .18s;
}
.switch i::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .25);
  transition: transform .18s;
}
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch:hover { color: var(--ink); }

/* ------------------------------- 分段控件 ------------------------------- */
.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.seg.wide { margin-bottom: 12px; }
.seg button {
  flex: 1;
  height: 28px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.seg button svg { width: 15px; height: 15px; }
.seg button:hover { color: var(--ink); }
.seg button.on {
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 0 0 1px rgba(16, 24, 40, .04);
}

/* ------------------------------- 按钮 ------------------------------- */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--field); }
.btn.sm { height: 32px; font-size: 12px; padding: 0 12px; }
.btn.block { width: 100%; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--ink-3);
  transition: background .15s, color .15s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover:not(:disabled) { background: #fff; color: var(--ink); box-shadow: var(--shadow-card); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.link {
  background: none; border: none; padding: 0;
  color: var(--blue);
  font-size: inherit;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.link.sm-link {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.link.sm-link:disabled { color: var(--ink-3); cursor: default; text-decoration: none; }

/* 主操作（下载） */
.export-row { display: flex; gap: 6px; }
.btn-primary {
  flex: 1;
  height: 42px;
  border-radius: var(--r);
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 6px 16px -8px rgba(33, 112, 245, .8);
  transition: background .15s, transform .08s;
}
.btn-primary:hover { background: var(--blue-600); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.split-caret {
  flex: 0 0 40px;
  padding: 0;
  box-shadow: 0 6px 16px -8px rgba(33, 112, 245, .8);
}
.btn-primary.split-caret svg { width: 13px; height: 13px; }
