/* Figma Design System - Exact Specifications */
/* Open Sans is preloaded as a self-hosted woff2 from app/views/layouts/application.html.erb */

/* Figma Button Component System */
.btn {
  font-family: 'Open Sans', sans-serif;
  font-weight: 600;
  border-radius: 6px; /* rounded-md from Figma */
  transition: all 0.2s ease;
  outline: none;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  gap: 8px; /* gap-x-2 from Figma */
}

.btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

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

.btn:active {
  transform: scale(0.95);
}

.btn:hover:not(:disabled) {
  transform: scale(1.05);
}

/* Button Variants - Exact Figma Colors */
.btn-primary {
  background-color: #46b6ff; /* homelight-blue/500 from Figma */
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background-color: #1192e5; /* homelight-blue/600 from Figma */
}

.btn-secondary {
  background-color: #f5f5f5; /* secondary from Figma */
  color: #273653; /* foreground from Figma */
}

.btn-secondary:hover:not(:disabled) {
  background-color: #f1f5f9; /* slate/100 from Figma */
}

.btn-tertiary {
  background-color: transparent;
  color: #273653; /* foreground from Figma */
}

.btn-tertiary:hover:not(:disabled) {
  background-color: #f8fafc; /* slate/50 from Figma */
}

.btn-link {
  background-color: transparent;
  color: #2563eb; /* blue link color */
  padding: 0;
  min-height: 0;
  height: auto;
}

.btn-link:hover:not(:disabled) {
  background-color: transparent;
  text-decoration: underline;
}

.btn-link,
.btn-link:hover:not(:disabled),
.btn-link:active {
  transform: none;
}

.btn-destructive {
  background-color: #ef4444; /* red/500 from Figma */
  color: #ffffff;
}

.btn-destructive:hover:not(:disabled) {
  background-color: #dc2626; /* red/600 from Figma */
}

.btn-destructive-outline {
  background-color: transparent;
  color: #ef4444; /* red/500 from Figma */
  border: 2px solid #ef4444; /* stroke-2 from Figma */
}

.btn-destructive-outline:hover:not(:disabled) {
  background-color: #fef2f2;
}

.btn-conversion-primary {
  background-color: #f97316; /* orange/500 from Figma */
  color: #ffffff;
}

.btn-conversion-primary:hover:not(:disabled) {
  background-color: #ea580c; /* orange/600 from Figma */
}

.btn-conversion-secondary {
  background-color: transparent;
  color: #f97316; /* orange/500 from Figma */
  border: 2px solid #f97316; /* stroke-2 from Figma */
}

.btn-conversion-secondary:hover:not(:disabled) {
  background-color: #fb923c; /* orange/400 from Figma */
}

.btn-submit-orange {
  background-color: #f97316; /* orange/500 from Figma */
  color: #ffffff;
}

.btn-submit-orange:hover:not(:disabled) {
  background-color: #ea580c; /* orange/600 from Figma */
}

/* Button Sizes - Exact Figma Specifications */
.btn-xm {
  padding: 8px 16px; /* py-2 px-4 from Figma */
  font-size: 14px;
  line-height: 20px;
  min-height: 32px;
}

.btn-sm {
  padding: 12px 20px;
  font-size: 16px; /* Text-base/Medium from Figma */
  line-height: 24px; /* Text-base/Medium from Figma */
  min-height: 40px;
}

.btn-md {
  padding: 16px 24px;
  font-size: 16px; /* Text-base/Medium from Figma */
  line-height: 24px; /* Text-base/Medium from Figma */
  min-height: 48px;
}

.btn-lg {
  padding: 20px 32px;
  font-size: 18px;
  line-height: 28px;
  min-height: 56px;
}

/* Figma Form Input System */
.form-input {
  width: 100%;
  padding: 12px 16px; /* py-3 px-4 from Figma */
  font-family: 'Open Sans', sans-serif;
  font-size: 16px; /* Text-base/Medium from Figma */
  line-height: 24px; /* Text-base/Medium from Figma */
  border-radius: 6px; /* rounded-md from Figma */
  border: 2px solid; /* stroke-2 from Figma */
  transition: all 0.2s ease;
  outline: none;
  min-height: 48px;
}

.form-input:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

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

.form-input-default {
  border-color: #cbd5e1; /* slate/300 from Figma */
  background-color: #ffffff;
}

.form-input-default:focus {
  border-color: #46b6ff; /* homelight-blue/500 from Figma */
}

.form-input-error {
  border-color: #ef4444; /* red/500 from Figma */
  background-color: #ffffff;
}

.form-input-error:focus {
  border-color: #ef4444; /* red/500 from Figma */
}

.form-input-success {
  border-color: #f97316; /* orange/500 from Figma */
  background-color: #fb923c; /* orange/400 from Figma */
}

.form-input-success:focus {
  border-color: #f97316; /* orange/500 from Figma */
}

.form-error-message {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  color: #ef4444; /* red/500 from Figma */
  margin-top: 4px;
}

.form-success-message {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  color: #f97316; /* orange/500 from Figma */
  margin-top: 4px;
}

/* Figma Checkbox System */
.form-checkbox {
  width: 20px; /* h-5 from Figma */
  height: 20px; /* w-5 from Figma */
  border-radius: 4px; /* rounded-sm from Figma */
  border: 2px solid #cbd5e1; /* stroke-2 slate/300 from Figma */
  background-color: #ffffff;
  color: #46b6ff; /* homelight-blue/500 from Figma */
  transition: all 0.2s ease;
  outline: none;
  cursor: pointer;
}

.form-checkbox:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(70, 182, 255, 0.5); /* homelight-blue/500 with opacity */
}

.form-checkbox:checked {
  background-color: #46b6ff; /* homelight-blue/500 from Figma */
  border-color: #46b6ff; /* homelight-blue/500 from Figma */
}

.form-checkbox:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-checkbox-error {
  border-color: #ef4444; /* red/500 from Figma */
}

.form-checkbox-error:focus {
  border-color: #ef4444; /* red/500 from Figma */
}

.form-checkbox-label {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #273653; /* foreground from Figma */
  cursor: pointer;
}

.form-required-indicator {
  color: #ef4444; /* red/500 from Figma */
  margin-left: 4px;
}

/* Figma Form Field System */
.form-field-label {
  display: block;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #273653; /* foreground from Figma */
  margin-bottom: 8px;
}

/* Figma Autocomplete System */
.autocomplete-dropdown {
  position: absolute;
  z-index: 99999; /* Much higher than sticky CTA button (z-index: 9999) */
  margin-top: 8px;
  width: 100%;
  border-radius: 6px; /* rounded-md from Figma */
  border: 2px solid #cbd5e1; /* stroke-2 slate/300 from Figma */
  background-color: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  /* Ensure dropdown is not clipped by parent containers */
  overflow: visible;
}

/* Mobile-specific adjustments for autocomplete */
@media (max-width: 768px) {
  .autocomplete-dropdown {
    /* Ensure it appears above mobile keyboards and other elements */
    z-index: 999999;
    /* Add better shadow for mobile visibility */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    /* Limit height on mobile to prevent overflow */
    max-height: 200px;
  }
  
  .autocomplete-dropdown ul {
    /* Reduce max height on mobile */
    max-height: 180px;
  }
}

.autocomplete-suggestion {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px; /* gap-x-2 from Figma */
  padding: 12px 16px; /* py-3 px-4 from Figma */
  text-align: left;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  color: #273653; /* foreground from Figma */
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-height: 44px; /* Touch-friendly */
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion:focus {
  background-color: #f1f5f9; /* slate/100 from Figma */
  outline: none;
}

/* Figma Typography System */
.heading-1 {
  font-family: 'Open Sans', sans-serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 40px;
  color: #273653; /* foreground from Figma */
}

.heading-2 {
  font-family: 'Open Sans', sans-serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  color: #273653; /* foreground from Figma */
}

.heading-3 {
  font-family: 'Open Sans', sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  color: #273653; /* foreground from Figma */
}

.body-large {
  font-family: 'Open Sans', sans-serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 28px;
  color: #273653; /* foreground from Figma */
}

.body-medium {
  font-family: 'Open Sans', sans-serif;
  font-size: 16px; /* Text-base/Medium from Figma */
  font-weight: 400;
  line-height: 24px; /* Text-base/Medium from Figma */
  color: #273653; /* foreground from Figma */
}

.body-small {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  color: #737373; /* muted-foreground from Figma */
}

/* Figma Spacing System */
.space-figma-xs { margin-bottom: 4px; }
.space-figma-sm { margin-bottom: 8px; }
.space-figma-md { margin-bottom: 16px; }
.space-figma-lg { margin-bottom: 24px; }
.space-figma-xl { margin-bottom: 32px; }
.space-figma-2xl { margin-bottom: 48px; }

/* Mobile-first responsive improvements */
@media (max-width: 640px) {
  /* Ensure proper touch targets while maintaining Figma specs */
  .btn {
    min-height: 44px; /* iOS minimum touch target */
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .btn-lg {
    min-height: 48px;
    font-size: 18px;
  }
  
  /* Improve form field spacing on mobile */
  .form-control {
    min-height: 44px;
  }
  
  /* Better mobile navigation */
  .navbar .dropdown-content {
    z-index: 50;
  }
  
  /* Prevent horizontal scroll on mobile */
  body {
    overflow-x: hidden;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets for touch devices */
  .btn {
    min-height: 48px; /* Enhanced touch target */
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .btn-lg {
    min-height: 52px;
    font-size: 18px;
  }
  
  .form-control {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Better spacing for touch */
  .space-y-4 > * + * {
    margin-top: 1rem;
  }
}

/* HELOC card submission flow (homes-heloc-card-portal UI + homes-fe application-flow layout patterns) */
.heloc-card-flow-root {
  --heloc-flow-primary: #46b6ff;
  --heloc-flow-primary-strong: #1192e5;
  --heloc-flow-radius-md: 6px;
  --heloc-flow-muted: #64748b;
  --heloc-flow-border: #e2e8f0;
  --heloc-flow-ink: #273653;
}

.heloc-card-flow-root .input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--heloc-flow-border);
  border-radius: var(--heloc-flow-radius-md);
  background: white;
  color: var(--heloc-flow-ink);
  font-size: 16px;
  line-height: 24px;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.heloc-card-flow-root .input::placeholder {
  color: var(--heloc-flow-muted);
}

.heloc-card-flow-root .input:hover:not(:disabled):not(:focus) {
  border-color: var(--heloc-flow-ink);
}

.heloc-card-flow-root .input:focus {
  border-width: 2px;
  border-color: var(--heloc-flow-primary);
}

.heloc-card-flow-root .input:disabled {
  background: #f8fafc;
  color: var(--heloc-flow-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.heloc-card-flow-root .quiz-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 20px;
  color: var(--heloc-flow-ink);
  font-weight: 500;
}

.heloc-card-flow-root .quiz-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--heloc-flow-radius-md);
  background: var(--heloc-flow-primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.heloc-card-flow-root .quiz-cta:hover:not(:disabled) {
  background: var(--heloc-flow-primary-strong);
}

.heloc-card-flow-root .quiz-cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.heloc-card-flow-root .quiz-cta-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--heloc-flow-primary);
  border-radius: var(--heloc-flow-radius-md);
  background: transparent;
  color: var(--heloc-flow-primary-strong);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.heloc-card-flow-root .quiz-cta-secondary:hover:not(:disabled) {
  background: #e9f6ff;
}

.heloc-card-flow-root .quiz-cta-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.heloc-card-flow-root input[type="range"].heloc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  outline: none;
  cursor: pointer;
  border: none;
  padding: 0;
}

.heloc-card-flow-root input[type="range"].heloc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 2px solid #46b6ff;
}

.heloc-card-flow-root input[type="range"].heloc-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 2px solid #46b6ff;
}

.heloc-card-flow-root input[type="range"].heloc-slider::-moz-range-track {
  height: 6px;
  border-radius: 9999px;
}
