/* =====================================================
   CUSTOM FORM COMPONENTS - GAMING STYLE
   Built from scratch for game server hosting
   ===================================================== */

/* =====================================================
   BASE INPUT STYLING
   ===================================================== */

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-regular);
  transition: all var(--transition-fast);
  outline: none;
  font-family: var(--font-primary);
}

/* Focus State */
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: var(--bg-tertiary);
}

/* Hover State */
.form-control:hover,
input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-hover);
}

/* Disabled State */
.form-control:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--bg-primary);
  border-color: var(--border-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Placeholder Styling */
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* =====================================================
   TEXTAREA
   ===================================================== */

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-primary);
  line-height: 1.6;
}

textarea.form-control-lg {
  min-height: 200px;
}

/* =====================================================
   SELECT DROPDOWN
   ===================================================== */

select {
  cursor: pointer;
  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'%3E%3Cpath fill='%23cbd5e1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-8);
}

select:focus {
  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 fill='%233b82f6' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: var(--space-2);
}

/* =====================================================
   FORM GROUPS
   ===================================================== */

.form-group {
  margin-bottom: var(--space-5);
}

.form-group:last-child {
  margin-bottom: 0;
}

/* =====================================================
   LABELS
   ===================================================== */

label,
.form-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

label.required::after,
.form-label.required::after {
  content: " *";
  color: var(--action-danger);
  margin-left: var(--space-1);
}

/* =====================================================
   INPUT SIZES
   ===================================================== */

/* Small Input */
.form-control-sm,
input.input-sm,
select.select-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
}

/* Large Input */
.form-control-lg,
input.input-lg,
select.select-lg {
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-lg);
}

/* =====================================================
   INPUT WITH ICONS
   ===================================================== */

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group-icon {
  position: absolute;
  left: var(--space-4);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.input-group-icon + input,
.input-group-icon + .form-control {
  padding-left: var(--space-10);
}

.input-group-icon-right {
  position: absolute;
  right: var(--space-4);
  color: var(--text-muted);
  pointer-events: none;
}

.input-group-icon-right ~ input,
.input-group-icon-right ~ .form-control {
  padding-right: var(--space-10);
}

/* Clickable Icons (like password toggle) */
.input-group-icon-clickable {
  pointer-events: auto;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.input-group-icon-clickable:hover {
  color: var(--brand-primary);
}

/* =====================================================
   SEARCH INPUT
   ===================================================== */

.search-input {
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  padding-left: var(--space-10);
  border-radius: var(--radius-full);
}

.search-input:focus {
  background: var(--bg-secondary);
  border-color: var(--brand-primary);
}

.search-icon {
  position: absolute;
  left: var(--space-4);
  color: var(--text-muted);
}

/* =====================================================
   CHECKBOXES & RADIO BUTTONS
   ===================================================== */

/* Hide default checkbox/radio */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-primary);
  background: var(--bg-secondary);
  cursor: pointer;
  position: relative;
  margin-right: var(--space-2);
  transition: all var(--transition-fast);
}

input[type="checkbox"] {
  border-radius: var(--radius-sm);
}

input[type="radio"] {
  border-radius: var(--radius-full);
}

/* Hover State */
input[type="checkbox"]:hover,
input[type="radio"]:hover {
  border-color: var(--brand-primary);
}

/* Checked State */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* Checkbox Checkmark */
input[type="checkbox"]:checked::before {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

/* Radio Dot */
input[type="radio"]:checked::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
}

/* Focus State */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Checkbox/Radio Label */
.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-regular);
  text-transform: none;
  letter-spacing: normal;
}

.checkbox-label:hover,
.radio-label:hover {
  color: var(--text-secondary);
}

/* =====================================================
   TOGGLE SWITCH
   ===================================================== */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-primary);
  transition: all var(--transition-fast);
  border-radius: var(--radius-full);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  transition: all var(--transition-fast);
  border-radius: 50%;
}

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

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

input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* =====================================================
   FORM VALIDATION STATES
   ===================================================== */

/* Success State */
.form-control.is-valid,
input.is-valid,
textarea.is-valid,
select.is-valid {
  border-color: var(--action-success);
}

.form-control.is-valid:focus,
input.is-valid:focus,
textarea.is-valid:focus,
select.is-valid:focus {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

/* Error State */
.form-control.is-invalid,
input.is-invalid,
textarea.is-invalid,
select.is-invalid {
  border-color: var(--action-danger);
}

.form-control.is-invalid:focus,
input.is-invalid:focus,
textarea.is-invalid:focus,
select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Validation Feedback Text */
.valid-feedback {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--action-success);
}

.invalid-feedback {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--action-danger);
}

/* Help Text */
.form-text,
.help-block {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

/* =====================================================
   INPUT GROUPS WITH BUTTONS
   ===================================================== */

.input-button-group {
  display: flex;
  gap: var(--space-2);
}

.input-button-group input {
  flex: 1;
}

.input-button-group .btn-gaming {
  flex-shrink: 0;
}

/* =====================================================
   FORM LAYOUTS
   ===================================================== */

/* Inline Form */
.form-inline {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.form-inline .form-group {
  margin-bottom: 0;
  flex: 1;
}

/* Grid Form (2 columns) */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.form-grid .form-group-full {
  grid-column: 1 / -1;
}

/* Responsive - Stack on mobile */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =====================================================
   FILE UPLOAD
   ===================================================== */

input[type="file"] {
  padding: var(--space-2);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  padding: var(--space-2) var(--space-4);
  background: var(--bg-tertiary);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-right: var(--space-3);
}

input[type="file"]::file-selector-button:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}

/* =====================================================
   RANGE SLIDER
   ===================================================== */

input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-full);
  outline: none;
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--brand-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--brand-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.6);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.6);
}

/* =====================================================
   LOADING STATE
   ===================================================== */

.form-control.is-loading,
input.is-loading,
select.is-loading {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%233b82f6' d='M10 2a8 8 0 108 8h-2a6 6 0 11-6-6V2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  animation: spin 1s linear infinite;
  padding-right: var(--space-10);
}

@keyframes spin {
  from { background-position: right var(--space-4) center; }
  to { background-position: right var(--space-4) center; }
}
