/* ─── Form inputs (text, number, search, email, url, password, select, textarea) ── */

:root {
  --ex-input-height: 32px;
  --ex-input-padding: 0 10px;
  --ex-input-font-size: 13px;
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="password"],
input:not([type]),
select,
textarea {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--ex-input-font-size);
  color: var(--ex-text);
  background: var(--ex-surface);
  border: 1.5px solid var(--ex-border);
  border-radius: var(--ex-radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  border-color: var(--ex-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ex-primary) 20%, transparent);
}

input[type="text"]:disabled,
input[type="number"]:disabled,
input[type="search"]:disabled,
input[type="email"]:disabled,
input[type="url"]:disabled,
input[type="password"]:disabled,
input:not([type]):disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="password"],
input:not([type]) {
  height: var(--ex-input-height);
  padding: var(--ex-input-padding);
}

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 { -webkit-appearance: none; }

select:not([multiple]) {
  height: var(--ex-input-height);
  padding: 0 32px 0 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  /* Light mode chevron */
  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 d='M2 4l4 4 4-4' stroke='%231a202c' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* Dark mode chevron */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) 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 d='M2 4l4 4 4-4' stroke='%23f1f5f9' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
  }
}

:root[data-theme="dark"] 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 d='M2 4l4 4 4-4' stroke='%23f1f5f9' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.5;
}

.input-inline {
  display: inline-block;
  width: auto;
}


/* ─── Toggle switch ──────────────────────────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-flex;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--ex-border);
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  background: var(--ex-surface);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--ex-primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.toggle input:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}
