/* 
 * HouseBlue Responsive Forms
 * Touch-friendly, mobile-first form components
 */

/* =============================================================================
   FORM FOUNDATION
   ============================================================================= */

.hb-form {
  --form-spacing: var(--hb-space-4);
  --form-spacing-sm: var(--hb-space-3);
  --form-spacing-lg: var(--hb-space-6);
}

.hb-form-group {
  margin-bottom: var(--form-spacing);
}

.hb-form-group:last-child {
  margin-bottom: 0;
}

/* =============================================================================
   LABELS
   ============================================================================= */

.hb-label {
  display: block;
  font-weight: 600;
  font-size: var(--hb-text-sm);
  color: var(--hb-gray-700);
  margin-bottom: var(--hb-space-2);
  line-height: 1.5;
}

.hb-label.required::after {
  content: '*';
  color: var(--hb-danger);
  margin-left: var(--hb-space-1);
}

.hb-label-hint {
  font-weight: 400;
  color: var(--hb-gray-500);
  font-size: var(--hb-text-xs);
  margin-top: var(--hb-space-1);
  display: block;
}

/* =============================================================================
   INPUT FIELDS (Mobile-First)
   ============================================================================= */

.hb-input {
  display: block;
  width: 100%;
  min-height: 44px; /* Touch-friendly minimum */
  padding: var(--hb-space-3) var(--hb-space-4);
  font-size: var(--hb-text-base);
  line-height: 1.5;
  color: var(--hb-gray-700);
  background: var(--hb-white);
  border: 2px solid var(--hb-gray-300);
  border-radius: var(--hb-radius);
  transition: var(--hb-transition);
  font-family: 'Nunito', sans-serif;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.hb-input:focus {
  outline: none;
  border-color: var(--hb-primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
  background: var(--hb-white);
}

.hb-input:disabled {
  background: var(--hb-gray-100);
  color: var(--hb-gray-500);
  cursor: not-allowed;
}

.hb-input::placeholder {
  color: var(--hb-gray-400);
}

/* Input States */
.hb-input.error {
  border-color: var(--hb-danger);
  background: #fef2f2;
}

.hb-input.error:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.hb-input.success {
  border-color: var(--hb-success);
  background: #f0fdf4;
}

.hb-input.success:focus {
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.15);
}

/* =============================================================================
   TEXTAREA
   ============================================================================= */

.hb-textarea {
  min-height: 100px;
  resize: vertical;
  font-family: 'Nunito', sans-serif;
}

/* Auto-resizing textarea */
.hb-textarea.auto-resize {
  resize: none;
  overflow: hidden;
}

/* =============================================================================
   SELECT DROPDOWNS
   ============================================================================= */

.hb-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--hb-space-3) center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: var(--hb-space-10);
}

.hb-select:focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%230d6efd' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* =============================================================================
   INPUT GROUPS
   ============================================================================= */

.hb-input-group {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
}

.hb-input-group .hb-input {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

.hb-input-group-prepend,
.hb-input-group-append {
  display: flex;
  align-items: center;
}

.hb-input-group-prepend {
  margin-right: -2px;
}

.hb-input-group-append {
  margin-left: -2px;
}

.hb-input-group-text {
  display: flex;
  align-items: center;
  padding: var(--hb-space-3) var(--hb-space-4);
  font-size: var(--hb-text-base);
  font-weight: 500;
  line-height: 1.5;
  color: var(--hb-gray-600);
  text-align: center;
  background: var(--hb-gray-100);
  border: 2px solid var(--hb-gray-300);
  border-radius: var(--hb-radius);
  min-height: 44px;
}

.hb-input-group-prepend .hb-input-group-text {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}

.hb-input-group-append .hb-input-group-text {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
}

.hb-input-group .hb-input:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.hb-input-group .hb-input:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* =============================================================================
   CHECKBOXES AND RADIOS
   ============================================================================= */

.hb-checkbox,
.hb-radio {
  position: relative;
  display: flex;
  align-items: flex-start;
  min-height: 44px; /* Touch-friendly */
  padding: var(--hb-space-2) 0;
  cursor: pointer;
}

.hb-checkbox input[type="checkbox"],
.hb-radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.hb-checkbox-indicator,
.hb-radio-indicator {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: var(--hb-space-3);
  margin-top: var(--hb-space-1);
  border: 2px solid var(--hb-gray-300);
  background: var(--hb-white);
  transition: var(--hb-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hb-checkbox-indicator {
  border-radius: var(--hb-radius-sm);
}

.hb-radio-indicator {
  border-radius: 50%;
}

.hb-checkbox input:checked + .hb-checkbox-indicator,
.hb-radio input:checked + .hb-radio-indicator {
  background: var(--hb-primary);
  border-color: var(--hb-primary);
}

.hb-checkbox input:checked + .hb-checkbox-indicator::after {
  content: '';
  width: 0.375rem;
  height: 0.75rem;
  border: solid var(--hb-white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.hb-radio input:checked + .hb-radio-indicator::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--hb-white);
}

.hb-checkbox:hover .hb-checkbox-indicator,
.hb-radio:hover .hb-radio-indicator {
  border-color: var(--hb-primary);
}

.hb-checkbox input:focus + .hb-checkbox-indicator,
.hb-radio input:focus + .hb-radio-indicator {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.hb-checkbox-label,
.hb-radio-label {
  font-size: var(--hb-text-base);
  line-height: 1.5;
  color: var(--hb-gray-700);
  cursor: pointer;
}

/* =============================================================================
   SWITCH TOGGLE
   ============================================================================= */

.hb-switch {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
}

.hb-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.hb-switch-track {
  position: relative;
  width: 3rem;
  height: 1.5rem;
  background: var(--hb-gray-300);
  border-radius: var(--hb-radius-full);
  transition: var(--hb-transition);
  margin-right: var(--hb-space-3);
}

.hb-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--hb-white);
  border-radius: 50%;
  transition: var(--hb-transition);
  box-shadow: var(--hb-shadow-sm);
}

.hb-switch input:checked + .hb-switch-track {
  background: var(--hb-primary);
}

.hb-switch input:checked + .hb-switch-track .hb-switch-thumb {
  transform: translateX(1.5rem);
}

.hb-switch input:focus + .hb-switch-track {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.hb-switch-label {
  font-size: var(--hb-text-base);
  line-height: 1.5;
  color: var(--hb-gray-700);
  cursor: pointer;
}

/* =============================================================================
   FILE UPLOAD
   ============================================================================= */

.hb-file-upload {
  position: relative;
  display: block;
  width: 100%;
  min-height: 100px;
  border: 2px dashed var(--hb-gray-300);
  border-radius: var(--hb-radius-lg);
  background: var(--hb-gray-50);
  text-align: center;
  cursor: pointer;
  transition: var(--hb-transition);
  padding: var(--hb-space-6);
}

.hb-file-upload:hover {
  border-color: var(--hb-primary);
  background: rgba(13, 110, 253, 0.05);
}

.hb-file-upload input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.hb-file-upload-content {
  pointer-events: none;
}

.hb-file-upload-icon {
  font-size: var(--hb-text-4xl);
  color: var(--hb-gray-400);
  margin-bottom: var(--hb-space-2);
}

.hb-file-upload-text {
  font-size: var(--hb-text-base);
  color: var(--hb-gray-600);
  margin-bottom: var(--hb-space-1);
}

.hb-file-upload-hint {
  font-size: var(--hb-text-sm);
  color: var(--hb-gray-500);
}

/* =============================================================================
   BUTTONS (Touch-Friendly)
   ============================================================================= */

.hb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* Touch-friendly */
  padding: var(--hb-space-3) var(--hb-space-6);
  font-size: var(--hb-text-base);
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--hb-radius);
  transition: var(--hb-transition);
  font-family: 'Nunito', sans-serif;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  user-select: none;
  white-space: nowrap;
}

.hb-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.hb-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.hb-btn.primary {
  background: linear-gradient(135deg, var(--hb-primary) 0%, var(--hb-primary-dark) 100%);
  color: var(--hb-white);
}

.hb-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--hb-shadow-md);
}

.hb-btn.secondary {
  background: var(--hb-gray-100);
  color: var(--hb-gray-700);
  border-color: var(--hb-gray-300);
}

.hb-btn.secondary:hover {
  background: var(--hb-gray-200);
  border-color: var(--hb-gray-400);
}

.hb-btn.outline {
  background: transparent;
  color: var(--hb-primary);
  border-color: var(--hb-primary);
}

.hb-btn.outline:hover {
  background: var(--hb-primary);
  color: var(--hb-white);
}

.hb-btn.success {
  background: linear-gradient(135deg, var(--hb-success) 0%, #0d9488 100%);
  color: var(--hb-white);
}

.hb-btn.danger {
  background: linear-gradient(135deg, var(--hb-danger) 0%, #b91c1c 100%);
  color: var(--hb-white);
}

/* Button Sizes */
.hb-btn.sm {
  min-height: 36px;
  padding: var(--hb-space-2) var(--hb-space-4);
  font-size: var(--hb-text-sm);
}

.hb-btn.lg {
  min-height: 52px;
  padding: var(--hb-space-4) var(--hb-space-8);
  font-size: var(--hb-text-lg);
}

.hb-btn.block {
  display: flex;
  width: 100%;
}

/* Button with Icon */
.hb-btn i {
  margin-right: var(--hb-space-2);
}

.hb-btn i:last-child {
  margin-right: 0;
  margin-left: var(--hb-space-2);
}

.hb-btn.icon-only {
  padding: var(--hb-space-3);
  min-width: 44px;
}

.hb-btn.icon-only i {
  margin: 0;
}

/* =============================================================================
   FORM VALIDATION
   ============================================================================= */

.hb-form-error {
  color: var(--hb-danger);
  font-size: var(--hb-text-sm);
  margin-top: var(--hb-space-1);
  display: block;
}

.hb-form-success {
  color: var(--hb-success);
  font-size: var(--hb-text-sm);
  margin-top: var(--hb-space-1);
  display: block;
}

.hb-form-help {
  color: var(--hb-gray-500);
  font-size: var(--hb-text-sm);
  margin-top: var(--hb-space-1);
  display: block;
}

/* =============================================================================
   FLOATING LABELS
   ============================================================================= */

.hb-floating-label {
  position: relative;
}

.hb-floating-label .hb-input {
  padding-top: var(--hb-space-6);
  padding-bottom: var(--hb-space-2);
}

.hb-floating-label .hb-label {
  position: absolute;
  top: 0;
  left: var(--hb-space-4);
  background: var(--hb-white);
  padding: 0 var(--hb-space-1);
  color: var(--hb-gray-500);
  font-size: var(--hb-text-sm);
  font-weight: 500;
  transform: translateY(var(--hb-space-4));
  transition: var(--hb-transition);
  pointer-events: none;
  z-index: 1;
}

.hb-floating-label .hb-input:focus + .hb-label,
.hb-floating-label .hb-input:not(:placeholder-shown) + .hb-label {
  transform: translateY(var(--hb-space-1));
  font-size: var(--hb-text-xs);
  color: var(--hb-primary);
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (min-width: 768px) {
  .hb-input,
  .hb-btn {
    min-height: 40px; /* Slightly smaller on desktop */
  }
  
  .hb-btn.lg {
    min-height: 48px;
  }
  
  .hb-form {
    --form-spacing: var(--hb-space-5);
  }
}

@media (min-width: 992px) {
  .hb-form {
    --form-spacing: var(--hb-space-6);
  }
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

.hb-form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--hb-space-4);
}

.hb-form-inline .hb-form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

.hb-form-row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--hb-space-2));
}

.hb-form-col {
  flex: 1;
  padding: 0 var(--hb-space-2);
  min-width: 0;
}

@media (max-width: 767.98px) {
  .hb-form-inline {
    flex-direction: column;
    align-items: stretch;
  }
  
  .hb-form-inline .hb-form-group {
    min-width: auto;
  }
  
  .hb-form-row {
    flex-direction: column;
    margin: 0;
  }
  
  .hb-form-col {
    padding: 0;
    margin-bottom: var(--hb-space-4);
  }
  
  .hb-form-col:last-child {
    margin-bottom: 0;
  }
}