/**
 * Housing Search - Modern UI Enhancements
 * 
 * This stylesheet provides a modern, cohesive, and visually "alive" design
 * for the Housing Search feature with:
 * - Enhanced status pills with glow effects
 * - Smooth state transitions
 * - Polished buttons with depth
 * - Loading animations
 * - Color-coded map rings that "pop"
 */

/* ===== CSS Custom Properties ===== */
:root {
  --housing-border-accent-height: 4px;
}

/* ===== Enhanced Form Styling ===== */
.home-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.home-form .field input,
.home-form .field select {
  transition: all 0.3s ease;
}

.home-form .field input:focus,
.home-form .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(210, 105, 30, 0.1);
  transform: translateY(-1px);
}

/* Enhanced radius input with visual feedback */
#radius_ft {
  font-weight: 600;
  color: var(--accent);
}

/* Modern checkboxes */
.checks label {
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
  padding: 4px 8px;
  border-radius: 6px;
}

.checks label:hover {
  background: rgba(210, 105, 30, 0.05);
}

.checks input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ===== Enhanced Buttons with Depth ===== */
.actions button {
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(210, 105, 30, 0.3);
}

.actions button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Button ripple effect */
.actions button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.actions button:active::after {
  width: 300px;
  height: 300px;
}

/* ===== Enhanced Result Card with State Transitions ===== */
.result-card {
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--housing-border-accent-height);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.result-card:not([hidden])::before {
  opacity: 1;
}

/* State-based card styling */
.result-card.state-ok {
  border-color: var(--ok);
  background: linear-gradient(to bottom, rgba(107, 142, 35, 0.02), var(--card));
}

.result-card.state-warn {
  border-color: var(--warn);
  background: linear-gradient(to bottom, rgba(234, 88, 12, 0.02), var(--card));
}

.result-card.state-bad {
  border-color: var(--bad);
  background: linear-gradient(to bottom, rgba(220, 38, 38, 0.02), var(--card));
}

.result-card.state-loading {
  border-color: #9ca3af;
  background: linear-gradient(to bottom, rgba(156, 163, 175, 0.02), var(--card));
}

/* ===== Enhanced Status Pills with Glow ===== */
.status-pill {
  position: relative;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  animation: pillFadeIn 0.4s ease;
}

@keyframes pillFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Status-specific glow effects */
.status-pill.status-green {
  background: var(--ok);
  box-shadow: 0 2px 12px rgba(107, 142, 35, 0.4),
              0 0 20px rgba(107, 142, 35, 0.2);
}

.status-pill.status-yellow {
  background: var(--warn);
  box-shadow: 0 2px 12px rgba(234, 88, 12, 0.4),
              0 0 20px rgba(234, 88, 12, 0.2);
}

.status-pill.status-red {
  background: var(--bad);
  box-shadow: 0 2px 12px rgba(220, 38, 38, 0.4),
              0 0 20px rgba(220, 38, 38, 0.2);
  animation: pillPulse 2s ease-in-out infinite;
}

.status-pill.status-loading {
  background: #6b7280;
  animation: pillLoading 1.5s ease-in-out infinite;
}

@keyframes pillPulse {
  0%, 100% {
    box-shadow: 0 2px 12px rgba(220, 38, 38, 0.4),
                0 0 20px rgba(220, 38, 38, 0.2);
  }
  50% {
    box-shadow: 0 2px 16px rgba(220, 38, 38, 0.6),
                0 0 30px rgba(220, 38, 38, 0.3);
  }
}

@keyframes pillLoading {
  0%, 100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* ===== Loading State ===== */
.result-card.state-loading .result-title {
  position: relative;
  color: #6b7280;
}

.result-card.state-loading .result-title::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 8px;
  border-radius: 50%;
  background: #6b7280;
  animation: loadingDots 1.4s ease-in-out infinite;
}

@keyframes loadingDots {
  0%, 20% {
    box-shadow: 0 0 0 0 #6b7280,
                12px 0 0 0 #6b7280,
                24px 0 0 0 #6b7280;
  }
  40% {
    box-shadow: 0 0 0 0 #6b7280,
                12px -6px 0 0 #6b7280,
                24px 0 0 0 #6b7280;
  }
  60% {
    box-shadow: 0 -6px 0 0 #6b7280,
                12px 0 0 0 #6b7280,
                24px -6px 0 0 #6b7280;
  }
  80%, 100% {
    box-shadow: 0 0 0 0 #6b7280,
                12px 0 0 0 #6b7280,
                24px 0 0 0 #6b7280;
  }
}

/* ===== Enhanced Restriction Alert ===== */
.restriction-alert {
  animation: alertSlideIn 0.4s ease;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

@keyframes alertSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.restriction-alert strong {
  animation: alertPulse 2s ease-in-out infinite;
}

@keyframes alertPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* ===== Enhanced Map Styling ===== */
.map {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  animation: mapFadeIn 0.5s ease;
}

@keyframes mapFadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Enhanced map with state border */
.result-card.state-ok .map {
  border-color: var(--ok);
  border-width: 2px;
}

.result-card.state-warn .map {
  border-color: var(--warn);
  border-width: 2px;
}

.result-card.state-bad .map {
  border-color: var(--bad);
  border-width: 2px;
}

/* ===== Enhanced POI List ===== */
.nearby-list {
  animation: listFadeIn 0.4s ease;
}

@keyframes listFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nearby-list li {
  transition: all 0.2s ease;
  background: var(--bg);
}

.nearby-list li:hover {
  background: linear-gradient(90deg, rgba(210, 105, 30, 0.05), var(--bg));
  border-color: var(--accent);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.nearby-list .poi {
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.nearby-list li:hover .poi {
  transform: scale(1.2);
}

/* ===== Enhanced Toggle Button ===== */
.toggle-button {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.toggle-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toggle-button:active {
  transform: translateY(0);
}

/* ===== Radius Selector Enhancement ===== */
.radius-presets {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.radius-preset-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.radius-preset-btn:hover {
  border-color: var(--accent);
  background: var(--card);
  transform: translateY(-1px);
}

.radius-preset-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(210, 105, 30, 0.3);
}

/* ===== Microcopy Styling ===== */
.info-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(210, 105, 30, 0.1);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

.info-badge::before {
  content: 'ℹ️';
  font-size: 0.9rem;
}

/* ===== DEV Badge ===== */
.dev-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin: 10px 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(147, 51, 234, 0.1));
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  font-size: 0.9rem;
  color: #3b82f6;
  font-weight: 600;
  animation: devBadgePulse 3s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

@keyframes devBadgePulse {
  0%, 100% {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
  }
  50% {
    border-color: rgba(147, 51, 234, 0.4);
    box-shadow: 0 2px 12px rgba(147, 51, 234, 0.3);
  }
}

/* ===== Distance Badge ===== */
#status-distance {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(139, 115, 85, 0.1);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-2);
}

/* ===== Responsive Enhancements ===== */
@media (max-width: 640px) {
  .home-form {
    padding: 16px;
  }
  
  .home-form .field input,
  .home-form .field select {
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 48px;
    padding: 12px;
  }
  
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .status-pill {
    font-size: 0.75rem;
    padding: 3px 8px;
  }
  
  .result-card {
    padding: 14px;
  }
  
  .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .result-title {
    font-size: 1.1rem;
  }
  
  .map {
    height: 260px;
    border-radius: 8px;
  }
  
  .radius-presets {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .radius-preset-btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 40px;
  }
  
  .checks {
    flex-direction: column;
    gap: 10px;
  }
  
  .checks label {
    width: 100%;
    padding: 10px 14px;
    min-height: 48px;
  }
  
  .actions {
    flex-direction: column;
  }
  
  .actions button {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
  }
  
  .poi-list-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .toggle-button {
    padding: 8px 12px;
    min-height: 40px;
  }
  
  .nearby-list li {
    padding: 10px;
    font-size: 14px;
  }
  
  .imagery img {
    border-radius: 8px;
  }
}

@media (max-width: 480px) {
  .home-form {
    padding: 12px;
  }
  
  .result-card {
    padding: 12px;
  }
  
  .map {
    height: 220px;
  }
  
  .tool-intro {
    font-size: 14px;
    line-height: 1.5;
  }
  
  .disclaimer {
    font-size: 12px;
    padding: 10px;
  }
}

/* ===== Accessibility Enhancements ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible styles for keyboard navigation */
.actions button:focus-visible,
.toggle-button:focus-visible,
.radius-preset-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.nearby-list li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Active Filters Display ===== */
.active-filters {
  margin: 16px 0;
  padding: 12px;
  background: linear-gradient(135deg, rgba(210, 105, 30, 0.05), rgba(139, 115, 85, 0.05));
  border: 1px solid var(--border);
  border-radius: 8px;
  animation: filtersFadeIn 0.3s ease;
}

@keyframes filtersFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.active-filters strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.9rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 16px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(210, 105, 30, 0.3);
}

/* Warning message styling */
.other-restriction-warning {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(234, 88, 12, 0.1);
  border-left: 3px solid var(--warn);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--warn);
  animation: warningSlideIn 0.3s ease;
}

@keyframes warningSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Partial Failure Warning */
.partial-failure-warning {
  margin: 16px 0;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.1), rgba(251, 146, 60, 0.05));
  border: 2px solid var(--warn);
  border-radius: 8px;
  animation: warningSlideIn 0.3s ease;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.15);
}

.partial-failure-warning strong {
  display: block;
  margin-bottom: 6px;
  color: var(--warn);
  font-size: 1rem;
}

.partial-failure-warning p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}
