/*
 * Authorized Aggregate GIS Map — page-specific styles.
 * Designed to feel native to DIME: same Helvetica Neue Light font stack,
 * DIME blue palette (#0263cc primary, #01349a dark), square corners,
 * minimal rounding to match the rest of the app.
 */

#aam-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 520px;
    width: 100%;
    border: 1px solid #a8a8a8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    background: #fff;
    overflow: hidden;
    font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
    color: #222;
}

/* ---------- Header bar ---------- */

#aam-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: #f4f6f8;
    border-bottom: 2px solid #01349a;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

#aam-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #01349a;
    letter-spacing: 0.2px;
    flex: 0 0 auto;
    white-space: nowrap;
}

#aam-counts {
    color: #555;
    font-size: 13px;
    flex: 1 1 auto;
    min-width: 0;
}

#aam-counts span {
    font-weight: 600;
    color: #01349a;
}

#aam-legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: #444;
    flex: 0 0 auto;
}

.aam-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.aam-pin {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px #555;
}

.aam-pin-app   { background: #0263cc; }
.aam-pin-innoc { background: #2c7252; }
.aam-pin-both  { background: #7d3c98; }

#aam-filter-toggle {
    margin-left: auto;
    padding: 5px 14px;
    border: 1px solid #999;
    background: #fff;
    border-radius: 0;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #333;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

#aam-filter-toggle:hover {
    background: #eef3fa;
    border-color: #0263cc;
}

/* ---------- Proximity bar ---------- */

#aam-prox-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fbfaf2;
    border-top: 1px solid #d4cda0;
    border-bottom: 1px solid #d4cda0;
    flex-shrink: 0;
    font-size: 13px;
}

.aam-prox-label,
.aam-prox-spacer {
    color: #555;
    font-weight: 500;
}

.aam-radius-group {
    display: inline-flex;
    border: 1px solid #999;
    background: #fff;
    overflow: hidden;
}

.aam-radius-btn {
    padding: 4px 12px;
    border: 0;
    border-right: 1px solid #999;
    background: #fff;
    color: #333;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.aam-radius-btn:last-child {
    border-right: 0;
}

.aam-radius-btn:hover {
    background: #eef3fa;
}

.aam-radius-btn.aam-active {
    background: #0263cc;
    color: #fff;
    text-shadow: 1px 1px 0.5px #002744;
}

#aam-prox-locate,
#aam-prox-pick,
#aam-prox-clear {
    padding: 5px 12px;
    background: #fff;
    border: 1px solid #999;
    border-radius: 0;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    color: #01349a;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

#aam-prox-locate:hover,
#aam-prox-pick:hover,
#aam-prox-clear:hover {
    background: #eef3fa;
    border-color: #0263cc;
}

#aam-prox-pick.aam-active {
    background: #0263cc;
    color: #fff;
    border-color: #01349a;
    text-shadow: 1px 1px 0.5px #002744;
}

#aam-prox-clear {
    margin-left: auto;
    color: #8a3a3a;
    border-color: #d6c0c0;
}

#aam-prox-clear:hover {
    background: #f8eaea;
    border-color: #b34;
}

/* ---------- Body: filter sidebar + map ---------- */

#aam-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    position: relative;
}

#aam-map {
    flex: 1 1 auto;
    min-width: 0;
    background: #e6e6e6;
    position: relative;
}

#aam-filters {
    flex: 0 0 260px;
    width: 260px;
    background: #f9fafb;
    border-right: 1px solid #c8c8c8;
    padding: 12px 14px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 13px;
    color: #222;
    box-sizing: border-box;
}

#aam-filters.aam-collapsed {
    display: none;
}

.aam-filter-section {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #cccccc;
}

.aam-filter-section:last-of-type {
    border-bottom: 0;
}

.aam-filter-section h3 {
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #01349a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #cfdcec;
}

.aam-filter-section label {
    display: block;
    margin: 3px 0;
    cursor: pointer;
    color: #333;
}

.aam-filter-section label input[type="checkbox"] {
    margin-right: 6px;
    vertical-align: middle;
}

.aam-filter-section input[type="search"],
.aam-filter-section input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    border: 1px solid #999;
    border-radius: 0;
    font-size: 13px;
    font-family: inherit;
    color: #222;
    background: #fff;
}

.aam-filter-section input[type="search"]:focus,
.aam-filter-section input[type="text"]:focus,
.aam-filter-section select:focus {
    outline: none;
    border-color: #0263cc;
    box-shadow: 0 0 0 2px rgba(2, 99, 204, 0.18);
}

.aam-filter-section select {
    width: 100%;
    box-sizing: border-box;
    padding: 4px;
    border: 1px solid #999;
    border-radius: 0;
    font-size: 13px;
    font-family: inherit;
    color: #222;
    background: #fff;
}

.aam-hint {
    margin: 4px 0 0 0;
    font-size: 11px;
    color: #888;
    font-style: italic;
}

.aam-filter-actions {
    margin-top: 12px;
}

#aam-f-reset {
    width: 100%;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #999;
    border-radius: 0;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #01349a;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

#aam-f-reset:hover {
    background: #eef3fa;
    border-color: #0263cc;
}

/* ---------- Unmapped sources panel ---------- */

#aam-unmapped-list {
    background: #fbfaf2;
    border-top: 1px solid #d4cda0;
    padding: 8px 16px;
    max-height: 180px;
    overflow-y: auto;
    font-size: 13px;
    flex-shrink: 0;
}

#aam-unmapped-list summary {
    cursor: pointer;
    font-weight: 600;
    color: #01349a;
    padding: 2px 0;
}

#aam-unmapped-list ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

#aam-unmapped-list li {
    margin: 2px 0;
    color: #333;
}

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

.aam-popup {
    font-size: 13px;
    line-height: 1.45;
    max-width: 500px;
    color: #222;
    font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}

.aam-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 2px solid #01349a;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.aam-popup-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #01349a;
    line-height: 1.3;
    flex: 1 1 auto;
}

.aam-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex: 0 0 auto;
    line-height: 1.4;
    text-shadow: 1px 1px 0.5px #002744;
}

.aam-badge-app       { background: #0263cc; }
.aam-badge-innocuous { background: #2c7252; }
.aam-badge-both      { background: #7d3c98; }

.aam-popup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

.aam-meta-id {
    background: #eef3fa;
    color: #01349a;
    padding: 2px 8px;
    font-weight: 600;
    border: 1px solid #cfdcec;
}

.aam-meta-nonsmara {
    background: #fbf3e0;
    color: #7a5300;
    border-color: #e3d2a3;
}

.aam-meta-status {
    color: #555;
    padding: 2px 4px;
}

.aam-popup-row {
    margin: 4px 0;
    display: flex;
    gap: 8px;
}

.aam-label {
    flex: 0 0 70px;
    color: #777;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding-top: 1px;
}

.aam-value {
    flex: 1 1 auto;
    color: #222;
}

.aam-popup-distance {
    background: #fbfaf2;
    border: 1px solid #e2dcb6;
    padding: 4px 8px;
    margin-top: 4px;
}

.aam-quals {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
    font-size: 12px;
    border: 1px solid #999;
}

.aam-quals th {
    text-align: left;
    background: #f4f6f8;
    color: #01349a;
    font-weight: 600;
    padding: 5px 6px;
    border-right: 1px solid #d6d6d6;
    border-bottom: 2px solid #01349a;
}

.aam-quals th:last-child {
    border-right: 0;
}

.aam-quals td {
    padding: 5px 6px;
    border-right: 1px solid #ececec;
    border-bottom: 1px solid #ececec;
    vertical-align: top;
    color: #222;
}

.aam-quals td:last-child {
    border-right: 0;
}

.aam-quals tr:last-child td {
    border-bottom: 0;
}

.aam-quals a {
    color: #0263cc;
    text-decoration: none;
}

.aam-quals a:hover {
    text-decoration: underline;
    color: #01349a;
}

.aam-qual-expired td {
    color: #999;
    background: #fafafa;
}

.aam-expired-tag {
    display: inline-block;
    background: #b53a3a;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-shadow: 1px 1px 0.5px #5a1414;
}

/* ---------- Marker cluster icons (MarkerClusterer.js sets .aam-cluster) ---- */

.aam-cluster {
    cursor: pointer !important;
}

.aam-cluster img {
    pointer-events: none;          /* let clicks bubble to the parent div */
}

.aam-cluster:hover {
    opacity: 0.85;
}

/* ---------- Map control button (Districts toggle) ---------- */

.aam-map-control {
    margin: 10px;
}

#aam-districts-toggle {
    background: #fff;
    border: 1px solid #999;
    border-radius: 0;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: #333;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

#aam-districts-toggle:hover {
    background: #eef3fa;
    border-color: #0263cc;
}

#aam-districts-toggle.aam-active {
    background: #0263cc;
    color: #fff;
    border-color: #01349a;
    text-shadow: 1px 1px 0.5px #002744;
}

/* ---------- Mobile breakpoint ---------- */

@media (max-width: 700px) {
    #aam-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    #aam-legend {
        flex-wrap: wrap;
    }
    #aam-body {
        flex-direction: column;
    }
    #aam-filters {
        flex: 0 0 auto;
        width: 100%;
        max-height: 40vh;
        border-right: 0;
        border-bottom: 1px solid #999;
    }
    #aam-filter-toggle {
        margin-left: 0;
    }
    #aam-prox-bar {
        font-size: 12px;
    }
    #aam-prox-clear {
        margin-left: 0;
    }
}
