/* ==========================================================================
   Uzbekistan regional PBX monitoring map (GeoJSON + D3) - dark theme
   ========================================================================== */

.uzb-map {
    --uzb-online: #10b981;
    --uzb-warning: #f59e0b;
    --uzb-offline: #ef4444;
    --uzb-nodata: #334155;
    position: relative;
    background: var(--bg-dark, #0f172a);
    border: 1px solid var(--border-color, #1e293b);
    border-radius: 16px;
    padding: 20px;
    color: var(--text-primary, #f8fafc);
}

.uzb-map__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 14px;
}

.uzb-map__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary, #f8fafc);
}
.uzb-map__title i { color: #0d9488; }

.uzb-map__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.8rem;
    color: #94a3b8;
}
.uzb-map__legend-item { display: inline-flex; align-items: center; gap: 6px; }
.uzb-map__dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.uzb-map__dot--online { background: var(--uzb-online); }
.uzb-map__dot--warning { background: var(--uzb-warning); }
.uzb-map__dot--offline { background: var(--uzb-offline); }
.uzb-map__dot--no_data { background: var(--uzb-nodata); border: 1px solid #64748b; }

/* Stage: the SVG always fits inside this box */
.uzb-map__stage {
    position: relative;
    width: 100%;
    height: clamp(320px, 52vw, 600px);
    overflow: hidden;
    border-radius: 12px;
    background: radial-gradient(ellipse at 50% 45%, #111c33 0%, #0b1220 70%);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.uzb-map__svg {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.uzb-map__svg:active { cursor: grabbing; }

/* Regions ---------------------------------------------------------------- */
.uzb-region {
    fill: var(--uzb-nodata);
    fill-opacity: 0.72;
    stroke: rgba(255, 255, 255, 0.55);
    stroke-width: 1px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    outline: none;
    transition: fill 0.35s ease, fill-opacity 0.2s ease;
}
.uzb-region[data-status="online"]  { fill: var(--uzb-online); }
.uzb-region[data-status="warning"] { fill: var(--uzb-warning); }
.uzb-region[data-status="offline"] { fill: var(--uzb-offline); }
.uzb-region[data-status="no_data"],
.uzb-region[data-status="unknown"] { fill: var(--uzb-nodata); }

.uzb-region:hover,
.uzb-region:focus-visible { fill-opacity: 0.95; }

/* Hover / focus outline drawn on top so neighbours never cover it */
.uzb-highlight {
    fill: rgba(255, 255, 255, 0.08);
    stroke: #ffffff;
    stroke-width: 2px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
    opacity: 0;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.55));
    transition: opacity 0.18s ease;
}
.uzb-highlight.is-active { opacity: 1; }

/* Tashkent city: own layer, stronger outline + ring so it stays visible at country scale */
.uzb-region--city { stroke: #ffffff; stroke-width: 1.6px; fill-opacity: 0.95; }
.uzb-city-ring {
    fill: transparent;
    stroke: #ffffff;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: opacity 0.25s ease;
}
.uzb-city-ring.is-hidden { opacity: 0; pointer-events: none; }

/* Labels (screen-space, never scaled) ------------------------------------ */
.uzb-label {
    fill: #f8fafc;
    font-family: inherit;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(11, 18, 32, 0.9);
    stroke-width: 3px;
    stroke-linejoin: round;
    transition: opacity 0.2s ease;
}
.uzb-label.is-hidden { opacity: 0; }
.uzb-label--city { text-anchor: end; fill: #ffffff; font-weight: 800; }
.uzb-leader {
    fill: none;
    stroke: rgba(255, 255, 255, 0.85);
    stroke-width: 1px;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Controls ---------------------------------------------------------------- */
.uzb-map__controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}
.uzb-map__btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    font-size: 0.95rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.uzb-map__btn:hover { background: rgba(30, 41, 59, 0.95); border-color: rgba(255, 255, 255, 0.35); }
.uzb-map__btn:focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; }

.uzb-map__hint {
    position: absolute;
    left: 12px;
    bottom: 10px;
    font-size: 0.72rem;
    color: #64748b;
    pointer-events: none;
    z-index: 2;
}

/* Loading / error overlay ------------------------------------------------- */
.uzb-map__state {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    max-width: calc(100% - 100px);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #cbd5e1;
    z-index: 4;
    display: none;
    align-items: center;
    gap: 10px;
}
.uzb-map__state.is-visible { display: inline-flex; }
.uzb-map__state.is-error { border-color: rgba(239, 68, 68, 0.5); color: #fecaca; }
.uzb-map__state button {
    background: none;
    border: 1px solid currentColor;
    color: inherit;
    border-radius: 999px;
    padding: 2px 10px;
    cursor: pointer;
    font-size: 0.75rem;
}

/* Tooltip ----------------------------------------------------------------- */
.uzb-map__tooltip {
    position: absolute;
    left: 0;
    top: 0;
    min-width: 230px;
    max-width: 280px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    font-size: 0.85rem;
    line-height: 1.5;
    color: #ffffff;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.uzb-map__tooltip.is-visible { opacity: 1; visibility: visible; transform: none; }

.uzb-tip__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1rem;
    font-weight: 700;
    color: #38bdf8;
}
.uzb-tip__badge {
    flex: none;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #0b1220;
    background: var(--uzb-nodata);
}
.uzb-tip__badge[data-status="online"]  { background: var(--uzb-online); }
.uzb-tip__badge[data-status="warning"] { background: var(--uzb-warning); }
.uzb-tip__badge[data-status="offline"] { background: var(--uzb-offline); }
.uzb-tip__badge[data-status="no_data"],
.uzb-tip__badge[data-status="unknown"] { background: #64748b; color: #fff; }

.uzb-tip__row { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 3px; }
.uzb-tip__row span { color: #94a3b8; }
.uzb-tip__row strong { color: #ffffff; font-variant-numeric: tabular-nums; }
.uzb-tip__row strong.is-ok { color: #22c55e; }
.uzb-tip__row strong.is-bad { color: #ef4444; }
.uzb-tip__row strong.is-accent { color: #38bdf8; }
.uzb-tip__note { margin-top: 6px; font-size: 0.75rem; color: #94a3b8; }

/* Footer ------------------------------------------------------------------ */
.uzb-map__footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 10px;
    font-size: 0.76rem;
    color: #64748b;
}
.uzb-map__unassigned { color: #f59e0b; }

@media (max-width: 640px) {
    .uzb-map { padding: 12px; }
    .uzb-map__title { font-size: 0.98rem; }
    .uzb-map__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .uzb-region, .uzb-highlight, .uzb-label, .uzb-leader, .uzb-map__tooltip { transition: none; }
}
