/* ==========================================================================
   1. MASTER WINDOW LOCK (App-Style Baseline)
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box !important;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw !important;
  height: 100vh !important;   /* Locks the page to exactly the window height */
  overflow: hidden !important; /* Prevents the main browser window from scrolling */
  background-color: #000033;   /* Your original deep blue background */
  font-family: Helvetica, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}
/* ==========================================================================
   2. DYNAMIC APARTMENTS-STYLE TOOLBAR HEADER
   ========================================================================== */
#toolbar {
  /* 1. Add your custom background image here */
  background-image: url('Top_Bkgd.jpg'); 
  background-size: cover;
  background-position: center;
  background-color: #EFEFEF; /* Fallback if image fails to load */
  
  /* Borders and Core Structural Sizing */
  border-left: 3px solid #CFDAF5;
  border-top: 3px solid #CFDAF5;
  border-right: 3px solid #89AEE7;
  border-bottom: 3px solid #89AEE7;
  width: 100% !important;
  flex-shrink: 0 !important; 
  
  /* Layout Spacing (Lets it adjust heights safely based on content) */
  height: auto !important;
  max-height: 175px !important;
  min-height:139px !important;
  padding: 10px 15px !important;
  overflow: visible !important;
}

/* 2. Overriding your legacy hardcoded tables inside the toolbar header */
#toolbar table {
  display: table !important; /* Forces layout tracking back to a crisp horizontal row */
  width: 20% !important;
  max-width: 20% !important;
  border-collapse: collapse;
  margin-top: 8px;
}

#toolbar td {
  display: table-cell !important; /* Keeps "Viewing X of Y" and "Legends" side-by-side */
  vertical-align: middle;
  padding: 4px !important;
  white-space: normal !important;
}

/* 3. Formatting the dynamic legend and navigation lists */
#toolbar ul {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-wrap: wrap; /* Wraps items into clear clean lines on small viewports */
  gap: 6px;
  align-items: center;
}

#toolbar ul li {
  display: inline-flex !important;
  align-items: center;
  color: #000066; /* Your original blueprint link/text color tint */
  font-size: 11px;
}

/* Style formatting for pagination link actions */
#toolbar ul#options li a, 
#toolbar ul#sidebar-controls li a {
  color: #990000;
  font-weight: bold;
  text-decoration: none;
  padding: 2px 5px;
}

#toolbar ul#options li a:hover {
  color: #FF0000;
  background-color: rgba(255,255,255,0.8);
}

#toolbar a:hover {
  color: #FF0000;
}

#toolbar a:active {
  color: #FF0000;
}

#toolbar a {
  color: #FFFFFF;
}

/* 4. Force small icons and future navigation arrows to frame accurately */
#toolbar img {
  display: inline-block !important;
  width: auto !important;
  height: auto !important;
  max-height: 20px !important; /* Locks icon layout limits vertically */
  margin-left: 4px;
  vertical-align: middle;
  aspect-ratio: auto !important; /* Keeps arrows/icons from warping */
}

/* 5. Clean layout overrides for the legacy raw tags */
#toolbar center {
  font-size: 12px;
  font-weight: bold;
  color: #333;
  margin: 4px 0;
}

#toolbar h1.style3 {
  font-size: 16px !important;
  font-weight: bold;
  color: #000066;
  margin: 0 !important;
}

/* Legend Text Formats inherited from your markup */
.style6, .style7 {
  font-size: 11px;
  font-weight: bold;
}


/* ==========================================================================
   3. MOBILE APP VIEWPORT (Default Behavior for Phones)
   ========================================================================== */
#content {
  display: flex;
  flex-direction: column; 
  width: 100%;
  height: calc(100vh - 45px); /* Fills remaining window space below toolbar */
}

/* Mobile Map Window */
#map-wrapper {
  position: relative;
  width: 100%;
  height: 40% !important; /* Map takes exactly 40% of the phone screen */
  flex-shrink: 0;
}

#map {
  width: 100%;
  height: 100%;
  border-left: 4px solid #89AEE7;
  border-top: 4px solid #CFDAF5;
  border-right: 4px solid #CFDAF5;
  border-bottom: 4px solid #89AEE7;
  background-color: #222;
}

/* Mobile Listings Column (The ONLY part allowed to scroll) */
#sidebar {
  width: 100%;
  height: 60% !important; /* Listings take up the remaining 60% of screen */
  overflow-y: auto !important; /* Adds isolated scrolling inside the listings */
  background-color: #000000;
  padding: 10px;
}

#sidebar a:hover {
  color: #FF0000;
}

#sidebar a:active {
  color: #FF0000;
}

#sidebar a {
  color: #990000;
}

/* Force listing tables and frames to fit cleanly inside the scrolling area */
table, thead, tbody, tr, th, td, #bottom_frames, #iframe {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

td {
  word-wrap: break-word !important;
  white-space: normal !important;
  padding: 10px 0;
}

/* Proportional Listing Images */
/* Pictures that Google draws inside the map (its buttons, the Street View figure, pins and map tiles) are left out:
   forcing them to full width and a 4:3 crop is what turned the map's buttons into blank white squares. */
img:not(#map *), iframe, table img:not(#map *), #sidebar img, #pic img {
  width: 100% !important;
  max-width: 100% !important;
  aspect-ratio: 4 / 3 !important; 
  object-fit: cover !important; 
  display: block;
}

/* The listing photo inside a pin's pop-up window keeps the same full-width 4:3 look as before */
#map .gm-style-iw-d img {
  width: 100% !important;
  max-width: 100% !important;
  aspect-ratio: 4 / 3 !important; 
  object-fit: cover !important; 
  display: block;
}
/* ==========================================================================
   4. DESKTOP APP VIEWPORT (Side-by-Side Windows - Cut-off Fix)
   ========================================================================== */
@media (min-width: 1024px) {
  /* 1. Release master html/body locks to let the calculation breathing room */
  html, body {
    height: 100vh !important;
    overflow: hidden !important;
  }

  /* 2. Tell the content wrapper to fill exactly what is left below the header */
  #content {
    flex-direction: row; 
    flex: 1 !important;         /* Automatically fills the window space below toolbar */
    min-height: 0 !important;   /* CRITICAL: Prevents columns from expanding beyond window */
    height: auto !important;
  }

  /* 3. Map dynamically takes up the remaining 2/3 of the layout width */
  #map-wrapper {
    flex: 1; 
    height: 100% !important;
  }

  /* 4. Listings sidebar takes up exactly 1/3 and locks inside the window edges */
  #sidebar {
    width: 33.333% !important; 
    height: 100% !important;
    overflow-y: auto !important; /* Isolated scrollbar handles long content safely */
    
    /* 5. Add safety padding at the very bottom so the last item never gets clipped */
    padding-bottom: 60px !important; 
  }
}

/* ==========================================================================
   5. RETAINED TEXT STYLES
   ========================================================================== */
.style1 { font-size: 11px; font-weight: bold; color: #990000; text-align: left; }
.style2 { font-size: 11px; color: #000066; }
.style3 { font-size: 10px; color: #000066; }

#sidebar p { margin: 10px; color: #fff; }
#sidebar ul#sidebar-list { list-style: none; padding: 0; margin: 0; }
#sidebar ul#sidebar-list li a {
  display: block;
  border-left: 3px solid #CFDAF5; border-top: 3px solid #CFDAF5;
  border-right: 3px solid #89AEE7; border-bottom: 3px solid #89AEE7;
  background: #EFEFEF; margin: 5px; padding: 4px; font-size: 12px;
  text-decoration: none; color: #000066;
}
#sidebar ul#sidebar-list li a:hover { background: #FFFFFF; color: #FF0000; }

 a:hover {
  color: #FF0000;
}

 a:active {
  color: #FF0000;
}

a: {
  color: #FFFFFF;
}

/* ==========================================================================
   MOBILE FOOTPRINT RESPONSIVE CORRECTION (Fixes Disappearing Listings)
   ========================================================================== */
@media (max-width: 1023px) {
  /* 1. Release the viewport vertical chokehold on phone viewports */
  html, body {
    height: auto !important;
    overflow-y: auto !important; /* Lets the whole mobile screen scroll up and down */
  }

  /* 2. Break down the master layout wrapper container into a standard block stack */
  #content {
    display: block !important;
    height: auto !important;
  }

  /* 3. Keep the map pinned at a tight layout height footprint */
  #map-wrapper {
    height: 300px !important; 
    margin-bottom: 15px;
  }

  /* 4. Force the listings container to sit inline and unlock its scrolling bounds */
  #sidebar {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important; /* The listing tables now show up right below the map */
    width: 100% !important;
  }

  /* 5. CRITICAL FIX: Kill your toolbar's legacy hardcoded 640px table width limit */
  #toolbar table, 
  #toolbar table[width="640"] {
    display: block !important;
    width: 100% !important;
  }

  #toolbar tr, 
  #toolbar td {
    display: block !important;
    width: 100% !important;
    text-align: center !important; /* Centers legend text and icons nicely on tiny mobile rows */
  }
}
