/* ---- Dark UI tokens (aligned with your dashboard) ---- */
:root{
  --bg: #0f172a;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --green:#22c55e;
  --yellow:#f59e0b;
  --red:#ef4444;
  --gap: 16px;
  --pad: 18px;
  --col-min: 279px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(99,102,241,.15), transparent 40%),
    radial-gradient(1200px 700px at 90% 110%, rgba(20,184,166,.15), transparent 40%),
    linear-gradient(180deg, #0b1020, #0b1223 60%, #0a1224);
  padding: var(--pad);
}

/* Layout */
.app{
  max-width:1200px;
  margin:18px auto;
  display:grid;
  gap:var(--gap);
  grid-template-columns: 360px 1fr;
}

/* Cards */
.card{
  background: linear-gradient(180deg, rgba(17,24,39,.9), rgba(17,24,39,.7));
  border:1px solid rgba(255,255,255,.06);
  border-radius:18px;
  padding:18px;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
  transition:transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover{ transform:translateY(-2px); box-shadow:0 14px 40px rgba(0,0,0,.35); border-color:rgba(255,255,255,.12); }

h1{margin:0 0 8px 0; font-weight:800; font-size:22px; letter-spacing:.3px}

/* Controls */
.label, label{display:block; font-size:12px; color:var(--muted); margin:10px 0 6px}
.row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  align-items:start;         /* ensure both cells align at top */
}
button {
    margin: 10px 0 6px;
}
.row > div{ display:flex; flex-direction:column; }

/* Inputs */
select, input[type="number"]{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:#fff;
  outline:none;
}
select:focus, input[type="number"]:focus{ border-color:rgba(255,255,255,.3); }
option {
    color: #000;
}

/* Buttons */
.btn{
  appearance:none;
  border:1px solid rgba(255,255,255,.12);
  background:linear-gradient(180deg, #1f2937, #111827);
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  font-weight:600;
  cursor:pointer;
  transition:transform .15s ease, border-color .2s ease;
}
.btn:hover{ transform:translateY(-1px); border-color:rgba(255,255,255,.3) }
.btn.secondary{ background:linear-gradient(180deg, #0f172a, #0b1223); }

/* Helper text + totals */
.muted{ color:var(--muted); }
.price{ font-size:24px; font-weight:800; margin-top:8px }
.totals{ display:grid; grid-template-columns: 1fr 1fr; gap:8px; margin-top:8px }
.totals div{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
  padding:10px;
  font-size:13px;
}

/* Preview area */
.preview{
  position:relative;
  aspect-ratio:16/9;
  background:linear-gradient(180deg, rgba(148,163,184,.12), rgba(148,163,184,.06));
  display:flex; align-items:center; justify-content:center;
  overflow:hidden; border-radius:14px; border:1px solid rgba(255,255,255,.06);
}

.preview .yard,
.preview .fence {
  z-index: 1;
}

.yard{
  position:absolute; inset:0;
  background-image: linear-gradient(180deg,#0f172a 0%, #0f172a 55%, #0c2a19 55%, #0c2a19 100%);
}
.fence{ position:absolute; bottom:12%; left:5%; right:5%; height:14%; display:flex; align-items:flex-end; gap:1.2% }
.pier{ width:2.2%; background:#6b665f; border:2px solid #4a443e; border-bottom:none; position:relative; border-radius:2px }
.cap{ position:absolute; top:-10px; left:-4px; right:-4px; height:10px; background:#3a3a3a; border-radius:2px }
.infill{ height:45%; background:#7b736a; border:2px solid #4a443e; opacity:.95; border-radius:2px }
.metal{
  height:35%; border:2px solid #333;
  background:repeating-linear-gradient(90deg, transparent 0 6px, rgba(255,255,255,.18) 6px 9px);
  border-radius:2px;
}

#aiResult {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  display: none;
  border-radius: 1rem;
}


/* Small viewports */
@media (max-width: 960px){
  .app{ grid-template-columns: 1fr; }
}

/* Preview photo */
.preview img#photoPreview{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  user-select:none;
  -webkit-user-drag:none;
  pointer-events:none;
  border-radius:14px;
  z-index: 2;
}
.preview.has-photo img#photoPreview{ display:block; }
.preview.has-photo .yard,
.preview.has-photo .fence{ display:none; }

/* File upload */
.file-upload{ display:flex; flex-direction:column; }

/* Hide native input; use styled label as the button */
.file-upload input[type="file"]{ display:none; }

/* Shared button style for Choose/Remove */
.file-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-height:46px;
  text-align:center;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background:linear-gradient(180deg,#1f2937,#111827);
  color:#fff;
  font-weight:600;
  cursor:pointer;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.06),
              0 2px 6px rgba(0,0,0,.35);
  transition:transform .15s ease, border-color .2s ease;
}
.file-btn:hover{ transform:translateY(-1px); border-color:rgba(255,255,255,.3) }

/* Filename wraps; never forces the grid to overflow */
.file-name{
  display:block;
  margin-top:6px;
  font-size:12px;
  color:var(--muted);
  max-width:100%;
  overflow-wrap:anywhere;
  word-break:break-word;
  line-height:1.35;
}

/* ---------------- Loading overlay ---------------- */
.loading-overlay{
  position:fixed;
  inset:0;
  z-index:99999;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

.loading-overlay.show{
  display:flex;
}

.loading-card{
  width:min(420px, 92vw);
  background: linear-gradient(180deg, rgba(17,24,39,.96), rgba(17,24,39,.88));
  border:1px solid rgba(255,255,255,.10);
  border-radius:18px;
  padding:18px;
  box-shadow:0 18px 60px rgba(0,0,0,.55);
  text-align:center;
}

.spinner{
  width:44px;
  height:44px;
  margin:4px auto 12px auto;
  border-radius:50%;
  border:4px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.85);
  animation:spin 1s linear infinite;
}

@keyframes spin{
  to{ transform: rotate(360deg); }
}
