/*
 * Styles for the Home Area "Device Locations" map.
 *
 * Leaflet renders markers and tooltips outside of Blazor's component DOM, so those nodes do
 * not receive the scoped CSS attribute generated for DeviceLocationMap.razor. The marker and
 * tooltip styles therefore live in this regular (non-scoped) stylesheet.
 *
 * Colors reference the WAGO design tokens (--w-color-* and --w-content-*) defined in the
 * UILibrary theme.css, which Host.razor loads before this file; no fallbacks are needed.
 */

.dlm-pin {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    border: 1px solid var(--w-color-light);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(31, 40, 55, .35);
}

.dlm-pin--cluster {
    width: 36px;
    height: 36px;
    font-size: 15px;
}

.dlm-pin--online {
    background: var(--w-color-primary);
    color: var(--w-content-default-fixed);
}

.dlm-pin--offline {
    background: var(--w-color-warning);
    color: var(--w-content-variant-fixed);
}

.dlm-pin--not-connected {
    background: var(--w-color-neutral-40);
    color: var(--w-content-default-fixed);
}

/* Device popup (Figma "Tooltip" component). Leaflet renders tooltips outside the Blazor
   component DOM, so these styles override Leaflet's default tooltip chrome from here. */

.dlm-popup-wrapper.leaflet-tooltip {
    display: flex;
    align-items: flex-start;
    width: 327px;
    padding: 0;
    white-space: normal;
    background: var(--w-color-neutral-7);
    border: 0;
    border-radius: 0;
    color: var(--w-color-anthracite);
    box-shadow:
        0 4px 4px rgba(0, 0, 0, .10),
        0 8.69px 10.16px rgba(0, 0, 0, .0182),
        0 17.72px 20.73px rgba(0, 0, 0, .02),
        0 36.5px 42.71px rgba(0, 0, 0, .03),
        0 100px 117px rgba(0, 0, 0, .04);
}

/* Leaflet draws a small white arrow for tooltips; the design has none. */
.dlm-popup-wrapper.leaflet-tooltip::before {
    display: none;
}

/* The popup controls its position through its offsets; Leaflet's direction margins must
   not shift it. */
.dlm-popup-wrapper.leaflet-tooltip-top,
.dlm-popup-wrapper.leaflet-tooltip-bottom {
    margin-top: 0;
}

.dlm-popup-info {
    flex: 1;
    min-width: 0;
    padding: 15px 0 15px 15px;
}

.dlm-popup-name,
.dlm-popup-status {
    margin: 0;
    font-size: 15px;
    line-height: 24px;
}

.dlm-popup-name {
    font-weight: 700;
}

.dlm-popup-address {
    margin: 0;
    font-size: 14px;
    line-height: 18px;
    color: var(--w-color-neutral-70);
}


.dlm-popup-wrapper,
.dlm-cluster-popup-wrapper {
    --dlm-state-hover: color-mix(in srgb, var(--w-color-anthracite) 10%, transparent);
    --dlm-state-pressed: color-mix(in srgb, var(--w-color-anthracite) 20%, transparent);
}

.dlm-popup-close {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--w-color-anthracite);
    cursor: pointer;
}

.dlm-popup-close-icon {
    display: block;
    width: 24px;
    height: 24px;
    background-color: currentColor;
    -webkit-mask: var(--icon-href) no-repeat center;
    mask: var(--icon-href) no-repeat center;
}

.dlm-popup-close:hover {
    background-image: linear-gradient(var(--dlm-state-hover), var(--dlm-state-hover));
}

.dlm-popup-close:active {
    background-image: linear-gradient(var(--dlm-state-pressed), var(--dlm-state-pressed));
}

.dlm-popup-close:focus-visible {
    outline: 1px solid var(--w-color-anthracite);
    outline-offset: 2px;
}

.dlm-cluster-popup-wrapper .leaflet-popup-content-wrapper {
    border-radius: 0;
    background: var(--w-color-neutral-7);
    color: var(--w-color-anthracite);
}

.dlm-cluster-popup-wrapper .leaflet-popup-tip-container {
    display: none;
}

.dlm-cluster-popup-wrapper .leaflet-popup-content {
    margin: 16px;
    overflow-wrap: anywhere;
    line-height: 24px;
}

/* Leaflet renders the cluster popup's own close button; style it as the same
   tertiary "button" design as the device popup close button. The '×' glyph is
   replaced by the masked close icon so both popups show the identical control. */
.dlm-cluster-popup-wrapper a.leaflet-popup-close-button {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    color: var(--w-color-anthracite);
    font-size: 0;
}

/* The icon URL has its single source in device-location-map.js (CLOSE_ICON_URL); the
   JS sets --icon-href on the popup element, same convention as the device popup. */
.dlm-cluster-popup-wrapper a.leaflet-popup-close-button::before {
    content: "";
    display: block;
    width: 24px;
    height: 24px;
    background-color: currentColor;
    -webkit-mask: var(--icon-href) no-repeat center;
    mask: var(--icon-href) no-repeat center;
}

.dlm-cluster-popup-wrapper a.leaflet-popup-close-button:hover {
    color: var(--w-color-anthracite);
    background-image: linear-gradient(var(--dlm-state-hover), var(--dlm-state-hover));
}

.dlm-cluster-popup-wrapper a.leaflet-popup-close-button:active {
    background-image: linear-gradient(var(--dlm-state-pressed), var(--dlm-state-pressed));
}

.dlm-cluster-popup-wrapper a.leaflet-popup-close-button:focus-visible {
    outline: 1px solid var(--w-color-anthracite);
    outline-offset: 2px;
}

.dlm-cluster-popup .dlm-cluster-heading {
    margin: 0 40px 8px 0;
    font-size: 15px;
    font-weight: 700;
}

.dlm-cluster-entries {
    margin: 0;
    padding: 0;
    list-style: none;
    /* The list is the popup's scroll container (capped from device-location-map.js)
       so its scrollbar starts below the heading row, clear of the close button. */
    overflow-y: auto;
}

.dlm-cluster-entry {
    padding: 8px 0;
    border-top: 1px solid var(--w-color-neutral-15);
}

.dlm-cluster-popup .dlm-popup-name,
.dlm-cluster-popup .dlm-popup-address,
.dlm-cluster-popup .dlm-popup-status {
    margin: 0;
}

.dlm-status-indicator {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    box-shadow: none;
}
