/* ==================== BASE STYLES ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --success: #10b981;
  --success-dark: #059669;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --bg: #f9fafb;
  --bg-alt: #f3f4f6;
  --surface: #ffffff;
  --text: #111827;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 80px;
  min-height: 100vh;
}

/* ==================== HEADER ==================== */
.header {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* ==================== BUTTONS ==================== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.btn-success:hover {
  box-shadow: var(--shadow-lg);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.btn-danger:hover {
  box-shadow: var(--shadow-lg);
}

.btn-outline {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}

.btn-outline:hover {
  background: #f5f3ff;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  min-height: 40px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  color: white;
  padding: 12px;
  border-radius: 12px;
  min-width: 48px;
  font-size: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: var(--shadow-md);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ==================== CONTROLS ==================== */
.controls {
  padding: 16px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 68px;
  z-index: 90;
  box-shadow: var(--shadow);
}

.controls-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.controls-row:last-child {
  margin-bottom: 0;
}

select {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  min-height: 48px;
  background: white;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ==================== LIST VIEW ==================== */
.apartment-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.apartment-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.apartment-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.apartment-card:active {
  transform: translateY(0);
}

.apartment-card.selected {
  border-color: var(--primary);
  background: linear-gradient(to bottom, #f5f3ff, white);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}

/* Move-in line under title */
.movein-line {
  font-size: 13px;
  margin: 6px 0 2px;
  color: var(--text-light);
}

.movein-amount {
  font-weight: 700;
  color: var(--text);
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.card-cost {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.perk-badge {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

/* ==================== MODAL/DETAIL VIEW ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  animation: fadeIn 0.2s;
}

.modal-overlay.active {
  display: block;
}

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 90vh;
  background: white;
  border-radius: 24px 24px 0 0;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal.active {
  transform: translateY(0);
}

.modal-header {
  position: sticky;
  top: 0;
  background: white;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-body {
  padding: 20px;
  background: var(--bg);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.2s ease;
  background: white;
  color: var(--text);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input.error {
  border-color: var(--danger);
}

.error-message {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
  font-weight: 500;
}

.amenities-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.amenity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: white;
  border-radius: 12px;
  border: 2px solid var(--border);
  transition: all 0.2s ease;
  cursor: pointer;
}

.amenity-item:hover {
  border-color: var(--primary-light);
  background: #fafafa;
}

.amenity-item:has(input:checked) {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.amenity-item input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: var(--primary);
}

.amenity-item label {
  font-size: 15px;
  cursor: pointer;
  flex: 1;
  font-weight: 500;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.modal-actions .btn {
  flex: 1;
}

/* ==================== COMPARE VIEW ==================== */
.compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 2px solid var(--primary);
  padding: 16px;
  box-shadow: 0 -10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 150;
  display: none;
}

.compare-bar.active {
  display: block;
  animation: slideUp 0.3s ease-out;
}

.compare-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.compare-count {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.compare-view {
  padding: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.compare-container {
  display: flex;
  gap: 16px;
  min-width: min-content;
}

.compare-card {
  min-width: 300px;
  background: white;
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border);
  position: relative;
}

.compare-card.best-monthly {
  border: 3px solid var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), var(--shadow-lg);
}

.compare-card.best-movein {
  border: 3px solid var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), var(--shadow-lg);
}

.badge-wrapper {
  position: absolute;
  top: -0.5rem;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.best-badge {
  background: #ffe58a;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.badge-monthly {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.badge-movein {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.compare-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.compare-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.compare-row:last-child {
  border-bottom: none;
}

.compare-label {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 500;
}

.compare-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-state-icon {
  font-size: 80px;
  margin-bottom: 20px;
  opacity: 0.4;
  animation: float 3s ease-in-out infinite;
}

.empty-state-text {
  font-size: 20px;
  color: var(--text-light);
  margin-bottom: 30px;
  font-weight: 600;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* ==================== UTILITY ==================== */
.hidden {
  display: none !important;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 640px) {
  .compare-card {
    min-width: 340px;
  }
}

/* Fix controls row overflow on small screens */
@media (max-width: 420px) {
  .controls-row {
    flex-wrap: wrap;
  }

  .controls-row select {
    flex: 1 1 100%;
  }
}

/* Remove number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield; /* Firefox */
}


.form-group-row {
  display: flex;
  gap: 12px;
}

.form-group-row .half {
  flex: 1;
}

@media (max-width: 480px) {
  .form-group-row {
    flex-direction: column;
  }
}

.address-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #777; /* dimmer */
  margin: 4px 0 10px 0;
}

.address-text,
.distance-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

