/* ========================================
   INOVAR - LOTEAMENTOS STYLESHEET
   ======================================== */

:root {
  --page-bg: #FFFFFF;
  --surface: #F9F9F9;
  --surface-alt: #FFFFFF;
  
  --border-soft: #E6E6E6;
  --border-mid: #CCCCCC;
  --border-dark: #333333;
  
  --text-primary: #0D0D0D;
  --text-secondary: #666666;
  --text-muted: #999999;
  
  --brand-red: #D42B2B;
  --brand-red-dark: #A82020;
  --brand-red-light: #E94545;
  --brand-red-glow: rgba(212, 43, 43, 0.35);
  
  --status-avail: #1E7E34;
  --status-avail-bg: #EBF7ED;
  --status-amber: #E1A032;
  --status-amber-bg: #FFF9EF;

  --radius: 16px;
  --radius-sm: 8px;

  --transition-fast: 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Page Spacing Below Absolute Header */
.loteamentos-hero-section {
  padding-top: 100px;
  padding-bottom: 24px;
  background: var(--page-bg);
  border-bottom: 1px solid var(--border-soft);
}

.loteamentos-header-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

.loteamento-meta-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

.loteamento-title-box h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.loteamento-title-box p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.loteamento-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- 1-Line Controls Bar --- */
.loteamento-controls-bar {
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  scrollbar-width: none;
}

.loteamento-controls-bar::-webkit-scrollbar {
  display: none;
}

.controls-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  white-space: nowrap;
}

/* Site's existing component styling: .segmented & .seg-btn */
.segmented {
  display: inline-flex;
  align-items: center;
  background: var(--page-bg);
  border: 1px solid var(--border-soft);
  border-radius: 50px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  height: 36px;
  padding: 0 16px;
  background: transparent;
  border: none;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  background: var(--brand-red);
  color: #FFFFFF;
  box-shadow: 0 2px 8px var(--brand-red-glow);
}

/* Filter Switch Toggle */
.filter-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.switch-track {
  width: 44px;
  height: 24px;
  background: var(--border-mid);
  border-radius: 50px;
  position: relative;
  transition: background var(--transition-fast);
}

.switch-thumb {
  width: 18px;
  height: 18px;
  background: #FFFFFF;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.filter-switch.active .switch-track {
  background: var(--brand-red);
}

.filter-switch.active .switch-thumb {
  transform: translateX(20px);
}

.avail-counter {
  font-size: 12px;
  color: var(--brand-red);
  font-weight: 700;
  margin-left: 2px;
}

/* --- Map Viewport & Prancha Grid Surface --- */
.loteamento-main-section {
  position: relative;
  padding: 24px 20px;
  background: var(--page-bg);
}

.main-layout-container {
  max-width: 1240px;
  margin: 0 auto;
}

/* A moldura precisa ter PROPORÇÃO, não altura fixa: o motor enquadra a
   planta dentro dela, e a planta é uma faixa de 292x124 (2,35:1). Com
   min-height:58dvh o quadro ficava 358x490 num celular — proporção 0,73
   para um desenho 2,35 — e o desenho encolhia para caber, boiando num
   vazio enorme. O --map-ar é escrito pelo JS: 2,35 na visão geral, 1,7
   quando um conjunto de lotes está em foco. */
.map-prancha-surface {
  position: relative;
  width: 100%;
  aspect-ratio: var(--map-ar, 2.35);
  min-height: 150px;
  max-height: 46dvh;
  transition: aspect-ratio var(--transition-smooth);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02), 0 2px 10px -4px rgba(30,25,15,0.16);
  overflow: hidden;
  /* INVARIANTE: pan-y — arrasto vertical rola a PÁGINA. Sem isso o dedo
     fica preso no mapa. A trava de direção fina está no JS. */
  touch-action: pan-y;
  user-select: none;
}

.prancha-grid-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(to right, var(--border-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-soft) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 1;
}

#svgPlant {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  cursor: grab;
}
#svgPlant.dragging { cursor: grabbing; }

/* Ruas e sombra dos disponíveis */
.road { fill: #E5E3DD; }
.road-curb { fill: none; stroke: #FFFFFF; stroke-width: 0.8; opacity: 0.75; }
.road-line { stroke: #FFFFFF; stroke-width: 0.7; stroke-dasharray: 4.5 4; fill: none; opacity: 0.85; }
.shadow-poly { fill: rgba(30, 25, 15, 0.07); }
.compass-n {
  font-family: var(--font-body); font-weight: 700; font-size: 9px;
  letter-spacing: 0.1em; fill: #A9A79F; text-anchor: middle;
}

/* Map Bar Below Map */
.map-bar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 0 4px;
}

.status-legend-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.dot-color.disponivel { background: var(--status-avail); }
.dot-color.consultar { background: #FFFFFF; border: 1px solid var(--border-dark); }
.dot-color.reservado { background: var(--status-amber); }
.dot-color.vendido { background: var(--border-mid); }

.zoom-btn-cluster {
  display: inline-flex;
  gap: 6px;
}

.btn-zoom {
  width: 44px;
  height: 44px;
  background: #FFFFFF;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all var(--transition-fast);
}

.btn-zoom:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
}

/* --- SVG Lot Elements & Light Theme Status Styling --- */
.lot-group {
  cursor: pointer;
  transition: opacity 0.3s ease;
}

/* As larguras de traço são em unidades do desenho (metros), não px: o
   viewBox escala tudo. Valores de 1,5 deixavam a borda com 1,5m de
   espessura e engoliam o lote no zoom de longe. */
.lot-visual.disponivel { fill: #D8EED0; stroke: #4A8A3E; stroke-width: 0.75; }
.lot-visual.consultar  { fill: #FDFDFC; stroke: #B0ADA5; stroke-width: 0.55; }
.lot-visual.reservado  { fill: url(#hatchPattern); stroke: #C0912F; stroke-width: 0.7; stroke-dasharray: 3 2.2; }
.lot-visual.vendido    { fill: #E6E5E1; stroke: #CFCDC8; stroke-width: 0.5; }

/* Vermelho institucional é EXCLUSIVO de interação — nunca indica status. */
.lot-group:hover .lot-visual,
.lot-group.hovered .lot-visual,
.lot-group.selected .lot-visual {
  fill: #FFF6F6;
  stroke: var(--brand-red);
  stroke-width: 1.6;
  stroke-dasharray: none;
}
.lot-group.selected .lot-visual {
  filter: drop-shadow(0 1.5px 4px var(--brand-red-glow));
}

.lot-hit-target {
  fill: transparent;
  stroke: transparent;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
}

/* ⚠️ Os tamanhos abaixo estão pareados com as constantes do
   loteamentos.js (NUM_SIZE 13 · AREA_SIZE 10 · AREA_Y 16) e com os
   'extent' de cada rótulo fixo. Mudar aqui sem mudar lá quebra o teste
   de encaixe: rótulo passa a aparecer espremido ou some sem motivo. */
.lot-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  fill: var(--text-primary);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.lot-area {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 10px;
  fill: var(--text-muted);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.lot-visual.disponivel + .lot-label .lot-num { fill: #1F4A1A; }
.lot-visual.disponivel + .lot-label .lot-area { fill: #4C8A42; }
.lot-group.selected .lot-num { fill: var(--brand-red); }
.lot-num, .lot-area { transition: opacity 0.2s ease; }

.road-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 9.5px;
  fill: #8E8C85;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.green-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 8.5px;
  fill: #5F7A55;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.lot-group.dimmed {
  opacity: 0.15;
  pointer-events: none;
}

/* --- Detail Drawer & Side Panel --- */
.detail-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 48vh;
  max-height: 48dvh;
  background: var(--surface-alt);
  border-top: 1px solid var(--border-soft);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
  z-index: 900;
  transform: translateY(100%);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.detail-drawer.open {
  transform: translateY(0);
}

.drawer-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--border-mid);
  border-radius: 2px;
  margin: 10px auto 2px;
}

.drawer-content {
  padding: 16px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.lot-nav-arrows {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-nav-arrow {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-nav-arrow:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
}

.drawer-title-box h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.drawer-close-btn {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.drawer-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.spec-box {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.spec-box .label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.spec-box .value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.price-tag .label {
  font-size: 11px;
  color: var(--text-secondary);
}

.price-tag .amount {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.btn-whatsapp-lote {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: #25D366;
  color: #FFFFFF;
  border-radius: 50px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.25);
  transition: transform var(--transition-fast);
}

.btn-whatsapp-lote:hover {
  transform: translateY(-2px);
}

.btn-house-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--brand-red);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.btn-house-link:hover {
  text-decoration: underline;
}

/* Desktop 2-Column Layout (>1024px) */
@media (min-width: 1024px) {
  .main-layout-container {
    display: grid;
    grid-template-columns: 65% 35%;
    gap: 24px;
    align-items: start;
  }

  /* Sticky top: 16px calibrated for absolute header */
  .map-column {
    position: sticky;
    top: 16px;
  }

  .detail-drawer {
    position: relative;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: none;
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    transform: none !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  }

  .drawer-drag-handle {
    display: none;
  }

  .table-section {
    grid-column: 1 / -1;
  }
}

/* --- Available Lots Table Section ---
   Sem padding horizontal próprio: .table-section é filha de
   .loteamento-main-section, que já aplica 20px de cada lado. O padding
   duplicado deixava só 308px úteis para a tabela num celular de 390px. */
.table-section {
  padding: 32px 0 8px;
  background: var(--page-bg);
  border-top: 1px solid var(--border-soft);
  margin-top: 24px;
}

.table-container-box {
  max-width: 1240px;
  margin: 0 auto;
}

.table-container-box h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.table-container-box p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.responsive-table {
  width: 100%;
  overflow: hidden;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.lots-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.lots-table th {
  background: var(--surface);
  color: var(--text-secondary);
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
}

.lots-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
}

.lots-table tbody tr:last-child td { border-bottom: 0; }
.lots-table tbody tr { transition: background 0.15s ease; }
.lots-table tbody tr:hover,
.lots-table tbody tr.active { background: var(--surface); }
/* .active é aplicado pelo JS quando o lote é selecionado no mapa: sem esta
   regra, clicar num lote não destacava a linha correspondente. */
.lots-table tbody tr.active td:first-child { box-shadow: inset 3px 0 0 var(--brand-red); }

.btn-select-lot {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 8px;
}

.btn-select-lot:hover { color: var(--brand-red); }

/* --- Celular: a tabela vira cartão ---------------------------------
   As quatro colunas pedem 364px de largura natural; sobram 348px num
   celular de 390px e 318px num Android de 360px. Espremer quebra o texto
   e rolar na horizontal corta o preço no meio — foi o que aconteceu.
   Empilhado em cartão, o valor sempre aparece inteiro e não há rolagem
   lateral nenhuma. Acima de 640px volta a ser tabela. */
@media (max-width: 639px) {
  .responsive-table { border: 0; border-radius: 0; overflow: visible; }
  .lots-table { display: block; }
  .lots-table thead {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .lots-table tbody { display: block; }

  .lots-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 2px 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--page-bg);
  }
  .lots-table tbody tr.active {
    border-color: var(--brand-red);
    background: var(--page-bg);
  }
  .lots-table tbody tr.active td:first-child { box-shadow: none; }

  .lots-table tbody td { padding: 0; border: 0; }

  /* Colunas: 1 Lote · 2 Área · 3 Frente×fundo · 4 Valor.
     Lote e Valor dividem a primeira linha do cartão. */
  .lots-table tbody td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .lots-table tbody td:nth-child(4) {
    grid-column: 2; grid-row: 1; justify-self: end;
    font-family: var(--font-display);
    font-size: 17px; font-weight: 700; color: var(--text-primary);
  }
  .lots-table tbody td:nth-child(1) .btn-select-lot { font-size: 17px; margin: 0; padding: 0; min-height: 0; }

  /* Área e medidas viram linhas rótulo/valor */
  .lots-table tbody td:nth-child(2),
  .lots-table tbody td:nth-child(3) {
    grid-column: 1 / -1;
    display: flex; justify-content: space-between; gap: 12px;
    padding-top: 5px;
    font-size: 12.5px;
  }
  .lots-table tbody td:nth-child(2) { margin-top: 6px; }
  .lots-table tbody td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
}

.btn-select-lot:focus-visible {
  outline: 2px solid var(--brand-red);
}

.table-status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
}

.table-status-badge.disponivel { background: var(--status-avail-bg); color: var(--status-avail); }
.table-status-badge.consultar { background: #F0F0F0; color: var(--text-primary); }
.table-status-badge.reservado { background: var(--status-amber-bg); color: var(--status-amber); }
.table-status-badge.vendido { background: var(--border-soft); color: var(--text-muted); }

.availability-note-box {
  margin-top: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.registral-info-line {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Movimento reduzido.
   NÃO usar "animation: none" universal: o .header do site nasce com
   opacity 0 e só aparece por animação (headerFadeIn). Matar a animação
   deixaria o cabeçalho invisível para sempre para quem tem essa
   preferência ligada. Encurtar a duração resolve sem esconder nada. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
