/* =========================================================
   Site Plan Page Styles
   ---------------------------------------------------------
   This file was split out from index.html so the code is
   easier to read and edit. The CSS order is preserved from
   the previous version to keep the same display.
   ========================================================= */

:root {
  --bg:#f6f7fb;
  --card:#fff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --dark:#111827;
  --accent:#e2e8f0;
  --accentBorder:#334155;
  --accentSoft:#e2e8f0;
  --accentMuted:#0f172a;
  --brown:#92400e;
  --brownBg:#ebd7b2
}

* {
  box-sizing:border-box
}

html,body {
  margin:0;
  max-width:100%;
  overflow-x:hidden
}

body {
  font-family:Inter,system-ui,-apple-system,"Segoe UI",Arial,sans-serif;
  background:var(--bg);
  color:var(--text)
}

.wrap {
  max-width:1280px;
  margin:0 auto;
  padding:22px
}

.hero {
  background:linear-gradient(135deg,#fff,#eef6ff);
  border:1px solid var(--line);
  border-radius:28px;
  padding:24px;
  box-shadow:0 8px 30px rgba(15,23,42,.06)
}

.brand {
  font-weight:900;
  color:#2563eb
}

h1 {
  font-size:30px;
  margin:4px 0 8px
}

.sub {
  color:var(--muted);
  line-height:1.55
}

.grid {
  display:grid;
  gap:16px
}

.metrics {
  grid-template-columns:repeat(4,1fr);
  margin:18px 0
}

.card {
  background:var(--card);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:0 6px 20px rgba(15,23,42,.05)
}

.metric {
  padding:18px
}

.metric small {
  color:var(--muted)
}

.metric b {
  display:block;
  margin-top:6px;
  font-size:22px
}

.selectedMetric {
  background:var(--accent);
  border-color:var(--accentBorder);
  color:#0f172a
}

.selectedMetric small {
  color:#0f172a
}

.selectedMetric b {
  color:#0f172a
}


.topMetrics {
  display:none;
}

.siteInfoDrawer {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 42px;
  top: auto;
  width: min(900px, calc(100vw - 48px));
  max-height: min(74vh, 620px);
  z-index: 80;
  padding: 20px;
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(28px) scale(.985);
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 24px;
  box-shadow:
    0 28px 80px rgba(15, 23, 42, .30),
    0 0 0 1px rgba(15, 23, 42, .06);
  transition:
    opacity .28s ease,
    visibility .28s ease,
    transform .32s cubic-bezier(.22, 1, .36, 1);
}

.siteInfoDrawer.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.pageModalOverlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, .58);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity .24s ease,
    visibility .24s ease;
}

.pageModalOverlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 700px) {
  .siteInfoDrawer {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: calc(100vw - 36px);
    max-width: 430px;
    max-height: 78vh;
    padding: 16px;
    border-radius: 22px;
    transform: translateX(-50%) translateY(calc(-50% + 24px)) scale(.985);
  }

  .siteInfoDrawer.open {
    transform: translateX(-50%) translateY(-50%) scale(1);
  }
}


.drawerHead {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px;
}

.drawerHead h2 {
  margin:0;
  font-size:20px;
}

.drawerSelectedLot {
  color:#0f172a;
  font-weight:900;
}

.drawerHead p {
  margin:4px 0 0;
  color:#64748b;
  font-weight:700;
}

.drawerClose {
  border:1px solid #cbd5e1;
  background:#f8fafc;
  color:#0f172a;
  width:38px;
  height:38px;
  border-radius:999px;
  font-size:24px;
  font-weight:900;
  cursor:pointer;
  line-height:1;
}

.drawerMetrics {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
  margin-bottom:12px;
}

.drawerExtra {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
}

.drawerMetric {
  background:#f8fafc;
  border:1px solid #e2e8f0;
  border-radius:18px;
  padding:14px;
}

.drawerMetric small {
  display:block;
  color:#64748b;
  font-weight:800;
}
.drawerActions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
}

.openBuyerCostBtn {
  width: 95%;
  margin: 0 auto;
  border: 0;
  border-radius: 16px;
  padding: 15px 18px;
  background: #1b2a4d;
  color: #ffffff;
  font-weight: 650;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 14px 18px -12px rgba(15, 23, 42, .45);
}

.openBuyerCostBtn:hover {
  background: #1e293b;
}


.drawerMetric b {
  display:block;
  margin-top:6px;
  color:#0f172a;
  font-size:16px;
}

.drawerMetric.descriptionMetric b {
  font-size:16px;
  line-height:1.25;
}


@keyframes drawerSlideUp {
  from {
    transform:translateY(14px);
    opacity:0;
  }
  to {
    transform:translateY(0);
    opacity:1;
  }
}

@media(max-width:900px) {
  .drawerMetrics {
    grid-template-columns:1fr 1fr;
  }

}

@media(max-width:600px) {
  .siteInfoDrawer {
    left:12px;
    right:12px;
    top:auto;
    bottom:14px;
    padding:14px;
  }

  .drawerMetrics {
    grid-template-columns:1fr;
  }

  .drawerMetric b {
    font-size:18px;
  }
}

.main {
  grid-template-columns:360px 1fr
}

.side {
  padding:16px
}

.search {
  width:100%;
  border:1px solid var(--line);
  border-radius:16px;
  padding:13px 14px;
  font-size:15px;
  outline:none
}

.filters {
  display:grid;
  grid-template-columns:1fr 1fr 1fr 1fr;
  gap:8px;
  margin-top:10px
}

.filterSelect {
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  padding:11px 12px;
  font-size:12px;
  font-weight:700;
  color:#334155;
  background:#fff;
  outline:none
}

.list {
  margin-top:14px;
  display:grid;
  gap:10px;
  max-height:680px;
  overflow:auto
}

.unit {
  width:100%;
  text-align:left;
  border:1px solid var(--line);
  background:#fff;
  border-radius:18px;
  padding:14px;
  cursor:pointer
}

.unit:hover {
  border-color:#0f172a;
  background:#f8fafc
}

.unit.active {
  border-color:var(--accentBorder);
  background:var(--accentSoft);
  color:#0f172a;
  box-shadow:0 10px 22px rgba(15,23,42,.14)
}

.rowtop {
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center
}


.unitTitle {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:baseline;
  min-width:0;
}

.unitPtd,
.unitSize {
  color:#2563eb !important;
}

.unitSize {
  font-weight:900;
  white-space:normal;
}

.badge {
  font-size:12px;
  border-radius:999px;
  padding:5px 9px;
  font-weight:900;
  background:#f1f5f9;
  color:#475569
}

.badge.intern {
  background:#cbd5e1;
  color:#0f172a;
  border:1px solid #334155
}

.badge.bumi {
  background:#ebd7b2;
  color:#0f172a;
  border:1px solid #92400e
}

.unit.bumi-lot {
  border-color:#ebd7b2;
  background:#f8f1e6
}

.unit.bumi-lot.active {
  border-color:#92400e;
  background:#ebd7b2;
  box-shadow:0 10px 22px rgba(146,64,14,.18)
}

.workspace {
  display:grid;
  gap:16px
}

.sitePlanBox {
  padding:18px;
  position:relative;
  overflow:hidden
}

.sitePlanHead {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px
}

.sitePlanHead h2 {
  margin:0;
  font-size:24px
}

.selectedPlanPill {
  background:var(--accent);
  color:#0f172a;
  border:1px solid var(--accentBorder);
  border-radius:999px;
  padding:9px 13px;
  font-weight:900;
  box-shadow:0 8px 18px rgba(15,23,42,.12)
}

.planScroll {
  overflow:hidden
}

.planFrame {
  border:1px solid var(--line);
  border-radius:20px;
  overflow:hidden;
  background:white;
  width:100%;
  height:680px;
  min-width:0;
  position:relative;
  touch-action:none;
  cursor:grab;
  user-select:none
}

.planFrame.dragging {
  cursor:grabbing
}

.planContent {
  position:absolute;
  left:0;
  top:0;
  width:5400px;
  height:3375px;
  transform-origin:0 0;
  will-change:transform
}

.planContent object {
  width:5400px;
  height:3375px;
  display:block;
  border:0;
  pointer-events:none;
  user-select:none;
  -webkit-user-drag:none
}

.unitOverlay {
  position:absolute;
  left:0;
  top:0;
  width:5400px;
  height:3375px;
  overflow:visible;
  z-index:5;
  pointer-events:none
}

.unitHotspot {
  fill:transparent;
  stroke:transparent;
  cursor:pointer;
  pointer-events:all;
  touch-action:none;
  transform-box:fill-box;
  transform-origin:center;
}

.unitHotspot:hover {
  fill:#334155;
  fill-opacity:.18;
  stroke:#1e293b;
  stroke-width:6;
  vector-effect:non-scaling-stroke;
  transform:rotate(0deg);
}

.unitHotspot.selected {
  fill:#334155;
  fill-opacity:.30;
  stroke:#0f172a;
  stroke-width:8;
  vector-effect:non-scaling-stroke;
  transform:rotate(0deg);
}

.sitePlanLegend {
  display:flex;
  align-items:center;
  gap:28px;
  margin:14px 0 4px;
  padding:14px 18px;
  border-top:1px solid var(--line);
  background:#fff
}

.legendItem {
  display:flex;
  align-items:center;
  gap:12px;
  font-size:18px;
  font-weight:900;
  color:#0f172a
}

.legendBox {
  width:56px;
  height:34px;
  border:3px solid #111827;
  border-radius:6px;
  display:inline-block
}

.legendBox.international {
  background:#fff
}

.legendBox.bumi {
  background:#ebd7b2;
  border-color:#92400e
}

.mapHint {
  color:#64748b;
  font-size:13px;
  line-height:1.5;
  margin-top:8px
}

.detailCostGrid {
  display:grid;
  grid-template-columns:1fr;
  gap:16px;
  align-items:start
}

.content {
  padding:20px
}

.sectionTitle {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px
}

.sectionTitle h2 {
  margin:0;
  font-size:21px
}

.info {
  display:grid;
  grid-template-columns:1fr;
  gap:12px
}

.panel {
  background:#f8fafc;
  border-radius:18px;
  padding:14px;
  min-width:0
}

.line {
  display:flex;
  justify-content:space-between;
  gap:16px;
  border-bottom:1px solid #e8edf4;
  padding:11px 0
}

.line:last-child {
  border-bottom:0
}

.line span:first-child {
  color:var(--muted)
}

.line span:last-child {
  text-align:right;
  font-weight:800;
  overflow-wrap:anywhere
}

.tabs {
  display:flex;
  background:#eef2f7;
  border-radius:16px;
  padding:5px;
  gap:5px
}

.tab {
  border:0;
  border-radius:12px;
  padding:11px 14px;
  cursor:pointer;
  font-weight:800;
  background:transparent
}

.tab.active {
  background:var(--dark);
  color:#fff
}

.calcTitle {
  align-items:flex-start
}

.calcLeft {
  display:flex;
  flex-direction:column;
  gap:12px
}

.calcRight {
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:14px
}

.loanBox {
  background:#fff;
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  gap:8px;
  justify-content:flex-end
}

.loanBox label {
  font-size:13px;
  color:var(--muted);
  font-weight:900
}

.loanBox input {
  width:82px;
  border:1px solid var(--line);
  border-radius:12px;
  padding:9px 10px;
  font-size:15px;
  font-weight:900;
  text-align:right;
  outline:none
}

.total {
  background:#0f172a;
  color:#fff;
  border-radius:18px;
  padding:16px
}

.total small {
  color:#cbd5e1
}

.total b {
  font-size:26px
}

.btn {
  border:0;
  background:#075e54;
  color:#fff;
  border-radius:14px;
  padding:11px 14px;
  font-weight:900;
  cursor:pointer
}


.calcActionButtons {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.actionBtn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
}

.floorPlanBtn {
  background: #0f172a;
  color: #ffffff;
}

.whatsappActionBtn {
  background: #075e54;
  color: #ffffff;
}

.note {
  margin-top:16px;
  padding:14px;
  border:1px dashed #cbd5e1;
  border-radius:18px;
  background:#fff;
  color:#475569;
  line-height:1.5
}

.mobilePlanTools {
  display:none;
  color:#64748b;
  font-size:13px;
  margin:8px 0
}

.placeholder {
  color:#94a3b8
}

@media(max-width:900px) {
  .wrap {
    padding:12px
  }

  .hero {
    padding:18px;
    border-radius:22px
  }

  h1 {
    font-size:24px
  }

  .metrics {
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin:12px 0
  }

  .metric {
    padding:14px
  }

  .metric b {
    font-size:18px
  }

  .main,.detailCostGrid {
    grid-template-columns:1fr
  }

  .list {
    max-height:360px
  }

  .sitePlanBox {
    padding:14px 12px;
    overflow:hidden
  }

  .sitePlanHead {
    flex-wrap:wrap
  }

  .sitePlanHead h2 {
    font-size:22px
  }

  .mobilePlanTools {
    display:none
  }

  .planScroll {
    width:100%;
    overflow:hidden
  }

  .planFrame {
    min-width:0;
    height:539px
  }

  .planFrame object {
    width:5400px;
    height:3375px
  }

  .content {
    padding:15px
  }

  .sectionTitle {
    flex-direction:column;
    align-items:stretch
  }

  .calcTitle,.calcRight {
    flex-direction:column;
    align-items:stretch
  }

  .calcRight {
    margin-left:0
  }

  .tabs {
    display:grid;
    grid-template-columns:repeat(3,1fr)
  }

  .tab {
    font-size:12px;
    padding:10px 6px
  }

  .loanBox {
    justify-content:space-between
  }

  .total b {
    font-size:22px
  }

  .line span:first-child {
    flex:0 0 43%;
    font-size:14px
  }

  .line span:last-child {
    flex:1;
    font-size:14px
  }
}

@media(max-width:600px) {
  .planFrame {
    min-width:0;
    height:614px
  }

  .planFrame object {
    width:5400px;
    height:3375px
  }

  .selectedPlanPill {
    font-size:13px;
    padding:8px 10px
  }

  .sitePlanLegend {
    gap:14px;
    padding:12px 10px;
    flex-wrap:wrap
  }

  .legendItem {
    font-size:15px
  }

  .legendBox {
    width:42px;
    height:26px;
    border-width:2px
  }
}
  

/* V76 mobile layout: show site plan first, filters/list second.
   Keep only around 3 units visible in the mobile list, then scroll. */
@media(max-width:600px) {
  .main {
    display: flex;
    flex-direction: column;
  }

  .workspace {
    order: 1;
  }

  .side {
    order: 2;
  }

  .side .list {
    max-height: 430px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}



/* V77 mobile popup fix: keep the info popup centered with left/right gap.
   This override comes last because older mobile rules set left/right/bottom and caused clipping. */
@media (max-width: 700px) {
  .siteInfoDrawer {
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    width: calc(100vw - 32px) !important;
    max-width: 430px !important;
    max-height: 80vh !important;
    padding: 14px !important;
    border-radius: 22px !important;
    transform: translateX(-50%) translateY(calc(-50% + 24px)) scale(.985) !important;
  }

  .siteInfoDrawer.open {
    transform: translateX(-50%) translateY(-50%) scale(1) !important;
  }

  .drawerMetric small {
    font-size: 12px !important;
    line-height: 1.15 !important;
  }

  .drawerMetrics {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .drawerExtra {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .drawerMetric {
    min-height: 86px !important;
    padding: 12px !important;
  }

  .drawerMetric b {
    font-size: 12px !important;
    line-height: 1.18 !important;
  }

  .drawerAction {
    width: 100% !important;
  }
}

@media (max-width: 390px) {
  .drawerMetrics,
  .drawerExtra {
    grid-template-columns: 1fr !important;
  }
}


/* V78 mobile: keep the popup title/PTD + category in one single row. */
@media (max-width: 700px) {
  .drawerHead {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }

  .drawerHead > div {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .drawerHead h2 {
    display: block !important;
    max-width: 100% !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: clamp(18px, 5.4vw, 16px) !important;
    line-height: 1.15 !important;
    letter-spacing: .01em !important;
  }

  .drawerSelectedLot {
    display: inline !important;
    white-space: nowrap !important;
  }

  .drawerClose {
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
  }
}

.drawerTopActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.drawerFloorPlanIconBtn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 0;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawerFloorPlanIconBtn svg {
  width: 25px;
  height: 25px;
  display: block;
}

.drawerFloorPlanIconBtn:hover {
  background: #f1f5f9;
}

@media(max-width:700px) {
  .drawerTopActions {
    gap: 8px;
  }

  .drawerFloorPlanIconBtn,
  .drawerClose {
    width: 48px;
    height: 48px;
  }
}

/* v199: iPad only - show site plan first, filters/list second */
@media (min-width: 768px) and (max-width: 1024px) {
  .main {
    display: flex !important;
    flex-direction: column !important;
  }

  .workspace {
    order: 1 !important;
  }

  .side {
    order: 2 !important;
  }

  .side .list {
    max-height: 430px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* V285 mobile iPhone 12 Pro: keep unit popup detail cards in 2 columns.
   Index page only. Other pages/functions unchanged. */
@media (max-width: 430px) {
  .siteInfoDrawer .drawerMetrics,
  .siteInfoDrawer .drawerExtra {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .siteInfoDrawer .drawerMetric {
    min-height: 84px !important;
    padding: 11px !important;
  }

  .siteInfoDrawer .drawerMetric small {
    font-size: 12px !important;
    line-height: 1.15 !important;
  }

  .siteInfoDrawer .drawerMetric b {
    font-size: 12px !important;
    line-height: 1.18 !important;
    overflow-wrap: anywhere !important;
  }
}


/* V294 mobile: keep PTD and size text the same blue colour on unit cards. */
@media (max-width: 700px) {
  .unit .unitPtd,
  .unit .unitSize {
    color:#2563eb !important;
  }
}


/* V295: force PTD + size in unit card title to use the same blue on all devices. */
.unitPtdWithSize,
.unit .unitTitle .unitPtdWithSize {
  color: #2563eb !important;
}

@media (max-width: 700px) {
  .unitPtdWithSize,
  .unit .unitTitle .unitPtdWithSize {
    color: #2563eb !important;
  }
}


/* =========================================================
   V297 Auth Bar / Supabase Guard
   ========================================================= */
.auth-checking body { visibility: hidden; }
.appAuthBar {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 22px;
  background: rgba(15, 23, 42, .94);
  color: #f8fafc;
  border-bottom: 1px solid rgba(255, 255, 255, .10);
  backdrop-filter: blur(14px);
}
.appAuthBrand {
  font-weight: 900;
  letter-spacing: -.02em;
}
.appAuthActions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.appAuthActions span {
  color: #cbd5e1;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appAuthActions a,
.appAuthActions button {
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #f8fafc;
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  font: inherit;
}
.appAuthActions button:hover,
.appAuthActions a:hover {
  background: rgba(255,255,255,.14);
}
@media (max-width: 640px) {
  .appAuthBar { padding: 9px 12px; }
  .appAuthBrand { font-size: 14px; }
  .appAuthActions { gap: 6px; }
  .appAuthActions span { display:none; }
  .appAuthActions a,
  .appAuthActions button { padding: 7px 9px; font-size: 12px; }
}

/* =========================================================
   V298 mobile only: align drawer top action icons to the far right.
   Keeps the popup layout and all other functions unchanged.
   ========================================================= */
@media (max-width: 700px) {
  .siteInfoDrawer .drawerHead {
    position: relative !important;
    padding-right: 112px !important;
  }

  .siteInfoDrawer .drawerHead > div:first-child {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .siteInfoDrawer .drawerTopActions {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    margin-left: 0 !important;
    justify-content: flex-end !important;
    transform: translateX(2px) !important;
  }
}
