/*!
 * GeoElections
 * https://geoelections.net
 * License: using this CSS or any source code from this website without permission is prohibited.
 */
      html,
      body {
        margin: 0;
        padding: 0;
        height: 100%;
        overflow-y: hidden;
      }

      #page-content {
        display: flex;
        flex-direction: column;
        height: 100vh;
        border-style: none;
        border-color: rgb(255, 174, 0);
      }

      #header-container {
        display: flex;
        height: auto;
        justify-content: space-between;
        align-items: stretch;  /* makes both boxes full height */
        background: #eee;
      }

      #controls {
        opacity: 0;
        transition: opacity 0.2s ease-in;
        display: flex;
        align-self: flex-end;
        padding: 10px;
        border-style: none  ;
        border-color: red;
        align-items: center;
        }

      #controls.is-ready {
        opacity: 1;
      }

      #logo {
        display: flex
        justify-content: flex-end;   /* horizontal: content to right */
        align-items: bottom;         /* vertical: content centered */
        height: auto;
        border-style: none;
        border-color: green;
      }

      #logo-img {
        display: flex;
        justify-content: right;   /* horizontal: content to right */
        align-self: flex-end;
        width: 400px;
        height: 50px;
        background-image: url('../img/logo-main-v03.svg');
        background-size: contain;
        background-position: center;
        background-repeat: no-repeat;
        border-style: none;
        border-color: rgb(0, 255, 242);
        margin-right: 100px;
        margin-bottom: 10px;
        margin-top: 5px;
      }

      #map {
        width: 100%;
        height: 100%;
        border-style: none;
        border-color: rgb(255, 251, 0);
      }

            /* Virtual Select Custom Styling */
      .vscomp-wrapper {
        font-family: Arial !important;
        font-size: 13.75px !important;
        margin-right: 10px;
      }

      /* Country select styling */
      .country-select .vscomp-wrapper {
        width: 200px !important;
      }

      .country-select .vscomp-toggle-button {
        height: 20px !important;
        border: 1px solid #aaaaaa !important;
        border-radius: 4px !important;
        font-size: 13.75px !important;
        padding: 0 8px !important;
        background: white !important;
      }

    .country-select-dropbox {
      width: 1400px !important;
      background:rgba(255, 255, 255, 0.93) !important;
    }

    /* Disable Virtual Select's built-in virtualization */
    .country-select-container {
      max-height: 0px !important;
      overflow: visible !important;
      border: 0px !important;
      background:rgba(255, 255, 255, 0.0) !important;
    }

    /* Main container - no grid here */
    .country-select .vscomp-options {
      width: 1400px !important;
      display: block !important;
      max-height: 800px !important;
      overflow-y: auto !important;
      overflow-x: hidden !important;
      padding: 10px !important;
      height: auto !important;
    }

    /* Group titles - full width */
    .country-select .vscomp-option.group-title {
      position: static !important;
      transform: none !important;
      display: block !important;
      opacity: 1 !important;
      width: 100% !important;
      font-weight: bold !important;
      font-size: 18px !important;
      /* background: #f8f9fa !important; */
      border-bottom: 1px solid #dee2e6 !important;
      margin: 5px 0 5px 0 !important;
      padding: 8px 12px !important;
      color: #000000 !important;
      /* color: #495057 !important; */
      grid-column: 1 / -1 !important; /* Span all columns */
      line-height: 35px !important;
    }

    /* Regular options - in grid */
    .country-select .vscomp-option:not(.group-title) {
      font-size: 14px !important;
      position: static !important;
      transform: none !important;
      display: inline-table !important;
      opacity: 1 !important;
      height: 35px !important;
      line-height: 30px !important;
      /*width: calc(10% - 7px) !important; /* 3 columns with gap */
      margin: 0px 20px 0px 20px !important;
      min-height: auto !important;
      text-align: left !important;
      /* border: 1px solid #ddd !important; */
      cursor: pointer !important;
      transition: all 0.2s ease !important;
      box-sizing: border-box !important;
      vertical-align: top !important;
      overflow: hidden !important;
      text-overflow: ellipsis !important;
      white-space: nowrap !important;
    }

    /* Hide virtual scrollbar */
    .country-select .vscomp-options-list {
      overflow: visible !important;
      height: auto !important;
      max-height: none !important;
    }


/* --- Election select styling (ONLY THIS SECTION CHANGED) --- */
.elec-select .vscomp-wrapper {
  width: 180px !important;
}

/* Background goes here because JS resizes this specific rule via ptrCSSBlock */
.elec-select-dropbox {
  /* REMOVED hardcoded width/height so they don't fight your JS updateDimsElecDropbox function */
  min-height: 86px !important;
  max-height: 640px !important;
  background: rgba(255, 255, 255, 0.93) !important; /* The background color */
  border: 1px solid #aaaaaa !important;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
}

.elec-select-container {
  background: transparent !important; /* Make container transparent */
  border: none !important;
  box-shadow: none !important;
  height: auto !important;
}

/* Keep your existing grid and option logic exactly as they were below this... */

    /* Create our own scrollable container */
    .elec-select .vscomp-options {
      display: grid !important;
      grid-template-columns: repeat(6, 1fr) !important;
      gap: 0px !important;
      max-height: 600px !important;
      overflow-y: auto !important;
      overflow-x: hidden !important;
      padding: 8px !important;
      /* Force all options to be rendered */
      height: auto !important;
    }

    /* Ensure all options are visible (disable virtualization) */
    .elec-select .vscomp-option {
      position: static !important;
      transform: none !important;
      display: block !important;
      opacity: 1 !important;
      height: 30px !important;
      max-height: 30px !important;
      line-height: 25px;
      width: 100px !important;
      font-size: 14.25px !important;
      min-height: auto !important;
      align-items: center;
      justify-content: center;
      text-align: center;
    }

    .elec-select .vscomp-toggle-button {
      height: 20px !important;
      border: 1px solid #aaaaaa !important;
      border-radius: 4px !important;
      font-size: 13.75px !important;
      padding: 0 8px !important;
      background: white !important;
    }

    /* Tier select styling - Vertical List Version */
    .tier-select-dropbox {
      height: auto !important; /* Allow height to fit content */
      min-height: 20px !important;
      max-height: 400px !important;
      width: auto !important; /* Let it fit the text width */
      min-width: 180px !important;
      background: rgba(255, 255, 255, 0.93) !important;
      border: 1px solid #ccc !important;
      box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
    }

    .tier-select .vscomp-wrapper {
      width: 180px !important;
    }

    .tier-select-container {
      background: transparent !important;
      height: auto !important;
    }

    .tier-select .vscomp-options {
      display: block !important; /* Change from grid to block for vertical list */
      max-height: 400px !important;
      overflow-y: auto !important;
      padding: 5px 0 !important;
      height: auto !important;
    }

    .tier-select .vscomp-option {
      position: static !important;
      transform: none !important;
      display: flex !important; /* Better alignment for single lines */
      opacity: 1 !important;
      height: 35px !important;
      line-height: 35px !important;
      width: 100% !important; /* Take full width of dropbox */
      font-size: 14.25px !important;
      text-align: left !important; /* Align text to the left */
      padding: 0 15px !important;
      box-sizing: border-box !important;
    }

    .tier-select .vscomp-toggle-button {
      height: 20px !important;
      border: 1px solid #aaaaaa !important;
      border-radius: 4px !important;
      font-size: 13.75px !important;
      padding: 0 8px !important;
      background: white !important;
    }

          /* Party select styling */
    /* --- PARTY SELECT (Corrected Flexible Popup) --- */
    .party-select .vscomp-wrapper {
      width: 250px !important; /* FIXED TOP BAR SELECTOR */
    }

    .party-select-dropbox {
      background: transparent !important; /* Hole punch */
      /* FLEXIBLE POPUP MENU */
      width: 500px !important; 
      min-width: 250px !important; 
      max-width: 1000px !important; /* Your test limit */
    }

    .party-select-container {
      background: rgba(255, 255, 255, 0.93) !important;
      border: 1px solid #aaaaaa !important;
      border-radius: 4px;
      /* FLEXIBLE POPUP MENU */
      width: 1000px !important;
      min-width: 250px !important;
      max-width: 500px !important;
    }

    /* 1. Force the internal list to fit the width of its widest content */
    .party-select .vscomp-options-list {
      width: max-content !important;
      min-width: 100% !important;
    }

    /* 2. Remove constraints from the option container */
    .party-select .vscomp-option {
      width: auto !important;
      display: flex !important;
      padding-right: 35px !important; /* Space for the checkbox/checkmark */
    }

    /* 3. KILL the ellipsis and forced hidden overflow on the text span */
    .party-select .vscomp-option-text {
      white-space: nowrap !important;
      overflow: visible !important;
      text-overflow: clip !important;
      display: inline-block !important;
      max-width: none !important;
    }

    .party-select-dropbox .vscomp-search-wrapper {
      background: transparent !important;
    }

      .party-select .vscomp-toggle-button {
        height: 20px !important;
        border: 1px solid #aaaaaa !important;
        border-radius: 4px !important;
        font-size: 13.75px !important;
        padding: 0 8px !important;
        background: white !important;
        min-height: 20px !important;
        max-height: 20px !important;
      }

      /* Multi-select horizontal scrolling */
      .party-select .vscomp-value-container {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        max-height: 18px !important;
      }

      .party-select .vscomp-value-tag {
        display: inline-block !important;
        white-space: nowrap !important;
        margin-right: 2px !important;
        font-size: 13px !important;
        height: 16px !important;
        line-height: 12px !important;
        padding: 2px 6px !important;
        border-radius: 2px !important;
        background: #1e90ff !important;
        color: white !important;
        max-width: 150px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex-shrink: 0 !important;
      }

      .party-select .vscomp-clear-button {
        right: -25px !important;  /* Adjust this value */
      }

      .party-select .vscomp-value-tag .vscomp-value-tag-clear-button {
        color: white !important;
        margin-left: 4px !important;
        font-size: 12px !important;
      }

      /* Scrollbar styling for multi-select */
      .party-select .vscomp-value-container::-webkit-scrollbar {
        height: 4px !important;
      }

      .party-select .vscomp-value-container::-webkit-scrollbar-track {
        background: #f1f1f1 !important;
        border-radius: 4px !important;
      }

      .party-select .vscomp-value-container::-webkit-scrollbar-thumb {
        background: #888 !important;
        border-radius: 4px !important;
      }

      .party-select .vscomp-value-container::-webkit-scrollbar-thumb:hover {
        background: #555 !important;
      }

      /* Dropdown styling */
      .vscomp-dropbox-container {
        font-family: Arial !important;
        font-size: 13.75px !important;
        /* max-height: 400px !important; */
      }

      .vscomp-option {
        padding: 3px 8px !important;
        font-size: 13.75px !important;
      }

      /* Placeholder styling */
      .vscomp-placeholder {
        color: #999 !important;
        font-family: Arial !important;
        font-size: 13.75px !important;
      }

      /* Arrow styling */
      .vscomp-arrow {
        font-size: 10px !important;
        color: #555 !important;
      }

      /* Search input styling */
      .vscomp-search-wrapper input {
        font-family: Arial !important;
        font-size: 13.75px !important;
      }

    /* Hide virtual scrollbar */
    .vscomp-options-list {
      overflow: visible !important;
      height: auto !important;
      max-height: none !important;
    }

      /* Label styling */
      .control-label {
        display: inline-block;
        margin-left: 10px;
        margin-right: 5px;
        line-height: 22px;
        vertical-align: top;
      }

      .control-label:first-child {
        margin-left: 0;
      }

      .control-label + .control-label {
        margin-left: 20px;
      }

/* --- POPUP STYLING --- */
/* --- POPUP STYLING --- */
.map-cst-popup .maplibregl-popup-content {
    padding: 10px !important;
    min-width: 150px;
    max-width: 220px;
    background: rgba(255, 255, 255, 0.90) !important; /* Match background exactly */
    border-radius: 0px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Fix the "Arrow/Tip" connection and color */
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip {

    /* Match the background and transparency of the popup content */
    border-bottom-color: rgba(255, 255, 255, 0.90) !important;
    
    /* 2. Shift the arrow 15px to the right to move it past the rounded corner */
    position: relative;
    left: 0px !important;
    
    /* 3. Close the "gap" glitch by forcing a 1px overlap */
    margin-top: 0px; 
    
    /* Ensure no other borders interfere with transparency */
    border-left-color: transparent !important;
    border-right-color: transparent !important;
    border-top-color: transparent !important;
}

.popup-header {
    font-weight: bold;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    /* Border removed from here */
}

/* New divider class for conditional horizontal line */
.popup-divider {
    border-top: 1px solid #bbb;
    margin: 6px 0 8px 0;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
    font-size: 12.5px;
}

.pty-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.pty-vts {
    white-space: nowrap;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
}