/**
 * ABC3 Map public page and responsive category drawer.
 */
.abc3map-page {
    position: relative;
    width: 100%;
    max-width: none;
}

.abc3map-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 24px;
    margin: 0 0 6px;
    padding: 0 2px;
}

.abc3map-count {
    font-size: 13px;
}

.abc3map-canvas {
    width: 100%;
    height: calc(100vh - 210px);
    min-height: 560px;
    background: #eef2f5;
    border: 1px solid var(--hh-border-color, #ddd);
    border-radius: 4px;
}

.abc3map-filter-index {
    display: none !important;
}

.abc3map-popup-title {
    margin-bottom: 4px;
    font-weight: 700;
}

.abc3map-popup-location {
    margin-top: 4px;
    color: #666;
    font-size: 12px;
}

.abc3map-popup-link,
.abc3map-popup .btn {
    margin-top: 6px;
}

.abc3map-space-modal .modal-dialog {
    width: min(920px, calc(100vw - 24px));
}

.abc3map-space-card h3 {
    margin-top: 0;
}

.abc3map-space-table th {
    width: 140px;
    white-space: nowrap;
}

/* Reuse the shared /cat and /spaces search surface. */
.abc3map-page .abc3search-heading {
    margin-bottom: 8px;
}

.abc3map-page .abc3search-search-shell {
    position: static !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.abc3map-page .abc3search-search-body {
    display: block !important;
    padding: 0 !important;
}

.abc3map-page .abc3search-mobile-search-header,
.abc3map-page .abc3search-mobile-search-footer {
    display: none;
}

.abc3map-page .abc3search-local .abc3search-advanced-filter {
    display: block !important;
}

.abc3map-page .abc3search-mobile-advanced-toggle-field {
    display: none !important;
}

@media (min-width: 768px) {
    .abc3map-page .abc3map-canvas {
        height: calc(100vh - 195px);
        min-height: 610px;
    }
}

@media (max-width: 767px) {
    .abc3map-toolbar {
        justify-content: center;
        margin-bottom: 4px;
    }

    .abc3map-canvas {
        height: calc(100vh - 128px);
        min-height: 450px;
        border-radius: 3px;
    }

    .abc3map-space-table th,
    .abc3map-space-table td {
        display: block;
        width: 100%;
        white-space: normal;
    }

    .abc3map-page .abc3search-search-shell {
        position: fixed !important;
        top: 56px !important;
        right: 6px !important;
        bottom: 8px !important;
        left: 6px !important;
        z-index: 1050 !important;
        display: none !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: var(--hh-background-color-main, #fff) !important;
        border: 1px solid var(--hh-border-color, #d7d7d7) !important;
        border-radius: 8px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, .32) !important;
    }

    .abc3map-page.abc3search-search-open .abc3search-search-shell {
        display: flex !important;
        flex-direction: column;
    }

    .abc3map-page .abc3search-mobile-search-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 9px 12px;
        background: var(--hh-background-color-page, #f7f7f7);
        border-bottom: 1px solid var(--hh-border-color, #d7d7d7);
    }

    .abc3map-page .abc3search-search-body {
        flex: 1 1 auto;
        min-height: 0;
        padding: 10px 10px 4px !important;
        overflow-y: auto;
        background: var(--hh-background-color-main, #fff) !important;
    }

    .abc3map-page .abc3search-mobile-search-footer {
        display: block !important;
        padding: 8px 10px;
        background: var(--hh-background-color-page, #f7f7f7);
        border-top: 1px solid var(--hh-border-color, #d7d7d7);
    }

    .abc3map-page .abc3search-mobile-search-footer .btn {
        width: 100%;
    }

    .abc3map-page .abc3search-mobile-advanced-toggle-field {
        display: block !important;
    }

    .abc3map-page form.abc3search-local:not(.abc3search-advanced-open) .abc3search-advanced-filter {
        display: none !important;
    }

    .abc3map-page form.abc3search-local.abc3search-advanced-open .abc3search-advanced-filter {
        display: block !important;
    }

    .abc3map-page .abc3search-search-launcher {
        display: inline-flex !important;
    }
}

/* Readable formatted map preview descriptions. */

.abc3map-rich-description p {
    margin: 0 0 8px;
}
.abc3map-rich-description ul {
    margin: 0 0 8px 20px;
    padding: 0;
}
.abc3map-rich-description h3,
.abc3map-rich-description h4 {
    margin: 10px 0 6px;
    font-size: 16px;
    font-weight: 700;
}
.abc3map-rich-description a {
    word-break: break-word;
}

/* Compact map toolbar spacing. */
.abc3map-page .abc3search-directory-panel {
    margin-top: 0 !important;
    margin-bottom: 3px !important;
}

.abc3map-page .abc3search-directory-panel .panel-body {
    padding: 3px 5px !important;
}

.abc3map-page .abc3map-toolbar {
    display: none !important;
    margin: 0 0 3px !important;
    padding: 0 !important;
}

.abc3map-page .abc3map-canvas {
    margin-top: 0 !important;
}

/* Remove the top gap above the unified toolbar. */
.abc3map-page.abc3search-spaces-page {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.abc3map-page.abc3search-spaces-page > .abc3search-directory-panel:first-child {
    margin-top: 0 !important;
}

/* Keep the unified toolbar close to the map and overlay the result count. */
.abc3map-page > .abc3search-spaces-page.container {
    margin-top: -10px !important;
    margin-bottom: 2px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.abc3map-page > .abc3search-spaces-page.container .panel {
    margin-top: 0 !important;
    margin-bottom: 2px !important;
}

.abc3map-page > .abc3search-spaces-page.container .panel-body {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}


.abc3map-page .abc3map-canvas-wrap {
    position: relative;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.abc3map-page .abc3map-count-overlay {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 900;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #555;
    font-size: 12px;
    line-height: 1.2;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Category tree layout matching the shared directory pattern. */
.abc3map-layout {
    display: grid;
    grid-template-columns: minmax(210px, 22%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    margin-top: 6px;
}

.abc3map-category-pane,
.abc3map-map-pane {
    min-width: 0;
}

.abc3map-category-pane {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 92px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
    z-index: 40;
}

.abc3map-category-panel {
    margin-bottom: 0 !important;
    border-radius: 4px;
    box-shadow: none;
}

.abc3map-category-panel .panel-heading {
    padding: 6px 10px !important;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.abc3map-category-panel .panel-body {
    padding: 8px !important;
}

.abc3map-category-tree {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 3px;
    margin: 0;
    padding: 0;
}

.abc3map-category-node {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 0;
    margin: 0;
    padding: 0;
    min-height: 0;
}

.abc3map-category-row {
    display: flex;
    align-items: stretch;
    min-height: 34px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--abc3map-category-border, #d7e3f3);
    border-left: 4px solid var(--abc3map-category-left-border, #5b9bd5);
    border-right: 4px solid var(--abc3map-category-right-border, #d7e3f3);
    border-radius: 4px;
    background: var(--abc3map-category-background, #fff);
    overflow: visible;
}

.abc3map-category-link {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 34px;
    margin: 0;
    padding: 6px 10px;
    color: #333;
    line-height: 1.2;
    text-decoration: none;
}

.abc3map-category-link:hover,
.abc3map-category-link:focus {
    background: #f5f8fc;
    color: #111;
    text-decoration: none;
}

.abc3map-category-name {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
}

.abc3map-category-count {
    margin-left: 5px;
    color: #777;
    font-weight: normal;
    white-space: nowrap;
}

.abc3map-category-expand {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    min-height: 34px;
    margin: 0;
    padding: 0;
    border-left: 1px solid #e5e5e5;
    background: #f7f7f7;
    color: #555;
    line-height: 1;
    font-weight: normal;
    cursor: pointer;
}

.abc3map-category-expand:hover,
.abc3map-category-expand:focus {
    background: #edf3fb;
    color: #111;
}

.abc3map-category-expand-empty {
    cursor: default;
    opacity: .35;
}

.abc3map-category-toggle {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.abc3map-category-children {
    display: none;
    grid-template-columns: 1fr;
    row-gap: 3px;
    margin: 3px 0 0 22px;
    padding: 0;
    min-height: 0;
}

.abc3map-category-toggle:checked ~ .abc3map-category-children {
    display: grid;
}

.abc3map-category-toggle:checked + .abc3map-category-row .abc3map-category-expand .fa:before {
    content: "\f077";
}

.abc3map-category-selected > .abc3map-category-row {
    border-color: #337ab7;
    border-left-color: #337ab7;
    background: #f5f9ff;
}

.abc3map-mobile-category-toggle,
.abc3map-mobile-category-backdrop {
    display: none;
}

@media (min-width: 1400px) {
    .abc3map-layout {
        grid-template-columns: minmax(230px, 20%) minmax(0, 1fr);
    }
}

@media (max-width: 991px) {
    body.abc3map-mobile-sidebar-open {
        overflow: hidden !important;
    }

    .abc3map-mobile-category-toggle {
        display: inline-block;
        margin: 6px 0 8px 0;
    }

    .abc3map-mobile-category-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .35);
        z-index: 300000;
    }

    body.abc3map-mobile-sidebar-open .abc3map-mobile-category-backdrop {
        display: block;
    }

    .abc3map-layout {
        display: block;
        margin-top: 4px;
    }

    .abc3map-category-pane {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: -88vw !important;
        right: auto !important;
        width: 86vw !important;
        max-width: 360px !important;
        height: 100vh !important;
        max-height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        background: #fff !important;
        padding: 12px !important;
        z-index: 300010 !important;
        box-shadow: 4px 0 18px rgba(0, 0, 0, .22) !important;
        transition: left .22s ease-in-out !important;
        -webkit-overflow-scrolling: touch !important;
    }

    body.abc3map-mobile-sidebar-open .abc3map-category-pane {
        left: 0 !important;
    }

    .abc3map-map-pane {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .abc3map-category-children {
        margin-left: 12px;
    }

    .abc3map-category-link {
        padding: 7px 8px;
    }

    .abc3map-category-expand {
        flex-basis: 38px;
        width: 38px;
    }
}
