/* ============================================
   FenceX - Form Controls
   Reusable styled form components
   ============================================ */

/* ============================================
   Toggle Switch
   ============================================ */
.fx-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

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

.fx-toggle-slider {
  position: relative;
  width: 48px;
  height: 26px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.15));
  border-radius: 999px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.fx-toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--color-text-muted, rgba(234, 242, 255, 0.7));
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Hover state */
.fx-toggle:hover .fx-toggle-slider {
  border-color: var(--color-accent, #5a8dff);
}

/* Focus state */
.fx-toggle input:focus-visible + .fx-toggle-slider {
  outline: 2px solid var(--color-accent, #5a8dff);
  outline-offset: 2px;
}

/* Checked state */
.fx-toggle input:checked + .fx-toggle-slider {
  background: var(--color-accent, #5a8dff);
  border-color: var(--color-accent, #5a8dff);
}

.fx-toggle input:checked + .fx-toggle-slider::before {
  transform: translateX(22px);
  background: #fff;
}

/* Disabled state */
.fx-toggle input:disabled + .fx-toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Light mode */
:root[data-theme='light'] .fx-toggle-slider {
  background: rgba(12, 26, 43, 0.08);
  border-color: rgba(12, 26, 43, 0.15);
}

:root[data-theme='light'] .fx-toggle-slider::before {
  background: rgba(12, 26, 43, 0.4);
}

:root[data-theme='light'] .fx-toggle input:checked + .fx-toggle-slider::before {
  background: #fff;
}

/* ============================================
   Checkbox
   ============================================ */
.fx-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
  color: var(--color-text-primary, #EAF2FF);
}

.fx-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.fx-checkbox-box {
  position: relative;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--color-border, rgba(255, 255, 255, 0.2));
  border-radius: 6px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.fx-checkbox-box::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 6px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  opacity: 0;
  transition: all 0.15s ease;
}

/* Hover */
.fx-checkbox:hover .fx-checkbox-box {
  border-color: var(--color-accent, #5a8dff);
  background: rgba(90, 141, 255, 0.1);
}

/* Focus */
.fx-checkbox input:focus-visible + .fx-checkbox-box {
  outline: 2px solid var(--color-accent, #5a8dff);
  outline-offset: 2px;
}

/* Checked */
.fx-checkbox input:checked + .fx-checkbox-box {
  background: var(--color-accent, #5a8dff);
  border-color: var(--color-accent, #5a8dff);
}

.fx-checkbox input:checked + .fx-checkbox-box::after {
  transform: rotate(45deg) scale(1);
  opacity: 1;
}

/* Disabled */
.fx-checkbox input:disabled + .fx-checkbox-box {
  opacity: 0.5;
  cursor: not-allowed;
}

.fx-checkbox input:disabled ~ .fx-checkbox-label {
  opacity: 0.5;
}

/* Light mode */
:root[data-theme='light'] .fx-checkbox-box {
  background: rgba(12, 26, 43, 0.04);
  border-color: rgba(12, 26, 43, 0.2);
}

:root[data-theme='light'] .fx-checkbox:hover .fx-checkbox-box {
  background: rgba(52, 98, 255, 0.08);
}

/* ============================================
   Select Dropdown
   ============================================ */
.fx-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  position: relative;
  width: 100%;
  min-width: 160px;
  padding: 12px 40px 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
  color: var(--color-text-primary, #EAF2FF);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23EAF2FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* When fx-select is also a form-input, override auth.css padding/background that breaks the chevron */
.fx-select.form-input {
  padding: 12px 40px 12px 14px;
  background-color: rgba(255, 255, 255, 0.06);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23EAF2FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  border-radius: 10px;
}

:root[data-theme='light'] .fx-select.form-input {
  background-color: rgba(12, 26, 43, 0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230C1630' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.fx-select:hover {
  border-color: var(--color-accent, #5a8dff);
  background-color: rgba(255, 255, 255, 0.08);
}

.fx-select:focus {
  outline: none;
  border-color: var(--color-accent, #5a8dff);
  box-shadow: 0 0 0 3px var(--color-accent-soft, rgba(90, 141, 255, 0.18));
}

.fx-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.fx-select option {
  background: var(--color-surface-solid, #0b132f);
  color: var(--color-text-primary, #EAF2FF);
  padding: 10px;
}

/* Light mode */
:root[data-theme='light'] .fx-select {
  background-color: rgba(12, 26, 43, 0.04);
  border-color: rgba(12, 26, 43, 0.15);
  color: var(--color-text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230C1630' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

:root[data-theme='light'] .fx-select:hover {
  background-color: rgba(12, 26, 43, 0.06);
}

:root[data-theme='light'] .fx-select option {
  background: #fff;
  color: var(--color-text-primary);
}

/* ============================================
   Text Input
   ============================================ */
.fx-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
  color: var(--color-text-primary, #EAF2FF);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.fx-input::placeholder {
  color: var(--color-text-muted, rgba(234, 242, 255, 0.5));
}

.fx-input:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.fx-input:focus {
  outline: none;
  border-color: var(--color-accent, #5a8dff);
  box-shadow: 0 0 0 3px var(--color-accent-soft, rgba(90, 141, 255, 0.18));
}

.fx-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Light mode */
:root[data-theme='light'] .fx-input {
  background: rgba(12, 26, 43, 0.04);
  border-color: rgba(12, 26, 43, 0.15);
}

:root[data-theme='light'] .fx-input:hover {
  border-color: rgba(12, 26, 43, 0.25);
}

/* ============================================
   Input with Label Group
   ============================================ */
.fx-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fx-field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary, #EAF2FF);
}

.fx-field-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted, rgba(234, 242, 255, 0.6));
  margin-top: 4px;
}

.fx-field-error {
  font-size: 0.8rem;
  color: #ff7676;
  margin-top: 4px;
}

/* ============================================
   Radio Button
   ============================================ */
.fx-radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
  color: var(--color-text-primary, #EAF2FF);
}

.fx-radio input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.fx-radio-circle {
  position: relative;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--color-border, rgba(255, 255, 255, 0.2));
  border-radius: 50%;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.fx-radio-circle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition: all 0.15s ease;
}

/* Hover */
.fx-radio:hover .fx-radio-circle {
  border-color: var(--color-accent, #5a8dff);
}

/* Focus */
.fx-radio input:focus-visible + .fx-radio-circle {
  outline: 2px solid var(--color-accent, #5a8dff);
  outline-offset: 2px;
}

/* Checked */
.fx-radio input:checked + .fx-radio-circle {
  background: var(--color-accent, #5a8dff);
  border-color: var(--color-accent, #5a8dff);
}

.fx-radio input:checked + .fx-radio-circle::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* ============================================
   Radio Group
   ============================================ */
.fx-radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fx-radio-group.horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .fx-toggle-slider,
  .fx-toggle-slider::before,
  .fx-checkbox-box,
  .fx-checkbox-box::after,
  .fx-select,
  .fx-input,
  .fx-radio-circle,
  .fx-radio-circle::after {
    transition: none;
  }
}
