/* SIA Solar Design Studio
   Standalone stylesheet; reuses the site's design tokens (see css/style.css)
   so the studio matches the rest of SIA in both themes. */

:root {
  --gold: #caa200;
  --gold-strong: #b08e00;
  --ink: #222222;
  --ink-soft: #555555;
  --bg: #f4f4f4;
  --surface: #ffffff;
  --border: #e2e2e2;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --good: #2e7d32;
  --bad: #c62828;
}

body.dark-mode {
  --ink: #f4f4f4;
  --ink-soft: #cfcfcf;
  --bg: #2c2c2c;
  --surface: #3a3a3a;
  --border: #4a4a4a;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --good: #81c784;
  --bad: #e57373;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Exo 2', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); }
.brand .logo { height: 34px; }
.brand-name { font-size: 1.1rem; font-weight: 500; }
.brand-sia { color: var(--gold); font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.back-link { color: var(--ink-soft); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--gold); }

.toggle-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  color: var(--ink);
  cursor: pointer;
}
.toggle-theme:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.step:disabled { opacity: 0.45; cursor: default; }
.step.active { background: var(--gold); color: #fff; }
.step.done:not(.active) { color: var(--gold-strong); }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.8rem;
}

#studio-main { flex: 1; display: flex; flex-direction: column; }
.step-panel { flex: 1; display: flex; flex-direction: column; }

/* ---------- Step 1: address ---------- */
#panel-1 { align-items: center; justify-content: center; padding: var(--space-4) var(--space-2); }

.address-card {
  max-width: 640px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  text-align: center;
}
.address-card h1 { margin: 0 0 var(--space-1); font-weight: 500; font-size: 1.6rem; }
.address-card .subtitle { color: var(--ink-soft); margin: 0 0 var(--space-3); }

.address-row { display: flex; gap: var(--space-1); }
.address-row input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
}
.address-row input:focus { outline: 2px solid var(--gold); border-color: transparent; }

#address-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  margin-top: var(--space-3);
  color: var(--ink-soft);
}

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

.error-box {
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--bad);
  border-radius: var(--radius);
  color: var(--bad);
  font-size: 0.9rem;
}

.fine-print { margin-top: var(--space-3); font-size: 0.78rem; color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.primary-btn {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.7rem 1.2rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
}
.primary-btn:hover { background: var(--gold-strong); }
.primary-btn:disabled { opacity: 0.5; cursor: default; }

#model-btn {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}
#model-btn:hover { background: var(--gold-strong); }
#model-btn:disabled { opacity: 0.5; }

/* ---------- Step 2: design layout ---------- */
.design-layout {
  flex: 1;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  min-height: 0;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #14161a;
}

#design-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#design-canvas.dragging { cursor: grabbing; }

#canvas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(20, 22, 26, 0.92);
  color: #fff;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
  max-width: 230px;
  z-index: 5;
}

.canvas-controls {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 4;
}
.canvas-controls button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.canvas-controls button:hover { color: var(--gold); border-color: var(--gold); }

.flux-legend {
  position: absolute;
  left: var(--space-1);
  bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(20, 22, 26, 0.8);
  color: #eee;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  z-index: 4;
}
.legend-gradient {
  width: 90px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #000004, #57106e, #bc3754, #f98c0a, #fcffa4);
}

/* ---------- Sidebar ---------- */
.design-sidebar {
  width: 330px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-2);
}
.card h3 { margin: 0 0 var(--space-1); font-size: 0.95rem; font-weight: 600; }
.card h3 i { color: var(--gold); margin-right: 0.35rem; }
.card h4 { margin: var(--space-2) 0 var(--space-1); font-size: 0.85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); margin-bottom: var(--space-2); }
.stat { background: var(--bg); border-radius: 8px; padding: 0.5rem 0.6rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.15rem; font-weight: 600; color: var(--gold-strong); }
body.dark-mode .stat-value { color: var(--gold); }
.stat-label { font-size: 0.68rem; color: var(--ink-soft); line-height: 1.25; }

.slider-label { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 2px; }
input[type="range"] { width: 100%; accent-color: var(--gold); }
.indent { margin-left: 1.55rem; width: calc(100% - 1.55rem); }
label.indent { display: block; }

.hint { font-size: 0.75rem; color: var(--ink-soft); margin: 0.4rem 0 0; }

.check-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; padding: 0.25rem 0; cursor: pointer; }
.check-row input { accent-color: var(--gold); }

.segment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: default;
}
.segment-row:hover { background: var(--bg); }
.segment-row .seg-name { font-weight: 600; }
.segment-row .seg-meta { color: var(--ink-soft); font-size: 0.75rem; }
.seg-access { font-weight: 600; }

/* ---------- Step 3: financials ---------- */
.financial-layout {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.fin-inputs { width: 320px; flex-shrink: 0; }
.fin-inputs label { display: block; font-size: 0.83rem; margin: 0.55rem 0; color: var(--ink-soft); }
.fin-inputs input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
}
.fin-inputs input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.fin-inputs details summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-soft); margin: var(--space-2) 0 var(--space-1); }
.fin-inputs .primary-btn { margin-top: var(--space-2); }

.fin-tabs { display: flex; gap: 6px; margin: var(--space-1) 0; }
.fin-tab {
  flex: 1;
  padding: 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink-soft);
  font-family: inherit;
  cursor: pointer;
}
.fin-tab.active { background: var(--gold); border-color: var(--gold); color: #fff; }

.fin-results { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }

.fin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-1); }
.fin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-2);
}
.fin-card .value { font-size: 1.25rem; font-weight: 600; }
.fin-card .value.positive { color: var(--good); }
.fin-card .value.negative { color: var(--bad); }
.fin-card .label { font-size: 0.72rem; color: var(--ink-soft); }

.chart-card canvas { width: 100%; }

/* ---------- Step 4: proposal ---------- */
#panel-4 { align-items: center; padding: var(--space-2); }
.proposal-toolbar { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); width: 100%; max-width: 820px; }
.proposal-toolbar .primary-btn { width: auto; }

.proposal-doc {
  width: 100%;
  max-width: 820px;
  background: #ffffff;
  color: #222222;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.proposal-doc h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }
.proposal-doc h2 { font-size: 1.05rem; font-weight: 600; margin: var(--space-3) 0 var(--space-1); border-bottom: 2px solid #caa200; padding-bottom: 4px; }
.proposal-head { display: flex; justify-content: space-between; align-items: flex-start; }
.proposal-head img.logo { height: 44px; }
.proposal-meta { color: #555; font-size: 0.85rem; margin-top: 4px; }
.proposal-doc img.snapshot { width: 100%; border-radius: 8px; margin-top: var(--space-1); }
.proposal-doc table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.proposal-doc td, .proposal-doc th { padding: 0.4rem 0.5rem; border-bottom: 1px solid #e6e6e6; text-align: left; }
.proposal-doc td:last-child { text-align: right; font-weight: 500; }
.proposal-highlights { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-1); }
.proposal-highlights .fin-card { background: #faf7ec; border-color: #e8dfc0; }
.proposal-highlights .fin-card .label { color: #777; }
.proposal-disclaimer { font-size: 0.72rem; color: #777; margin-top: var(--space-3); }

/* ---------- Footer ---------- */
.studio-footer { text-align: center; padding: var(--space-1); color: var(--ink-soft); font-size: 0.75rem; }

/* ---------- Print (PDF export) ---------- */
@media print {
  .no-print, .studio-header, .stepper, .studio-footer { display: none !important; }
  body { background: #fff; }
  #panel-4 { padding: 0; }
  .proposal-doc { box-shadow: none; border-radius: 0; max-width: none; padding: 0.5in; }
  .proposal-doc h2 { break-after: avoid; }
  .proposal-doc table, .proposal-doc img, .proposal-highlights { break-inside: avoid; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .design-layout { flex-direction: column; }
  .canvas-wrap { min-height: 340px; }
  .design-sidebar { width: 100%; }
  .financial-layout { flex-direction: column; }
  .fin-inputs { width: 100%; }
  .step-label { display: none; }
  .brand-name { font-size: 0.95rem; }
}
