/* ═══════════════════════════════════════════════════════════════════════
   Components — Forms
   Inputs, selects, textarea, phone picker, OTP, checkbox, radio, switch
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Form container ───────────────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .form-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-row-wide { grid-column: 1 / -1; }

/* ─── Label ────────────────────────────────────────────────────── */
.form-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.form-label .required {
  color: var(--gold);
  font-style: normal;
}

.form-label .hint {
  margin-inline-start: auto;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gold);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

/* ─── Base input/select/textarea ───────────────────────────────── */
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--touch);
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  transition:
    border-color var(--tr-fast),
    background var(--tr-fast),
    box-shadow var(--tr-fast);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-dim);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-strong);
  background: var(--surface-1);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold);
  background: var(--surface-1);
  box-shadow: 0 0 0 3px rgba(255, 46, 198, 0.12);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-1);
}

/* ─── Textarea ─────────────────────────────────────────────────── */
.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

/* ─── Select ───────────────────────────────────────────────────── */
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23ff2ec6' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 12px;
  padding-inline-end: var(--space-7);
}

[dir="rtl"] .select {
  background-position: left var(--space-3) center;
  padding-inline-end: var(--space-4);
  padding-inline-start: var(--space-7);
}

/* ─── Validation states ────────────────────────────────────────── */
.input.is-error,
.select.is-error,
.textarea.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.input.is-success,
.select.is-success {
  border-color: var(--success);
}

.form-error,
.form-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error {
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ─── Password input with reveal button ────────────────────────── */
.input-secret {
  position: relative;
  display: flex;
  gap: var(--space-2);
}

.input-secret > .input {
  font-family: var(--font-mono);
  letter-spacing: 1.5px;
  flex: 1;
  min-width: 0;
}

.input-secret > .btn {
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   PHONE PICKER (country code + number)
   ═══════════════════════════════════════════════════════════════════════ */

.phone-picker {
  display: grid;
  grid-template-columns: minmax(110px, 130px) 1fr;
  gap: var(--space-2);
}

.phone-picker .country-select {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: center;
  padding-inline-end: var(--space-5);
  padding-inline-start: var(--space-3);
}

.phone-picker .phone-input {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════════════════
   OTP INPUT (6 separate digit boxes)
   ═══════════════════════════════════════════════════════════════════════ */

.otp-group {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  direction: ltr;
}

@media (min-width: 480px) {
  .otp-group {
    gap: var(--space-3);
  }
}

.otp-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--gold-light);
  background: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  transition: all var(--tr-fast);
  -moz-appearance: textfield;
}

.otp-digit::-webkit-outer-spin-button,
.otp-digit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

@media (min-width: 480px) {
  .otp-digit {
    width: 56px;
    height: 64px;
    font-size: var(--text-3xl);
  }
}

.otp-digit:focus {
  border-color: var(--gold);
  background: var(--surface-1);
  box-shadow:
    0 0 0 3px rgba(255, 46, 198, 0.15),
    inset 0 0 12px rgba(255, 46, 198, 0.10);
  outline: none;
}

.otp-digit.filled {
  border-color: var(--gold);
  background: var(--surface-1);
}

.otp-digit.error {
  border-color: var(--danger);
  animation: otp-shake 0.4s;
}

@keyframes otp-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════════════════
   CHECKBOX & RADIO (custom-styled)
   ═══════════════════════════════════════════════════════════════════════ */

.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
  min-height: var(--touch);
  padding: var(--space-2) 0;
}

.checkbox input,
.radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkbox-mark,
.radio-mark {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  background: var(--ink);
  transition: all var(--tr-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.checkbox-mark { border-radius: var(--r-xs); }
.radio-mark    { border-radius: 50%; }

.checkbox input:checked + .checkbox-mark,
.radio input:checked + .radio-mark {
  border-color: var(--gold);
  background: var(--gold);
}

.checkbox-mark::after,
.radio-mark::after {
  content: '';
  opacity: 0;
  transition: opacity var(--tr-fast);
}

.checkbox-mark::after {
  width: 6px;
  height: 10px;
  border: solid var(--text-on-gold);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.radio-mark::after {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-on-gold);
}

.checkbox input:checked + .checkbox-mark::after,
.radio input:checked + .radio-mark::after {
  opacity: 1;
}

.checkbox:focus-within .checkbox-mark,
.radio:focus-within .radio-mark {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ─── Radio cards (visual radio buttons as cards) ──────────────── */
.radio-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .radio-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .radio-cards-3 { grid-template-columns: repeat(3, 1fr); }
  .radio-cards-4 { grid-template-columns: repeat(4, 1fr); }
}

.radio-card {
  position: relative;
  padding: var(--space-4);
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--tr-fast);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: var(--touch);
}

.radio-card:hover {
  border-color: var(--line-strong);
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.radio-card.selected,
.radio-card:has(input:checked) {
  border-color: var(--gold);
  background: linear-gradient(160deg, var(--gold-soft), transparent 60%), var(--surface-1);
}

.radio-card.selected::after,
.radio-card:has(input:checked)::after {
  content: '✓';
  position: absolute;
  top: var(--space-3);
  inset-inline-end: var(--space-3);
  color: var(--gold);
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
}

.radio-card-name {
  font-weight: var(--weight-semibold);
  color: var(--text);
  font-size: var(--text-base);
}

.radio-card-desc {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ═══════════════════════════════════════════════════════════════════════
   SWITCH (toggle)
   ═══════════════════════════════════════════════════════════════════════ */

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
  min-height: var(--touch);
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  transition: all var(--tr);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--tr);
}

.switch input:checked + .switch-track {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.switch input:checked + .switch-track .switch-thumb {
  inset-inline-start: 22px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(255, 46, 198, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════
   SEARCH INPUT (with icon, smart suggestions support)
   ═══════════════════════════════════════════════════════════════════════ */

.search-input {
  position: relative;
}

.search-input .input {
  padding-inline-start: var(--space-7);
}

.search-input .search-icon {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input:focus-within .search-icon {
  color: var(--gold);
}

/* ═══════════════════════════════════════════════════════════════════════
   FILTERS BAR (Admin: customers, subscriptions, etc.)
   ═══════════════════════════════════════════════════════════════════════ */

.filter-bar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--tr-fast);
  min-height: 36px;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.filter-chip.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.filter-chip .count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--ink);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}
