/**
 * Regions API Documentation - Specific Styles.
 *
 * This stylesheet contains styles specific to the Regions API documentation page, including the choropleth map preview
 * and its metric toggle, legend, and popups.
 */

/* ==========================================================================
   REGIONS API SPECIFIC STYLES
   ========================================================================== */

/* ---- Regions Preview Container ---- */

#regions-preview {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: var(--border-radius, 4px);
    background-color: white;
    overflow: hidden;
}

/* The metric selector lives in a toolbar above the map (rather than as an on-map Leaflet control) so it can never be
   overlapped by region popups: Leaflet control corners sit at z-index 1000 while the popup pane is trapped at 700
   inside the transformed map pane, so on-map controls always cover popups. */
.regions-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-light, #e0e0e0);
    background-color: #fafafa;
    font-family: var(--font-sans);
    font-size: 13px;
    color: #222;
}

.regions-toolbar label {
    font-weight: 600;
}

.regions-toolbar select {
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

#regions-map {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

/* ---- Loading Message ---- */

.loading-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-style: italic;
    background-color: #f8f9fa;
}

.loading-message::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid var(--color-accent-link, #007bff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---- Counter Badge ---- */

.counter-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: auto; /* Override the shared api-docs.css rule's `right`, which would otherwise stretch the badge full width. */
    background-color: white;
    padding: 5px 10px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    font-size: 12px;
    font-weight: 500;
    color: #222;
    z-index: 1000;
}

/* ---- Continuous Legend ---- */

.continuous-legend {
    background-color: white;
    padding: 8px 10px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    line-height: 1.4;
    color: #555;
    font-family: var(--font-sans);
    max-width: 250px;
}

.continuous-legend h4 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #222;
}

.gradient-container {
    border: 1px solid #ccc;
    border-radius: 3px;
    overflow: hidden;
}

.legend-tick {
    font-size: 10px;
    color: #666;
    font-weight: 500;
}

/* ---- Region Popup ---- */

.region-popup {
    font-family: var(--font-sans);
    max-width: 250px;
    line-height: 1.4;
}

.region-popup h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #222;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 4px;
}

.region-popup p {
    margin: 4px 0;
    font-size: 13px;
    color: #555;
}

.region-popup strong {
    color: #222;
    font-weight: 500;
}

/* ---- View Region Button ---- */

.explore-region-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background-color: var(--color-accent-link, #007bff);
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    border: 1px solid var(--color-accent-link, #007bff);
    transition: background-color 0.2s ease;
}

.explore-region-btn:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    text-decoration: none;
}

.explore-region-btn:focus {
    outline: 2px solid rgba(0, 123, 255, 0.5);
    outline-offset: 2px;
}

/* ---- No Regions Message ---- */

.no-regions-message {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    font-size: 14px;
    color: #666;
    z-index: 1000;
    white-space: nowrap;
}

/* ---- Responsive Adjustments ---- */

@media (max-width: 768px) {
    .continuous-legend {
        max-width: 180px;
        padding: 6px 8px;
    }

    .gradient-container,
    .legend-labels {
        width: 160px !important;
    }

    .continuous-legend h4 {
        font-size: 13px;
    }

    .legend-tick {
        font-size: 9px;
    }

    .region-popup {
        max-width: 200px;
    }
}
