@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1f2937);
  --hint: var(--tg-theme-hint-color, #9ca3af);
  --link: var(--tg-theme-link-color, #2563eb);
  --button: var(--tg-theme-button-color, #2563eb);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --accent: #f59e0b;
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }
html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); }

#app { display: flex; flex-direction: column; height: 100vh; }

/* Header */
#header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 44px;
  background: var(--bg); border-bottom: 1px solid rgba(0,0,0,0.08);
  z-index: 10;
}
#header .logo { font-size: 20px; }
#header .title { font-size: 15px; font-weight: 600; color: var(--text); }
#header .spacer { flex: 1; }
.header-btn {
  background: var(--secondary-bg); border: none; border-radius: 8px;
  width: 36px; height: 36px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Search */
#search-bar {
  position: absolute; top: 52px; left: 12px; right: 12px; z-index: 10;
}
#search-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius); font: 400 14px var(--font);
  color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#search-input::placeholder { color: var(--hint); }
#search-results {
  display: none; background: var(--bg); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); margin-top: 4px;
  max-height: 200px; overflow-y: auto;
}
#search-results.open { display: block; }
.search-item {
  padding: 10px 14px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.search-item:hover { background: var(--secondary-bg); }
.search-item:last-child { border-bottom: none; }

/* Map */
#map { flex: 1; }

/* Bottom sheet */
#bottom-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg); border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1); z-index: 20;
  max-height: 60vh; overflow-y: auto;
  transition: transform 0.3s ease;
}
#bottom-sheet.hidden { transform: translateY(100%); }
.sheet-handle {
  width: 36px; height: 4px; background: rgba(0,0,0,0.2);
  border-radius: 2px; margin: 8px auto;
}
#sheet-content { padding: 4px 16px 20px; }

.route-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid rgba(0,0,0,0.06); cursor: pointer;
}
.route-item:last-child { border-bottom: none; }
.route-item .name { font-size: 15px; font-weight: 500; }
.route-item .meta { font-size: 12px; color: var(--hint); }

/* Modal */
#modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.15s ease;
}
#modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#modal-card {
  background: var(--bg); border-radius: 16px;
  max-width: 360px; width: 100%; max-height: 80vh; overflow-y: auto;
  position: relative; padding: 24px 20px;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.close-btn {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; font-size: 24px;
  color: var(--hint); cursor: pointer; line-height: 1;
}

.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--hint); }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 12px;
  background: var(--secondary-bg); border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px; font: 400 14px var(--font); color: var(--text);
}
.form-group textarea { min-height: 60px; resize: vertical; }

.btn {
  display: block; width: 100%; padding: 12px;
  background: var(--button); color: var(--button-text);
  border: none; border-radius: 10px; font: 500 15px var(--font);
  cursor: pointer; text-align: center;
}
.btn:active { opacity: 0.85; }
.btn-secondary {
  background: var(--secondary-bg); color: var(--text);
}
.btn + .btn { margin-top: 8px; }

/* Marker popup */
.marker-popup {
  background: var(--bg); border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); min-width: 180px;
}
.marker-popup .popup-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.marker-popup .popup-addr { font-size: 12px; color: var(--hint); }
