/* Bathroom planner styles. Everything is scoped to .bp-app so the planner can be
   embedded in any page (e.g. a WordPress theme) without leaking styles either way.
   .bp-compact is toggled by JS when the planner itself is narrow (phone layout). */

.bp-app {
  --bg: #1d2127;
  --panel: #f7f7f5;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e2e2de;
  --accent: #2f6fdb;
  --panel-w: 340px;
  --bp-height: 85vh;          /* overridden by the shortcode / standalone page */
  --bp-compact-view: 55vh;    /* height of the 3D view in the phone layout */

  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  text-align: left;
}

/* ---- Light reset against theme styles -------------------------------------------- */
.bp-app, .bp-app *, .bp-app *::before, .bp-app *::after { box-sizing: border-box; }
.bp-app h1, .bp-app h2, .bp-app h3 {
  font-family: inherit; color: inherit; line-height: 1.25; text-transform: none; letter-spacing: normal; font-weight: 700;
}
.bp-app button, .bp-app select, .bp-app input {
  font-family: inherit; text-transform: none; letter-spacing: normal; box-shadow: none; min-height: 0; line-height: normal;
}
.bp-app input[type="checkbox"] { appearance: auto; width: auto; height: auto; margin: 0; padding: 0; }
.bp-app input[type="range"] { appearance: auto; width: auto; height: auto; margin: 0; padding: 0; border: 0; background: none; }
.bp-app ul { margin: 0; padding: 0; }
.bp-app p { margin: 0; }
.bp-app #viewport canvas {
  display: block; max-width: none !important; width: 100% !important; height: 100% !important;
}

/* ---- Layout ------------------------------------------------------------------------ */
.bp-app .bp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  height: var(--bp-height);
  background: var(--bg);
  overflow: hidden;
}
.bp-app.bp-embedded .bp-layout { border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .18); }
.bp-app.bp-fullwidth { width: 100vw; max-width: 100vw; margin-left: calc(50% - 50vw); }
.bp-app.bp-fullwidth .bp-layout { border-radius: 0; }

.bp-app #viewport { position: relative; min-width: 0; height: 100%; overflow: hidden; }
.bp-app #panel {
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 20px;
}

.bp-app.bp-compact .bp-layout { grid-template-columns: 1fr; grid-template-rows: var(--bp-compact-view) auto; height: auto; }
.bp-app.bp-compact #viewport { height: var(--bp-compact-view); }
.bp-app.bp-compact #panel { height: auto; overflow: visible; border-left: none; }

.bp-app h1 { font-size: 18px; margin: 0 0 16px; }
.bp-app h2 { font-size: 14px; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---- Options --------------------------------------------------------------------------- */
.bp-app .controls { display: grid; gap: 14px; }
.bp-app .controls label { display: grid; gap: 6px; font-size: 13px; margin: 0; }
.bp-app .controls label.check { display: flex; align-items: center; gap: 8px; }
.bp-app .controls select {
  width: 100%; height: auto; padding: 6px; font-size: 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

/* ---- 3D view overlays ------------------------------------------------------------------ */
.bp-app #viewport::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(5, 7, 10, .45) 100%);
}
.bp-app .total-badge {
  position: absolute; right: 16px; top: 16px; z-index: 2;
  display: grid; gap: 2px; text-align: right;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(20, 24, 31, .62); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.bp-app .total-badge span { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: #aeb6c2; }
.bp-app .total-badge strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.bp-app.bp-compact .total-badge { padding: 8px 12px; }
.bp-app.bp-compact .total-badge strong { font-size: 16px; }

.bp-app .viewport-hint {
  position: absolute; left: 16px; bottom: 16px; z-index: 2;
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  background: rgba(20, 23, 28, .7); color: #e8eaed; pointer-events: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

/* ---- Pipe details card (desktop: floating card; phone: bottom sheet) ------------------- */
.bp-app .pipe-card {
  position: absolute; left: 16px; top: 16px; z-index: 3;
  width: min(340px, calc(100% - 32px)); max-height: calc(100% - 80px); overflow: auto;
  padding: 14px 16px; border-radius: 10px;
  background: rgba(255, 255, 255, .92); color: var(--text);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  animation: bp-card-in .25s ease-out;
}
.bp-app .pipe-card[hidden] { display: none; }
.bp-app .pipe-card h3 { margin: 0 24px 6px 0; font-size: 15px; }
.bp-app .pipe-card .meta { margin: 6px 0; font-size: 12px; color: var(--muted); }
.bp-app .pipe-card .meta strong { color: var(--text); }
.bp-app .pipe-card .close {
  position: absolute; top: 8px; right: 10px; border: 0; background: none; padding: 0;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted);
}
.bp-app .pipe-card .home {
  margin-top: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text); font-size: 12px; cursor: pointer;
}
.bp-app .pipe-card .home:hover { border-color: var(--accent); color: var(--accent); }
.bp-app .pipe-card .grip { display: none; }

.bp-app.bp-compact .pipe-card {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 100000;
  width: 100%; max-height: 45vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
  background: #fff; box-shadow: 0 -10px 30px rgba(0, 0, 0, .25);
  animation: bp-sheet-in .28s ease-out;
}
.bp-app.bp-compact .pipe-card .grip { display: block; width: 40px; height: 4px; margin: 2px auto 10px; border-radius: 4px; background: #d5d7dc; }
.bp-app.bp-compact .pipe-card .close { top: 10px; }

@keyframes bp-card-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes bp-sheet-in { from { transform: translateY(100%); } to { transform: none; } }

/* Small price table inside the pipe card */
.bp-app table.costs { width: 100%; border-collapse: collapse; font-size: 12px; margin: 0; border: 0; }
.bp-app table.costs th, .bp-app table.costs td {
  padding: 5px 4px; border: 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; background: none;
}
.bp-app table.costs td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bp-app table.costs tfoot td { border-bottom: none; }
.bp-app table.costs tfoot tr.total td { font-weight: 700; font-size: 14px; border-top: 2px solid var(--text); }

/* ---- Fixtures list -------------------------------------------------------------------- */
.bp-app .hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.bp-app .room-size { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.bp-app .room-size label { display: grid; gap: 6px; font-size: 13px; margin: 0; }
.bp-app .room-size input {
  width: 100%; min-width: 0; height: auto; padding: 7px 8px; font-size: 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; background: #fff; box-sizing: border-box;
}
.bp-app .room-size input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 111, 219, .15); }
.bp-app .room-size input.invalid { border-color: #d64545; box-shadow: 0 0 0 3px rgba(214, 69, 69, .12); }
.bp-app .room-area {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.bp-app .room-area strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.bp-app .fixtures { display: grid; gap: 10px; }
.bp-app .fixture {
  display: grid; gap: 4px; font-size: 13px; padding: 8px 10px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; transition: box-shadow .2s, border-color .2s, opacity .2s;
}
.bp-app .fixture:hover { border-color: #c9d6ee; box-shadow: 0 2px 10px rgba(47, 111, 219, .08); }
.bp-app .fixture.off { opacity: .55; }
.bp-app .fixture.off .row { display: none; }
.bp-app .fixture label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.bp-app .fixture .row { display: flex; align-items: center; gap: 10px; }
.bp-app .fixture input[type="range"] { flex: 1; accent-color: var(--accent); }
.bp-app .fixture output { font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.bp-app .fixture .note { font-size: 12px; color: var(--muted); }
.bp-app .warnings { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.bp-app .warnings li { font-size: 12px; padding: 6px 8px; border-radius: 6px; background: #fff4e5; color: #8a4b00; border: 1px solid #f3d3a6; }
.bp-app .warnings:empty { display: none; }

/* ---- Cost estimate (also used by the print window) -------------------------------------- */
.bp-app .estimate {
  --c-drain: #7b8794;
  --c-supply: #13a3a0;
  --c-labour: #e3892b;
  --c-parts: #7c5cd6;
  display: grid; gap: 10px; font-size: 13px;
}
.bp-app .cat-drain { --c: var(--c-drain); }
.bp-app .cat-supply { --c: var(--c-supply); }
.bp-app .cat-labour { --c: var(--c-labour); }
.bp-app .cat-parts { --c: var(--c-parts); }
.bp-app .estimate .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.bp-app .estimate .amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.bp-app .print-head { display: none; }

.bp-app .est-summary {
  display: grid; gap: 12px; padding: 14px;
  border-radius: 12px; color: #fff;
  background: linear-gradient(145deg, #1f2a3d, #2b3a55);
  box-shadow: 0 6px 18px rgba(31, 42, 61, .25);
}
.bp-app .est-total { display: grid; gap: 2px; }
.bp-app .est-total span { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #a9b5c8; }
.bp-app .est-total strong { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bp-app .est-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .12); gap: 2px; }
.bp-app .est-bar .seg { background: var(--c); min-width: 3px; }
.bp-app .est-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.bp-app .est-legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 0; }
.bp-app .est-legend .lbl { flex: 1; color: #dbe2ec; }
.bp-app .est-legend .pct { color: #a9b5c8; font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }
.bp-app .est-legend .amt { min-width: 92px; text-align: right; }
.bp-app .est-sub { margin: 0; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .14); display: grid; gap: 4px; font-size: 12px; }
.bp-app .est-sub div { display: flex; justify-content: space-between; }
.bp-app .est-sub dt { color: #a9b5c8; font-weight: 400; }
.bp-app .est-sub dd { margin: 0; font-variant-numeric: tabular-nums; }

.bp-app .est-cat { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0; }
.bp-app .est-cat summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  cursor: pointer; list-style: none; user-select: none;
  border-left: 3px solid var(--c);
}
.bp-app .est-cat summary::-webkit-details-marker { display: none; }
.bp-app .est-cat summary::after {
  content: ""; width: 7px; height: 7px; margin-left: 2px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s;
}
.bp-app .est-cat[open] summary::after { transform: rotate(45deg); }
.bp-app .est-cat summary:hover { background: #f8f9fb; }
.bp-app .est-cat summary .lbl { font-weight: 600; white-space: nowrap; }
.bp-app .est-cat summary .count { flex: 1; font-size: 11px; color: var(--muted); white-space: nowrap; }
.bp-app .est-lines { list-style: none; margin: 0; padding: 0 12px 4px; }
.bp-app .est-lines li {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 1px;
  padding: 8px 0; margin: 0; border-top: 1px solid #f0f0ec;
}
.bp-app .est-lines .name { line-height: 1.3; }
.bp-app .est-lines .amt { font-weight: 500; }
.bp-app .est-lines .meta { grid-column: 1 / -1; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bp-app .est-grand {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 14px; border-radius: 10px; background: #eef3fc; border: 1px solid #d6e2f7;
}
.bp-app .est-grand span { font-weight: 600; }
.bp-app .est-grand strong { font-size: 17px; font-variant-numeric: tabular-nums; color: #1d4fa8; }
.bp-app .est-note { margin: 0; font-size: 11px; color: var(--muted); }
.bp-app .est-print {
  justify-self: start; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: #fff; color: var(--accent); font-size: 14px; font-weight: 600;
}
.bp-app .est-print:hover { background: var(--accent); color: #fff; }

/* ---- Print window (opened by "Printo / ruaj si PDF") ------------------------------------ */
body.bp-print { margin: 24px; background: #fff; }
.bp-print .bp-app .print-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 14px; }
.bp-print .bp-app .est-print { display: none; }
.bp-print .bp-app .est-cat summary::after { display: none; }
.bp-print .bp-app .estimate { max-width: 720px; }
@media print {
  body.bp-print { margin: 0; }
  .bp-print .bp-app .est-summary, .bp-print .bp-app .est-cat, .bp-print .bp-app .est-grand { break-inside: avoid; box-shadow: none; }
  .bp-print .bp-app * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
