/* Map page — extends StudentBase dark theme */
body.map-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.map-page .site-header {
  flex-shrink: 0;
}

.app-container {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.sidebar {
  width: 340px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 900;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: var(--text);
}

.sidebar-header input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  background: var(--surface2);
  color: var(--text);
}

.sidebar-header input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2);
}

.location-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.location-status.locating .status-dot {
  background: #f39c12;
  animation: map-pulse 1.2s infinite;
}

.location-status.found .status-dot {
  background: var(--accent);
}

.location-status.error .status-dot {
  background: #e74c3c;
}

@keyframes map-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.house-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.house-card {
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.house-card:hover {
  border-color: #333;
}

.house-card.active {
  border-color: var(--accent);
  background: rgba(39, 174, 96, 0.08);
}

.house-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.house-card-header h3 {
  font-size: 0.95rem;
  color: var(--text);
}

.price-tag {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--accent);
  white-space: nowrap;
}

.house-address {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.house-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.house-card-actions {
  display: flex;
  gap: 8px;
}

.route-panel {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  background: rgba(39, 174, 96, 0.06);
  max-height: 40%;
  overflow-y: auto;
  flex-shrink: 0;
}

.route-panel h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text);
}

.route-dest {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.route-from {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.route-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.route-stats .stat {
  background: var(--surface2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--accent);
}

.route-steps {
  margin-bottom: 10px;
}

.route-step {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: #ccc;
}

.route-step:last-child {
  border-bottom: none;
}

.step-num {
  background: var(--accent);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.route-step em {
  color: var(--muted);
  font-style: normal;
}

.map-wrapper {
  flex: 1;
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.locate-btn {
  position: absolute;
  bottom: 24px;
  right: 12px;
  z-index: 800;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.locate-btn:hover {
  border-color: var(--accent);
}

.sidebar-toggle {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 850;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
}

.custom-marker {
  background: none;
  border: none;
  font-size: 1.6rem;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.map-page .btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.map-page .btn:hover {
  border-color: #444;
}

.map-page .btn-primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.map-page .btn-primary:hover {
  background: var(--accent-h);
}

.map-page .btn-secondary {
  width: 100%;
}

.map-page .btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.leaflet-popup-tip {
  background: var(--surface);
}

.leaflet-popup-content {
  font-size: 14px;
  margin: 10px 14px;
}

.popup-content .btn {
  margin-top: 6px;
  margin-right: 4px;
}

.map-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.map-modal.hidden {
  display: none;
}

.map-modal .modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.map-modal .modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.map-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  z-index: 1;
}

.modal-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.map-modal .modal-content h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.modal-price {
  color: var(--accent);
  font-weight: bold;
  margin-bottom: 6px;
}

.modal-address {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.modal-description {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #ccc;
  margin-bottom: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-item a {
  color: var(--accent);
  text-decoration: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
}

.modal-route-info {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(39, 174, 96, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.route-loading {
  color: var(--muted);
}

.route-error {
  color: #e74c3c;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.leaflet-routing-container {
  display: none !important;
}

@media (max-width: 768px) {
  body.map-page {
    height: 100dvh;
  }

  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(340px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .map-modal .modal-content {
    padding: 1rem;
    max-height: 92dvh;
  }

  .modal-image {
    height: 140px;
  }
}

@media (max-width: 420px) {
  .map-page .site-header .cta .btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
  }
}
