/* ==========================================
   Form 表單控制項樣式
   ========================================== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #636366;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: #fff;
  outline: none;
  box-sizing: border-box;
  appearance: none;
  transition: border-color 0.2s ease;
}

.form-control:focus { border-color: var(--primary-color); }

select.form-control {
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  cursor: pointer;
}
select.form-control::-ms-expand { display: none; }

textarea.form-control {
  height: auto;
  min-height: 80px;
  resize: vertical;
  line-height: 1.4;
}

.option-group { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.option-group.inline { flex-direction: row; flex-wrap: wrap; gap: 12px 16px; }

.option-label {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  color: var(--text-color);
  cursor: pointer;
  user-select: none;
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0 8px 0 0;
  accent-color: var(--primary-color);
  cursor: pointer;
}

input[type="file"].form-control { height: auto; padding: 8px 12px; font-size: 14px; color: #636366; background-color: #fafafc; }
input[type="file"]::file-selector-button {
  padding: 6px 12px;
  margin-right: 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

input[type="date"].form-control,
input[type="datetime-local"].form-control,
input[type="time"].form-control { max-width: 100%; min-width: 0; box-sizing: border-box; display: block; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; min-height: 20px; }

/* Switch 開關 */
.switch-group { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.switch-label-text { font-size: 15px; color: var(--text-color); }
.switch-toggle { position: relative; display: inline-block; width: 51px; height: 31px; flex-shrink: 0; }
.switch-toggle input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: #e5e5ea; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 31px;
}
.switch-slider:before {
  position: absolute; content: ""; height: 27px; width: 27px; left: 2px; bottom: 2px;
  background-color: white; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.switch-toggle input:checked + .switch-slider { background-color: var(--primary-color); }
.switch-toggle input:checked + .switch-slider:before { transform: translateX(20px); }

/* 按鈕與按鈕組 */
.btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.btn-primary   { background-color: var(--primary-color); color: #fff; }
.btn-secondary { background-color: #e5e5ea; color: var(--text-color); }
.btn-success   { background-color: #34c759; color: #ffffff; }
.btn-warning   { background-color: #ffd700; color: #1c1c1e; }
.btn-caution   { background-color: #ff9500; color: #ffffff; }
.btn-danger    { background-color: #ff3b30; color: #ffffff; }
.btn-outline   { background-color: transparent; border: 1px solid var(--primary-color); color: var(--primary-color); }

.btn:disabled, .btn.disabled {
  background-color: #e5e5ea !important;
  color: #aeaeb2 !important;
  border-color: #e5e5ea !important;
  cursor: not-allowed !important;
  opacity: 0.7;
  pointer-events: none;
  box-shadow: none !important;
}

.btn:last-child { margin-bottom: 0; }
.btn:active     { opacity: 0.85; }

.btn-group { display: flex; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 12px; width: 100%; }
.btn-group.align-left   { justify-content: flex-start; }
.btn-group.align-center { justify-content: center; }
.btn-group.align-right  { justify-content: flex-end; }

.btn-group .btn-inline {
  width: auto; min-width: fit-content; height: 40px; padding: 0 16px; font-size: 14px; margin-bottom: 0; flex-grow: 0;
}

/* 按鈕 Loading 動畫 */
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

button.loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin 0.75s linear infinite;
  vertical-align: middle;
}

@keyframes button-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
