*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: #1a1a1a;
  background: #f5f5f5;
}

.hidden {
  display: none !important;
}

/* ===== HEADER ===== */

#header {
  padding: 16px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
}

#header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.9rem;
  color: #666;
}

/* ===== SEARCH BAR ===== */

#search-bar {
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
}

#search-form {
  display: flex;
  gap: 8px;
  max-width: 600px;
}

#input-wrapper {
  flex: 1;
  position: relative;
}

#address-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

#address-input:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

#search-btn {
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #4a90d9;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

#search-btn:hover {
  background: #357abd;
}

#search-btn:disabled {
  background: #a0c4e8;
  cursor: not-allowed;
}

/* ===== AUTOCOMPLETE DROPDOWN ===== */

#autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 500;
  max-height: 260px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 10px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: #eef4fb;
}

.autocomplete-item-main {
  font-weight: 500;
  color: #1a1a1a;
}

.autocomplete-item-context {
  font-size: 0.8rem;
  color: #888;
  margin-top: 2px;
}

#status-message {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #c0392b;
}

#status-message.info {
  color: #666;
}

/* ===== MAIN CONTENT (MAP + PANEL) ===== */

#content {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - 130px);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

#results-panel {
  overflow-y: auto;
  padding: 16px;
  background: #ffffff;
  border-left: 1px solid #e0e0e0;
}

#results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

#results-title {
  font-size: 1.1rem;
  font-weight: 600;
}

#results-count {
  font-size: 0.85rem;
  color: #888;
}

/* ===== RESULTS LIST ===== */

#results-list {
  list-style: none;
}

.result-item {
  padding: 12px;
  margin-bottom: 8px;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.result-item:hover {
  background: #eef4fb;
  border-color: #4a90d9;
}

.result-item.active {
  background: #ddeaf7;
  border-color: #4a90d9;
}

.result-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.result-address {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 4px;
}

.result-distance {
  font-size: 0.8rem;
  color: #4a90d9;
  font-weight: 500;
}

.result-select-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: #4a90d9;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s;
}

.result-select-btn:hover {
  background: #357abd;
}

.result-item-far {
  opacity: 0.6;
}

.result-item-far:hover {
  opacity: 1;
}

#no-results p {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 0.95rem;
}

/* ===== LOADING OVERLAY ===== */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE: MOBILE ===== */

@media (max-width: 768px) {
  #content {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh auto;
    height: auto;
  }

  #results-panel {
    border-left: none;
    border-top: 1px solid #e0e0e0;
    max-height: 50vh;
  }
}
