/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1117;
  color: #e0e0e0;
}

/* ===== Auth Page ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a2332 100%);
}

.auth-card {
  background: #1e2530;
  border: 1px solid #2e3a4a;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.auth-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #4ade80;
  margin-bottom: 6px;
}

.tagline {
  color: #7a8a9a;
  font-size: 0.875rem;
  margin-bottom: 28px;
}

.auth-card input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #0f1117;
  border: 1px solid #2e3a4a;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.auth-card input:focus { border-color: #4ade80; }

.auth-card button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: #4ade80;
  color: #0f1117;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.auth-card button[type="submit"]:hover { background: #22c55e; }
.auth-card button[type="submit"]:disabled { background: #2e3a4a; color: #555; cursor: not-allowed; }

.toggle-text { margin-top: 16px; font-size: 0.875rem; color: #7a8a9a; text-align: center; }
.toggle-text a { color: #4ade80; text-decoration: none; }

.error-msg {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #f87171;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

/* ===== Map Page ===== */
.map-page { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #1e2530;
  border-bottom: 1px solid #2e3a4a;
  z-index: 1000;
  flex-shrink: 0;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: #4ade80;
  white-space: nowrap;
}

.search-wrap {
  display: flex;
  flex: 1;
  gap: 8px;
  max-width: 480px;
}

.search-wrap input {
  flex: 1;
  padding: 8px 12px;
  background: #0f1117;
  border: 1px solid #2e3a4a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.9rem;
  outline: none;
}
.search-wrap input:focus { border-color: #4ade80; }

.search-wrap button, #logout-btn {
  padding: 8px 16px;
  background: #4ade80;
  color: #0f1117;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.search-wrap button:hover { background: #22c55e; }

.rate-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: #7a8a9a;
  white-space: nowrap;
}
.rate-wrap label { color: #7a8a9a; }
.rate-prefix, .rate-suffix { color: #a0a0a0; }
.rate-wrap input {
  width: 62px;
  padding: 6px 8px;
  background: #0f1117;
  border: 1px solid #2e3a4a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
  outline: none;
  text-align: center;
}
.rate-wrap input:focus { border-color: #4ade80; }

#logout-btn { background: #2e3a4a; color: #e0e0e0; margin-left: auto; }
#logout-btn:hover { background: #3e4a5a; }

#map { flex: 1; z-index: 1; }

/* ===== Side Panel ===== */
#side-panel {
  position: fixed;
  top: 60px;
  right: 0;
  width: 320px;
  height: calc(100vh - 60px);
  background: #1e2530;
  border-left: 1px solid #2e3a4a;
  overflow-y: auto;
  padding: 20px;
  z-index: 900;
  transition: transform 0.25s ease;
}
#side-panel.hidden { display: none; }

#close-panel {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #7a8a9a;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
#close-panel:hover { color: #e0e0e0; }

#side-panel h2 { font-size: 1.2rem; margin-bottom: 16px; padding-right: 24px; }
#side-panel h3 { font-size: 0.85rem; color: #7a8a9a; text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 0 10px; }

/* ESI Gauge */
.esi-gauge { margin-bottom: 14px; }
.esi-gauge label { font-size: 0.8rem; color: #7a8a9a; }
.gauge-bar { height: 10px; background: #2e3a4a; border-radius: 5px; margin: 6px 0; overflow: hidden; }
#gauge-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.esi-value { font-size: 1.5rem; font-weight: 700; }

/* Price */
.price-block { margin-bottom: 14px; }
.price-block label { font-size: 0.8rem; color: #7a8a9a; display: block; }
.price-value { font-size: 1.3rem; font-weight: 600; color: #facc15; }

/* Component bars */
.component-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.comp-bar { height: 8px; background: #2e3a4a; border-radius: 4px; overflow: hidden; }
.comp-bar div { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.component-row span:last-child { text-align: right; font-size: 0.78rem; color: #7a8a9a; }

/* Explanation */
.explanation-block p { font-size: 0.875rem; line-height: 1.6; color: #c0c0c0; }
.loading-text { color: #7a8a9a; font-style: italic; }

/* Simulation panel */
#simulation-panel { font-size: 0.875rem; line-height: 1.7; }
#simulation-panel p { margin-bottom: 4px; }
#simulation-panel span { font-weight: 600; color: #4ade80; }
.ai-note { color: #7a8a9a; font-style: italic; margin-top: 8px; }

/* ===== Weights Panel ===== */
#weights-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: #1e2530dd;
  border: 1px solid #2e3a4a;
  border-radius: 10px;
  padding: 14px 18px;
  z-index: 900;
  max-width: 280px;
  backdrop-filter: blur(6px);
}
#weights-panel.hidden { display: none; }
#weights-panel h3 { font-size: 0.8rem; color: #7a8a9a; text-transform: uppercase; margin-bottom: 6px; }
.reasoning-text { font-size: 0.78rem; color: #a0a0a0; margin-bottom: 10px; line-height: 1.5; }
.weight-row { display: grid; grid-template-columns: 100px 1fr 35px; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 0.8rem; }
.weight-bar-wrap { height: 6px; background: #2e3a4a; border-radius: 3px; overflow: hidden; }
.weight-bar { height: 100%; background: #4ade80; border-radius: 3px; }
.weight-row span:last-child { text-align: right; color: #7a8a9a; }

/* ===== Loading Overlay ===== */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#loading.hidden { display: none; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #2e3a4a;
  border-top-color: #4ade80;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes neighborhood-pulse {
  0%   { opacity: 0.5; }
  50%  { opacity: 1.0; }
  100% { opacity: 0.5; }
}
.neighborhood-selected {
  animation: neighborhood-pulse 1.4s ease-in-out infinite;
}

.hidden { display: none !important; }
