:root{
  --bg:#0b0f17;
  --panel:#5c4f98;
  --panel2:#0f1622;
  --text:#e7eefc;
  --muted:#a9b4c7;
  --muted_light_bgrnd:#e60808;
  --accent:#5b61d6;
  --border: rgba(255,255,255,0.10);
}

.hidden { display: none !important; }
  
*{ box-sizing:border-box; }

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

.app{
  height:100vh;
  width:100vw;
  display:flex;
}

.sidebar{
  width:550px;
  min-width:450px;
  max-width:600px;
  border-right:1px solid var(--border);
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  overflow:auto;
}

.sidebar-inner{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.title{
  font-weight:800;
  letter-spacing:0.2px;
  margin-bottom:6px;
}

.hint{
  color:var(--muted);
  font-size:13px;
  margin-bottom:10px;
}

.tiny{
  color:var(--muted);
  font-size:12px;
  margin-top:8px;
}

.search-block{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  background:rgba(255,255,255,0.03);
}

.search-holder{
  border:1px solid rgba(91,97,214,0.6);
  border-radius:10px;
  padding:10px;
  background:rgba(0,0,0,0.2);
}


/* Geolocation button inside search field */
.geolocate-btn {
  position: absolute;
  right: 15px;
  top: 48%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  background: #c9e1dd;
  border-radius: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 2px 4px 4px rgba(90,90,90,0.5);
}

.geolocate-btn:hover {
  background: #f0f0f0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.geolocate-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.geolocate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.geolocate-icon {
  display: block;
}

.geolocate-spinner {
  display: none;
  animation: spin 1s linear infinite;
}

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

/* Ensure search input has right padding for the button */
#pac-input {
  padding-right: 50px !important;
}



.panel{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  background:rgba(255,255,255,0.03);
}

.panel-title{
  font-weight:750;
  margin-bottom:10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.panel-title.row{
  gap:12px;
}

.controls{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:var(--muted);
}

.controls input[type="range"]{
  width:140px;
}

.prop-info{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:13px;
}

.kv{
  display:flex;
  justify-content:space-between;
  gap:10px;
}
.kv .k{ color:var(--muted); }
.kv .v{ text-align:right; }

.sales-pane{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.units-and-sales{
  display:flex;
  gap:10px;
  height:280px;
}

.units{
  width:150px;
  border:1px solid var(--border);
  border-radius:10px;
  overflow:auto;
  padding:8px;
  background:rgba(0,0,0,0.18);
}

.unit-btn{
  width:98%;
  height:15%;
  text-align:left;
  padding:4px;
  margin-bottom:6px;
  border-radius:8px;
  border:1px solid rgb(229 222 231 / 50%);
  background: rgb(105 102 168 / 50%);
/*  background:rgba(138 43 226,0.5); */
  color:var(--text);
  cursor:pointer;
}

.unit-btn.active{
  border-color: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 1px rgba(213,27,27,0.9) inset;
  background: rgb(143 188 143 / 50%);
}

.sales{
  flex:1;
  border:1px solid var(--border);
  border-radius:10px;
  overflow:auto;
  padding:8px;
  background:rgba(0,0,0,0.18);
}

.sales-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:6px 0;
  border-bottom:1px solid rgba(255,255,255,0.06);
  font-size:13px;
  color: #ffffff;
}
.sales-row:last-child{ border-bottom:none; }

.muted{ color:var(--muted); font-size:13px; }
.muted_light_bgrnd{ color:var(--muted_light_bgrnd); font-size:13px; }

.map-wrap{
  flex:1;
  position:relative;
}

.map{
  height:100%;
  width:100%;
}

/* ================================
   InfoWindow Styles
   ================================ */

/* InfoWindow body container */
.iw-body {
  padding: 8px;
  max-width: 320px;
  font-family: inherit;
}

/* Address/title at top */
.iw-title {
  color: #5b61d6;
  font-weight: 700;
  font-size: 14px;
  display: block;
}

/* Sales History heading */
.iw-heading {
  margin-top: 10px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: #333;
}

/* Horizontal separator/divider */
.iw-separator {
  border: none;
  border-top: 1px solid #e3e3e3;
  margin: 6px 0 10px 0;
}

/* Sales content container */
.iw-sales {
    max-width: 380px;
  font-size: 14px;
}

/* Individual sale row */
.iw-sale-row {
  display: flex;
  max-width: 380px;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* Sale label (left side - "Settlement Date:", "Sale Amount:") */
.iw-sale-label {
  color: #333;
  font-weight: 400;
}

/* Sale value (right side - the actual date/amount) */
.iw-sale-value {
  color: #000;
  font-weight: 500;
}

/* Sale separator between items */
.iw-sale-separator {
  margin: 8px 0;
  border: none;
  border-top: 1px solid #ddd;
}

/* No sales message */
.iw-no-sales {
  opacity: 0.8;
  text-align: center;
  font-style: italic;
  color: #666;
}

/* Multi-unit message */
.iw-multi-unit-msg {
  margin-top: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  opacity: 0.85;
  color: #666;
  font-style: italic;
  text-align: center;
}

/* Re-center & Search button */
.iw-action-btn {
  width: 100%;
  padding: 8px 12px;
  background-color: #5b61d6;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.2s ease;
}

.iw-action-btn:hover {
  background-color: #4a4fb5;
}

.iw-action-btn:active {
  background-color: #3d4299;
}

.iw-action-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* Button helper text */
.iw-helper-text {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
  font-style: italic;
  text-align: center;
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.3;
}



/* Suburb Statistics Panel */
#suburb-stats-panel .panel-title {
  font-weight: 750;
  font-size: 16px;
}

#suburb-stats-content {
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
}

/* Two-column grid layout */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  min-height: 60px;
}

.stat-label {
  font-weight: 600;
  color: #d0cfcf;
  font-size: 13px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
  color: #5bafd6;
  margin-bottom: 2px;
}

.stat-detail {
  font-size: 10px;
  color: #666;
  line-height: 1.4;
}

.stat-address {
  font-size: 12px;
  color: #dbdabe;
  margin-top: 2px;
}

.no-data {
  color: #999;
  font-style: italic;
}

/* --- Responsive sidebar widths --- */
.app{
  height: 100dvh;   /* better on iOS than 100vh */
  width: 100%;
  display: flex;
}

/* Let the map actually shrink/grow properly */
.map-wrap { flex: 1 1 auto; min-width: 0; }

/* Responsive sidebar width */
:root{
  --sidebar-w: clamp(400px, 20vw, 450px);  /* desktop */
}

.sidebar{
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);

  /* IMPORTANT: remove the lock */
  min-width: 0;
  max-width: none;

  border-right:1px solid var(--border);
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  overflow:auto;
}

/* =============================================
   MOBILE RESPONSIVE LAYOUT
   ============================================= */

/* Small screens - Portrait (iPhone default) */
@media (max-width: 768px) and (orientation: portrait) {
  .app {
    flex-direction: column;           /* stack vertically */
  }

  .sidebar {
    width: 100% !important;
    max-height: 48vh;                 /* side panel takes ~half the screen */
    min-height: 220px;                /* don't collapse too much */
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
  }

  .sidebar-inner {
    padding: 10px;
    gap: 8px;
  }

  .map-wrap {
    flex: 1 1 auto;                   /* map gets ALL remaining space */
    min-height: 52vh;
  }

  /* Make panels and text more touch-friendly */
  .panel {
    padding: 12px;
  }
  .panel-title {
    font-size: 15px;
  }
  .search-holder {
    padding: 12px;
  }
  #pac-input {
    font-size: 16px !important;       /* prevents iOS zoom */
    padding: 14px 52px 14px 14px !important;
  }
  .geolocate-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
    right: 12px;
  }
}

/* Landscape phones & small tablets */
@media (max-width: 1024px) and (orientation: landscape) {
  .app {
    flex-direction: row;
  }
  .sidebar {
    width: 50% !important;
    max-width: 420px;
    min-width: 320px;
    max-height: 100%;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  .map-wrap {
    flex: 1;
  }
}



/* ── Portrait (main iPhone view) ───────────────────────────────────── */
/* =============================================
   MOBILE LAYOUT + INFO WINDOW (iPhone / iPad)
   ============================================= */

/* ── Portrait (main iPhone view) ───────────────────────────────────── */
@media (max-width: 768px) and (orientation: portrait) {
  .app {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100% !important;
    flex: 0 0 28vh;
    max-height: 28vh;
    min-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
  }
  
  .map-wrap {
    flex: 1 1 auto;
    min-height: 0;
  }
  
  /* Touch-friendly tweaks */
  .panel { 
    padding: 12px; 
  }
  
  .panel-title { 
    font-size: 15px; 
  }
  
  .search-holder { 
    padding: 12px; 
  }
  
  #pac-input {
    font-size: 16px !important;
    padding: 14px 52px 14px 14px !important;
  }
  
  .geolocate-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
    right: 12px;
  }
  
  /* ── INFO WINDOW (much more compact) ─────────────────────────────────── */
  .gm-style-iw-c,
  .gm-style-iw {
    width: 62vw !important;
    max-width: 320px !important;
    min-width: 220px !important;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4) !important;
    border-radius: 10px !important;
  }
  
  .iw-body {
    max-width: 100% !important;
    padding: 8px 10px !important;
    font-size: clamp(10px, 3.2vw, 12px) !important;
    line-height: 1.30;
  }
  
  /* Address title - much smaller */
  .iw-title {
    font-size: clamp(11px, 3.5vw, 13px) !important;
    font-weight: 600;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-bottom: 6px !important;
  }
  
  /* Sales data rows - smaller text */
  .iw-sale-row {
    font-size: clamp(9px, 3vw, 11px) !important;
    gap: 8px !important;
    white-space: nowrap !important;
    display: flex;
    align-items: baseline;
    margin-bottom: 4px !important;
  }
  
  .iw-sale-label {
    min-width: clamp(70px, 22vw, 85px);
    flex-shrink: 0;
  }
  
  .iw-sale-value {
    font-weight: 600;
  }
  
  /* Action button - more compact */
  .iw-action-btn {
    font-size: clamp(10px, 3.2vw, 12px) !important;
    padding: 9px 12px !important;
    margin-top: 10px !important;
  }
  
  /* Helper text */
  .iw-helper-text {
    font-size: clamp(8px, 2.8vw, 10px) !important;
    margin-top: 6px !important;
  }
  
  /* Hide the arrow on mobile */
  .gm-style-iw-tc {
    display: none !important;
  }
}

/* ── Very small iPhones (SE, 12/13 mini, etc) ─────────────────────── */
@media (max-width: 380px) and (orientation: portrait) {
  .sidebar {
    flex: 0 0 26vh;
    max-height: 26vh;
  }
  
  .gm-style-iw-c,
  .gm-style-iw {
    width: 68vw !important;
    max-width: 280px !important;
    min-width: 220px !important;
  }
  
  .iw-body {
    padding: 8px 10px !important;
  }
  
  .iw-sale-label {
    min-width: clamp(65px, 20vw, 75px);
  }
}

/* ── Landscape phones (iPhone + iPad) ─────────────────────────────── */
@media (max-width: 1024px) and (orientation: landscape) {
  .sidebar {
    width: 40% !important;
    max-width: 360px;
    min-width: 220px;
    max-height: 100%;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  
  /* Info window in landscape - MUCH narrower */
  .gm-style-iw-c,
  .gm-style-iw {
    width: 30vw !important;
    max-width: 360px !important;
    min-width: 220px !important;
  }
  
  .iw-body {
    padding: 6px 8px !important;
    font-size: clamp(10px, 2vh, 12px) !important;
    line-height: 1.3;
  }
  
  .iw-title {
    font-size: clamp(10px, 2.2vh, 12px) !important;
    margin-bottom: 4px !important;
  }
  
  .iw-sale-row {
    font-size: clamp(8px, 1.8vh, 10px) !important;
    gap: 4px !important;
    margin-bottom: 2px !important;
  }
  
  .iw-sale-label {
    min-width: clamp(60px, 20vw, 80px);
  }
  
  .iw-action-btn {
    font-size: clamp(9px, 2vh, 11px) !important;
    padding: 7px 10px !important;
    margin-top: 8px !important;
  }
  
  .iw-helper-text {
    font-size: clamp(7px, 1.6vh, 9px) !important;
    margin-top: 4px !important;
  }
}

/* ── iPad Pro in portrait (larger tablets) ────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
  .sidebar {
    width: 33% !important;
    max-width: 480px;
    min-width: 360px;
  }
  
  /* Info window reasonable size for iPad */
  .gm-style-iw-c,
  .gm-style-iw {
    width: 30vw !important;
    max-width: 400px !important;
    min-width: 300px !important;
  }
  
  .iw-body {
    padding: 10px 12px !important;
    font-size: 12px !important;
  }
  
  .iw-title {
    font-size: 14px !important;
  }
  
  .iw-sale-row {
    font-size: 11px !important;
  }
}