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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5fa;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ---------- Header ---------- */

header {
  background: #4f46e5;
  color: white;
  padding: 1.25rem 5%;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header p {
  margin-top: 0.25rem;
  opacity: 0.82;
  font-size: 0.95rem;
}

/* ---------- Main layout ---------- */

main {
  width: 90%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

/* ---------- Search row ---------- */

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.input-group {
  flex: 1;
  min-width: 0;
  position: relative;
}

.input-group label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  background: white;
  transition: border-color 0.15s;
  min-width: 0;
}

.input-row input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.locate-btn {
  padding: 0.7rem 0.75rem;
  border: 1.5px solid #ddd;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.locate-btn:hover {
  background: #f0f0ff;
  border-color: #4f46e5;
}

/* Autocomplete dropdown */

.autocomplete-list {
  list-style: none;
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  background: white;
  border: 1.5px solid #4f46e5;
  border-top: none;
  border-radius: 0 0 8px 8px;
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.autocomplete-list:empty {
  display: none;
}

.autocomplete-list li {
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #333;
  border-top: 1px solid #f0f0f4;
  line-height: 1.4;
}

.autocomplete-list li:first-child {
  border-top: none;
}

.autocomplete-list li:hover {
  background: #f0f0ff;
  color: #4f46e5;
}

/* ---------- Action buttons ---------- */

.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.action-buttons button {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#search-btn {
  background: #4f46e5;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  border: none;
}

#search-btn:hover:not(:disabled) {
  background: #4338ca;
}

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

#share-btn {
  background: white;
  color: #4f46e5;
  border: 1.5px solid #c7d2fe;
}

#share-btn:hover {
  background: #f0f0ff;
}

.material-icons {
  font-size: 20px;
  user-select: none;
}

/* ---------- Map ---------- */

.map-section {
  margin-bottom: 1.5rem;
}

#map {
  width: 100%;
  height: 440px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* ---------- Custom map markers ---------- */

.marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: default;
}

.marker-a {
  background: #2563eb;
}

.marker-b {
  background: #dc2626;
}

.marker-restaurant {
  width: 18px;
  height: 18px;
  background: #f59e0b;
  cursor: pointer;
  transition: transform 0.1s;
}

.marker-restaurant.active {
  background: #d97706;
  transform: scale(1.35);
  z-index: 10;
}

/* ---------- Results ---------- */

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#results-header {
  flex-shrink: 0;
}

.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-btn {
  padding: 0.3rem 0.75rem;
  border: 1.5px solid #ddd;
  border-radius: 999px;
  background: white;
  color: #555;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: #a5b4fc;
  color: #4f46e5;
}

.filter-btn.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: white;
}

.filter-divider {
  width: 1px;
  height: 18px;
  background: #ddd;
  margin: 0 0.15rem;
  flex-shrink: 0;
}

#results-header {
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 1rem;
}

#results-list {
  display: grid;
  gap: 0.75rem;
}

.restaurant-card {
  background: white;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  border: 1.5px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.restaurant-card:hover {
  box-shadow: 0 3px 12px rgba(79, 70, 229, 0.12);
  border-color: #c7d2fe;
}

.restaurant-card.highlighted {
  border-color: #4f46e5;
  box-shadow: 0 3px 12px rgba(79, 70, 229, 0.18);
}

.card-main {
  min-width: 0;
  flex: 1;
}

.card-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.83rem;
  color: #666;
}

.card-cuisine {
  text-transform: capitalize;
}

.card-price {
  color: #16a34a;
  font-weight: 600;
}

.card-rating {
  color: #b45309;
}

.card-open {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.card-open.open {
  background: #dcfce7;
  color: #16a34a;
}

.card-open.closed {
  background: #fee2e2;
  color: #dc2626;
}

.card-distances {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #888;
}

.card-link {
  flex-shrink: 0;
  font-size: 0.83rem;
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
  padding: 0.45rem 0.8rem;
  border: 1.5px solid #c7d2fe;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s;
}

.card-link:hover {
  background: #f0f0ff;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  header {
    padding: 1rem 5%;
  }

  main {
    width: 95%;
  }

  .search-row {
    flex-wrap: wrap;
  }

  .input-group {
    flex: 1 1 100%;
  }

  .action-buttons {
    margin-left: auto;
  }

  #map {
    height: 300px;
    border-radius: 8px;
  }

  .restaurant-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .card-link {
    align-self: flex-end;
  }
}
