/* =========================================
   The map's status (EntityHealth): one class per status, named by
   Symbols.OfHealth (MapClass). Markers, clusters, places and dots read
   the same variables, so a status looks the same wherever it is drawn.
   Loaded after app.css, whose marker pin this colours.
========================================= */

.b2b-health-unknown { --b2b-health-color: #2563eb; --b2b-health-border: #e5e7eb; --b2b-health-bg: #fff; }
.b2b-health-online { --b2b-health-color: #16a34a; --b2b-health-border: #22c55e; --b2b-health-bg: #fff; }
/* Grey, not red: red is an alarm, and without contact is not one */
.b2b-health-offline { --b2b-health-color: #6b7280; --b2b-health-border: #9ca3af; --b2b-health-bg: #e5e7eb; }
/* The alarm levels in their colours (Symbols.OfAlarmLevel): a warning yellow, an alarm orange, a critical alarm red. CSS
   variables cannot read a Tailwind class, so the same colours are written here as their values. */
.b2b-health-warning { --b2b-health-color: #ca8a04; --b2b-health-border: #facc15; --b2b-health-bg: #fff; }  /* yellow-600, yellow-400 */
.b2b-health-alarm { --b2b-health-color: #ea580c; --b2b-health-border: #fb923c; --b2b-health-bg: #fff; }    /* orange-600, orange-400 */
.b2b-health-critical { --b2b-health-color: #dc2626; --b2b-health-border: #ef4444; --b2b-health-bg: #fff; } /* red-600, red-500 */

.b2b-marker-wrapper .b2b-marker-icon {
    background: var(--b2b-health-bg, #fff);
    border-color: var(--b2b-health-border, #e5e7eb);
}

    /* The status decides the colour, over the kind's theme colour (bgCustomText) */
    .b2b-marker-wrapper .b2b-marker-icon i {
        color: var(--b2b-health-color, #2563eb) !important;
    }

.b2b-health-dot {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 9999px;
    background: var(--b2b-health-border, #d1d5db);
}

/* =========================================
   Clusters and places
========================================= */

.b2b-cluster-container {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
}

/* A cluster and a place stand centred on their point, as badges of one size (b2bMap._badgeSize): markers whose badges
   would cover each other are clustered, so badges never stand on each other */
.b2b-cluster,
.b2b-place {
    position: absolute;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    color: #111827;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.b2b-cluster,
.b2b-place-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: var(--b2b-health-bg, #fff);
    border: 3px solid var(--b2b-health-border, #e5e7eb);
    box-shadow: 0 6px 18px rgba(0,0,0,.24), 0 2px 6px rgba(0,0,0,.14);
}

.b2b-cluster {
    font-size: 14px;
}

/* The place's badge: its symbol, with the alarm count on its edge, over its name. How many stand at the place is in the
   list on hover: a count on the badge would read as an alarm count. */
.b2b-place-badge {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    font-size: 15px;
}

/* The name joins the badge: a pill from the badge's middle outwards, behind it and in its status frame, so it is plain
   which badge a name belongs to. It goes to the side with room (b2bMap._placeNames). About 18 characters; the whole
   name is in the list on hover. */
.b2b-place-name {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateY(-50%);
    max-width: 160px;
    padding: 4px 10px 4px 28px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 3px solid var(--b2b-health-border, #e5e7eb);
    border-radius: 9999px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,.24), 0 2px 6px rgba(0,0,0,.14);
    font-size: 13px;
}

    .b2b-place-name-left .b2b-place-name {
        left: auto;
        right: 50%;
        padding: 4px 28px 4px 10px;
    }

    /* Where even the shortest form of the name collides (b2bMap._placeNames): the badge only */
    .b2b-place-compact .b2b-place-name {
        display: none;
    }

/* The alarm count, the same on a marker, a cluster and a place */
.b2b-alarm-count {
    z-index: 20;
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9999px;
    background: #ef4444;
    border: 2px solid #fff;
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   A marker's popup: name, status, a line, and a link to its page
========================================= */

.b2b-popup {
    min-width: 240px;
}

.b2b-popup-title {
    margin-bottom: 8px;
    color: #111827;
    font-size: 15px;
    font-weight: 800;
}

.b2b-popup-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.b2b-popup-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #374151;
    font-size: 13px;
}

.b2b-popup-muted {
    color: #6b7280;
}

.b2b-popup-open,
.b2b-popup-action {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    text-decoration: none;
}

    .b2b-popup-open:hover,
    .b2b-popup-action:hover {
        background: #eff6ff;
        color: #2563eb;
    }

.b2b-popup-open {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 14px;
}

/* A function's button: its page, or the page's dialog */
.b2b-popup-actions {
    display: flex;
    min-width: 42px;
    align-items: center;
    justify-content: center;
}

.b2b-popup-action {
    width: 38px;
    height: 38px;
    border-radius: 9999px;
    color: #111827;
    font-size: 15px;
    cursor: pointer;
}

/* No page and no dialog on this map: the symbol only */
.b2b-popup-action-off,
.b2b-popup-action-off:hover {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: default;
}

/* =========================================
   What a cluster holds: on hover, or the first tap on a touch screen
========================================= */

.b2b-cluster-popup .leaflet-popup-content {
    margin: 8px;
    min-width: 220px;
}

.b2b-cluster-title {
    font-weight: 800;
    font-size: 14px;
    color: #111827;
    padding: 2px 6px 6px;
}

.b2b-cluster-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #111827;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

    .b2b-cluster-row:hover {
        background: #f3f4f6;
    }

.b2b-cluster-row-icon {
    width: 18px;
    text-align: center;
    color: #4b5563;
}

.b2b-cluster-row-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.b2b-cluster-row-count {
    color: #6b7280;
    font-size: 12px;
}

.b2b-cluster-more {
    padding: 4px 6px;
    color: #6b7280;
    font-size: 12px;
}

.b2b-cluster-zoom {
    width: 100%;
    margin-top: 4px;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    color: #111827;
    font-size: 13px;
    font-weight: 600;
}

/* =========================================
   The AI's way to a place (b2bGuidanceMap): the place, the reader, and
   the path between them
========================================= */

.ai-guide-marker {
    background: transparent;
    border: 0;
}

.ai-guide-target,
.ai-guide-user {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px rgba(15,23,42,.25);
    color: #fff;
}

.ai-guide-target {
    background: #dc2626;
}

.ai-guide-user {
    background: #2563eb;
}

    .ai-guide-target span,
    .ai-guide-user span {
        position: absolute;
        inset: -8px;
        border-radius: 9999px;
        border: 2px solid currentColor;
        opacity: .35;
        animation: aiGuidePulse 1.6s ease-out infinite;
    }

    .ai-guide-target i,
    .ai-guide-user i {
        position: relative;
        z-index: 1;
        font-size: 16px;
    }

.ai-guide-path {
    animation: aiGuideDash 1.2s linear infinite;
}

@keyframes aiGuidePulse {
    0% { transform: scale(.75); opacity: .55; }
    100% { transform: scale(1.55); opacity: 0; }
}

@keyframes aiGuideDash {
    to { stroke-dashoffset: -36; }
}
