/* ── PV Calc — Light Relond style ─────────────────────────────────────────── */

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

:root {
  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --surface2:  #f0f0f2;
  --surface3:  #e8e8ea;
  --border:    #d8d8da;
  --accent:    #FF6B00;
  --accent2:   #F97316;
  --text:      #1d1d1f;
  --sub:       #6e6e73;
  --muted:     #aeaeb2;
  --danger:    #d93025;
  --radius:    16px;
  --radius-sm: 8px;
  --shadow:    0 2px 20px rgba(0,0,0,0.08);
  --font:      -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

/* ── Steps ───────────────────────────────────────────────────────────────── */
.step { display: none; min-height: 100vh; }
.step.active { display: flex; flex-direction: column; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-bar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 12px;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(12px);
  z-index: 100; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.progress-label {
  font-size: 13px; color: var(--sub);
  display: flex; align-items: center; gap: 8px;
}
.progress-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); transition: all 0.3s;
}
.progress-dot.done    { background: var(--accent2); }
.progress-dot.active  { background: var(--accent); transform: scale(1.4); }
.progress-step-names {
  display: flex; gap: 32px; margin: 0 16px;
}
.progress-step-name {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.progress-step-name.active { color: var(--accent); }
.progress-step-name.done   { color: var(--accent2); }

/* ── STEP 1 — Hero / Address ─────────────────────────────────────────────── */
#step-1 {
  background: radial-gradient(ellipse at 50% -20%, rgba(255,107,0,0.07) 0%, transparent 65%), var(--bg);
  align-items: center; justify-content: center;
  padding: 80px 24px 40px;
}

.hero-content {
  max-width: 600px; width: 100%; text-align: center;
}

.logo {
  font-size: 14px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 40px;
  display: inline-flex; align-items: center; gap: 8px;
}
.logo-icon { font-size: 20px; }

.hero-content h1 {
  font-size: clamp(36px, 6vw, 62px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  color: var(--text);
}
.accent { color: var(--accent); }

.hero-subtitle {
  font-size: 17px; color: var(--sub); line-height: 1.6;
  margin-bottom: 40px;
}

/* Search */
.search-container { position: relative; margin-bottom: 24px; }

.search-box {
  display: flex; align-items: center;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 50px; padding: 0 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,107,0,0.12), 0 2px 12px rgba(0,0,0,0.06);
}

.search-icon { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }

#address-input {
  flex: 1; padding: 18px 12px;
  background: transparent; border: none; outline: none;
  font-size: 16px; color: var(--text); font-family: var(--font);
}
#address-input::placeholder { color: var(--muted); }

#search-clear {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 4px 8px;
  line-height: 1; transition: color 0.2s;
}
#search-clear:hover { color: var(--text); }

/* Suggestions dropdown */
.suggestions {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12); z-index: 50;
  display: none;
}
.suggestions.open { display: block; }

.suggestion-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  transition: background 0.15s; outline: none;
}
.suggestion-item:hover, .suggestion-item:focus { background: var(--surface2); }
.suggestion-icon { font-size: 16px; margin-top: 2px; flex-shrink: 0; color: var(--accent); }
.suggestion-main { font-size: 14px; color: var(--text); }
.suggestion-sub  { font-size: 12px; color: var(--sub); margin-top: 2px; }
.suggestion-loading, .suggestion-empty {
  padding: 16px; font-size: 14px; color: var(--sub); text-align: center;
}

/* Data sources badges */
.trusted {
  display: flex; align-items: center; flex-wrap: wrap;
  justify-content: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.badge {
  padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 11px; color: var(--sub);
  background: var(--surface);
}

/* ── STEP 2 — Config layout ───────────────────────────────────────────────── */
#step-2 { padding-top: 48px; flex-direction: row; height: 100vh; overflow: hidden; }

.config-layout { display: flex; flex: 1; overflow: hidden; }

/* Map panel */
.map-panel { flex: 1; position: relative; min-width: 0; }

#map { width: 100%; height: 100%; }

.map-address-badge {
  position: absolute; bottom: 16px; left: 16px; right: 16px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; color: var(--text); z-index: 10;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* Config panel */
.config-panel {
  width: 380px; flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: -2px 0 12px rgba(0,0,0,0.04);
}

.config-header { display: flex; align-items: center; gap: 12px; }
.config-header h2 { font-size: 18px; font-weight: 600; color: var(--text); }

.back-btn {
  background: none; border: 1px solid var(--border);
  color: var(--sub); padding: 6px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; transition: all 0.2s;
  white-space: nowrap;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

.section-title {
  font-size: 13px; font-weight: 600; color: var(--sub);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* Roof face cards */
.roof-face-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}

.face-header {
  display: flex; align-items: center; justify-content: space-between;
}
.face-title { font-size: 13px; font-weight: 600; color: var(--text); }
.face-remove {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 2px 6px;
  border-radius: 4px; transition: all 0.2s;
}
.face-remove:hover { background: rgba(217,48,37,0.1); color: var(--danger); }

.face-fields { display: flex; flex-direction: column; gap: 10px; }

.face-field { display: flex; flex-direction: column; gap: 4px; }
.face-field label {
  font-size: 11px; color: var(--sub); text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hint { font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }

select, input[type="number"], input[type="text"] {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,107,0,0.1);
}

.tilt-control { display: flex; align-items: center; gap: 8px; }
input[type="range"] {
  flex: 1; accent-color: var(--accent);
  background: transparent; height: 4px;
  padding: 0; border: none;
}
.face-tilt-val { font-size: 13px; color: var(--accent); min-width: 28px; text-align: right; }

.face-preview {
  background: var(--surface3); border-radius: var(--radius-sm);
  padding: 8px 12px; display: flex; gap: 16px;
  font-size: 12px; color: var(--sub);
}
.face-preview span { display: flex; align-items: center; gap: 4px; }

/* Add face button */
.add-face-btn {
  background: none; border: 1.5px dashed var(--border);
  color: var(--sub); padding: 10px;
  border-radius: var(--radius); cursor: pointer;
  font-size: 13px; transition: all 0.2s; text-align: center;
}
.add-face-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(255,107,0,0.04); }

/* Settings section */
.settings-section { display: flex; flex-direction: column; gap: 10px; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.setting-row label { font-size: 13px; color: var(--sub); white-space: nowrap; }
.setting-row select, .setting-row input { max-width: 160px; }

.input-with-unit {
  display: flex; align-items: center; gap: 6px; max-width: 160px;
}
.input-with-unit input { flex: 1; }
.input-with-unit span { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Total preview */
.total-preview {
  font-size: 13px; color: var(--accent); text-align: center;
  padding: 8px; background: rgba(255,107,0,0.06);
  border-radius: var(--radius-sm); border: 1px solid rgba(255,107,0,0.18);
  font-weight: 600;
}

/* Calculate button */
.calculate-btn {
  margin-top: auto; padding: 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all 0.2s; letter-spacing: -0.01em;
  box-shadow: 0 4px 16px rgba(255,107,0,0.3);
}
.calculate-btn:hover  { background: #e05f00; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(255,107,0,0.38); }
.calculate-btn:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(255,107,0,0.2); }
.calculate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── STEP 3 — Results ────────────────────────────────────────────────────── */
#step-3 { padding: 80px 24px 60px; background: var(--bg); }

.results-container { max-width: 900px; margin: 0 auto; }

.results-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 32px; flex-wrap: wrap;
}
.results-header h1 { font-size: 28px; font-weight: 700; color: var(--text); }
.results-header .res-address-line {
  font-size: 14px; color: var(--sub); margin-top: 4px;
}

.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Big metric cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 16px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow);
}
.metric-card.highlight {
  background: linear-gradient(135deg, rgba(255,107,0,0.07), rgba(249,115,22,0.04));
  border-color: rgba(255,107,0,0.25);
}
.metric-label { font-size: 11px; color: var(--sub); text-transform: uppercase; letter-spacing: 0.06em; }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.metric-value.accent { color: var(--accent); }
.metric-sub   { font-size: 12px; color: var(--muted); }

/* Detail sections */
.details-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px;
}
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.detail-card h3 {
  font-size: 13px; font-weight: 600; color: var(--sub);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px;
}

/* Faces breakdown */
.res-face {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.res-face:last-child { border-bottom: none; }
.res-face-label { font-size: 13px; font-weight: 600; color: var(--text); }
.res-face-data  { font-size: 12px; color: var(--sub); }

/* Financial rows */
.fin-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.fin-row:last-child { border-bottom: none; }
.fin-row .fin-label { color: var(--sub); }
.fin-row .fin-val   { font-weight: 600; color: var(--text); }
.fin-row .fin-val.positive { color: var(--accent); }
.fin-row .fin-val.negative { color: var(--danger); }

/* Monthly chart */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.chart-card h3 {
  font-size: 13px; font-weight: 600; color: var(--sub);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px;
}
#monthly-chart { width: 100%; height: 180px; display: block; }

/* CTA */
.cta-card {
  background: linear-gradient(135deg, rgba(255,107,0,0.08), rgba(249,115,22,0.04));
  border: 1px solid rgba(255,107,0,0.22);
  border-radius: var(--radius); padding: 28px;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.cta-card h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.cta-card p  { font-size: 15px; color: var(--sub); max-width: 480px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  padding: 14px 28px; border-radius: 50px;
  font-size: 15px; font-weight: 700;
  text-decoration: none; border: none; cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(255,107,0,0.3);
}
.btn-primary:hover { background: #e05f00; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,107,0,0.38); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text);
  padding: 10px 20px; border-radius: 50px;
  font-size: 14px; font-weight: 500;
  text-decoration: none; border: 1px solid var(--border); cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: rgba(255,107,0,0.04); }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(245,245,247,0.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
#loading-overlay.hidden { display: none; }

.loading-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  font-size: 14px; color: var(--sub);
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}

.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Leaflet overrides ───────────────────────────────────────────────────── */
.leaflet-container { background: #e8e0d8; }
.leaflet-control-layers { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; box-shadow: 0 2px 12px rgba(0,0,0,0.1) !important; }
.leaflet-control-layers-list label { color: var(--sub) !important; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #step-2 { flex-direction: column; height: auto; overflow: auto; }
  .config-layout { flex-direction: column; }
  .map-panel { height: 300px; }
  .config-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); }

  .details-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .results-header { flex-direction: column; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .hero-content h1 { font-size: 32px; }
}

/* ── Custom panel fields ─────────────────────────────────────────────────── */
.custom-panel-fields {
  background: var(--surface2);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 4px;
}
.custom-panel-fields.hidden { display: none; }

/* ── LOD2 auto-detect banner ─────────────────────────────────────────────── */
.lod2-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: #c2410c;
  margin-bottom: 10px;
  font-weight: 500;
}
