/* Shared styles for the KMZ/KML unit-layer overlay.
   Loaded globally so labels + toolbar render consistently on every Leaflet
   instance (full table map, minimap preview, future maps). */

/* ─── Permanent placemark labels ────────────────────────────────────────
   White bold text, no chip background, no directional arrow. The compound
   selector covers Leaflet's directional variants (top/bottom/left/right)
   which carry their own bg + arrow rules at higher specificity. */
.leaflet-tooltip.map-layer-label,
.leaflet-tooltip-top.map-layer-label,
.leaflet-tooltip-bottom.map-layer-label,
.leaflet-tooltip-left.map-layer-label,
.leaflet-tooltip-right.map-layer-label {
    background: transparent !important;
    background-color: transparent !important;
    border: 0 none transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    text-shadow:
        0 0 2px rgba(0, 0, 0, 0.95),
        0 0 4px rgba(0, 0, 0, 0.85),
        0 1px 2px rgba(0, 0, 0, 0.9) !important;
    pointer-events: none;
    white-space: nowrap;
}
.leaflet-tooltip.map-layer-label::before,
.leaflet-tooltip-top.map-layer-label::before,
.leaflet-tooltip-bottom.map-layer-label::before,
.leaflet-tooltip-left.map-layer-label::before,
.leaflet-tooltip-right.map-layer-label::before {
    display: none !important;
    border: 0 none transparent !important;
    background: transparent !important;
}

/* ─── On-map layers toolbar (button + popover panel) ──────────────────── */
/* z-index 1100 sits above Leaflet's tile pane (200), overlay/marker panes
   (400/600), tooltip pane (650) and the .leaflet-top/.leaflet-bottom control
   container (1000). */
/* ─── Canonical map control chrome ──────────────────────────────────────
   ONE source of truth for every floating map control across the app
   (fullscreen, search, layers, coordinate tools, zoom, photo mode, …).
   The look is defined by the --map-ctrl-* tokens below — the translucent
   dark strip matching the restyled attribution/zoom badge. ANY new on-map
   button must use `.map-ctrl-btn` (or these tokens), never ad-hoc colors. */
:root {
    --map-ctrl-bg: rgb(17 24 39 / 0.78);
    --map-ctrl-bg-hover: rgb(17 24 39 / 0.94);
    --map-ctrl-border: rgb(55 65 81 / 0.35);
    --map-ctrl-fg: #d1d5db;
    --map-ctrl-fg-hover: #fff;
}
.map-ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background-color: var(--map-ctrl-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--map-ctrl-border);
    color: var(--map-ctrl-fg);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.map-ctrl-btn:hover {
    background-color: var(--map-ctrl-bg-hover);
    border-color: rgb(55 65 81 / 0.6);
    color: var(--map-ctrl-fg-hover);
}
.map-ctrl-btn.active {
    background-color: color-mix(in srgb, rgb(59 130 246) 22%, rgb(17 24 39));
    border-color: transparent;
    color: #fff;
}
.map-ctrl-btn svg { width: 18px; height: 18px; display: block; }

/* Circular variant — e.g. the photo-mode exit X. */
.map-ctrl-btn--round { width: 44px; height: 44px; border-radius: 9999px; }

/* Popover panel that pairs with map controls (search box, layers list). */
.map-ctrl-panel {
    background-color: rgb(17 24 39 / 0.94);
    backdrop-filter: blur(12px);
    border: 1px solid var(--map-ctrl-border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* The KMZ/KML layers toggle IS the shared .map-ctrl-btn (added in the partial);
   this rule only positions it. All look/size/hover/active come from the
   component so every on-map button matches everywhere. */
.map-layers-toggle {
    position: absolute;
    top: 110px;
    right: 10px;
    z-index: 1100 !important;
}

.map-layers-panel {
    position: absolute;
    top: 110px;
    right: 60px;
    z-index: 1100 !important;
    background-color: rgb(17 24 39 / 0.94);
    backdrop-filter: blur(12px);
    border: 1px solid var(--map-ctrl-border);
    border-radius: 0.75rem;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    min-width: 240px;
    max-width: 320px;
    max-height: 60vh;
    overflow-y: auto;
}
.map-layers-panel.hidden { display: none; }

/* Minimap modal hosts a smaller variant — pin to the map container, not the page. */
.map-layers-toggle--minimap { top: 12px; right: 12px; }
.map-layers-panel--minimap { top: 12px; right: 60px; }

/* Enemy-target track map: sit just below the fullscreen control (top-2, 38px). */
.map-layers-toggle--target { top: 52px; right: 8px; }
.map-layers-panel--target { top: 52px; right: 56px; }

.map-layer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}
.map-layer-row .layer-name {
    color: #e5e7eb;
    font-size: 0.8125rem;
    line-height: 1.2;
    min-width: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Shared Leaflet control styling (zoom +/-, popups) ────────────────
   Lives here so every map (table view, minimap, future) gets the same look. */
.leaflet-control-zoom { border: none !important; box-shadow: none !important; }

.leaflet-control-zoom a {
    background-color: var(--map-ctrl-bg) !important;
    backdrop-filter: blur(8px) !important;
    border: 1px solid var(--map-ctrl-border) !important;
    color: var(--map-ctrl-fg) !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 28px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: 0.5rem !important;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    margin-bottom: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}
.leaflet-control-zoom a:hover {
    background-color: var(--map-ctrl-bg-hover) !important;
    border-color: rgb(55 65 81 / 0.6) !important;
    color: var(--map-ctrl-fg-hover) !important;
}
.leaflet-control-zoom-in,
.leaflet-control-zoom-out { text-shadow: none !important; }

/* ─── Attribution — match the app's dark chrome ───────────────────────── */
.leaflet-control-attribution {
    background: rgb(17 24 39 / 0.75) !important;
    backdrop-filter: blur(8px);
    color: #6b7280 !important;
    font-size: 10px !important;
    padding: 2px 6px !important;
    border-radius: 6px 0 0 0;
}
.leaflet-control-attribution a {
    color: #9ca3af !important;
}

/* ─── Current-zoom badge (bottom-left, click to type a zoom level) ────── */
/* Same visual language as the restyled .leaflet-control-attribution below it:
   translucent dark strip, muted gray text — just slightly larger and clickable. */
.map-zoom-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgb(17 24 39 / 0.75);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    padding: 2px 8px;
    color: #9ca3af;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    user-select: none;
    margin-bottom: 2px !important;
    transition: color .15s ease, background-color .15s ease;
}
.map-zoom-badge:hover {
    background: rgb(17 24 39 / 0.9);
    color: #e5e7eb;
}
.map-zoom-badge .mzb-prefix {
    color: #6b7280;
    font-size: 10px;
}
.map-zoom-badge .mzb-input {
    width: 46px;
    background: rgb(17 24 39 / 0.6);
    border: 1px solid rgb(59 130 246 / 0.5);
    border-radius: 5px;
    color: #fff;
    font-size: 12px;
    padding: 0 5px;
    outline: none;
    -moz-appearance: textfield;
}
.map-zoom-badge .mzb-input::-webkit-outer-spin-button,
.map-zoom-badge .mzb-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.map-zoom-badge .hidden { display: none; }

/* ─── Coordinate popup (feature popups + click-anywhere MGRS) ─────────── */
.coord-popup .leaflet-popup-content-wrapper {
    background: rgb(31 41 55 / 0.97);
    border: 1px solid rgb(55 65 81 / 0.6);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.6), 0 4px 10px -4px rgb(0 0 0 / 0.4);
    overflow: hidden;
}
/* Pages (map-view.css, extractor results) force margin/padding 0 !important
   on .leaflet-popup-content — so spacing lives on the inner .map-coord-popup
   div, where no Leaflet-generic override can strip it. */
.coord-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    color: #e5e7eb;
    font-family: inherit;
    line-height: 1.4;
}
.coord-popup .leaflet-popup-tip {
    background: rgb(31 41 55 / 0.97);
    border: 1px solid rgb(55 65 81 / 0.6);
}
.coord-popup .leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    width: 22px !important;
    height: 22px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9ca3af !important;
    font-size: 16px !important;
    line-height: 1 !important;
    padding: 0 !important;
    transition: color .15s ease, background .15s ease;
}
.coord-popup .leaflet-popup-close-button:hover {
    color: #fff !important;
    background: rgb(255 255 255 / 0.08);
}
/* All spacing lives here (see note above); extra right padding keeps every
   line clear of the absolute close button. */
.map-coord-popup {
    min-width: 180px;
    padding: 13px 36px 13px 16px;
}
.map-coord-popup .mcp-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}
.map-coord-popup .mcp-desc {
    font-size: 12.5px;
    color: #9ca3af;
    margin-bottom: 6px;
}
.map-coord-popup .mcp-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}
.map-coord-popup .mcp-row svg {
    width: 13px;
    height: 13px;
    color: #9ca3af;
    flex-shrink: 0;
}
/* Flat click-to-copy coordinate — field-copy.js adds the green + badge on
   hover and the copy-on-click, same as detail-modal fields. */
.map-coord-popup .mcp-coord {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12.5px;
    color: #d1d5db;
    white-space: nowrap;
    cursor: pointer;
    transition: color .15s ease;
}
.map-coord-popup .mcp-coord:hover {
    color: #fff;
}
