/* OMC Map — Leaflet dark theme, matches app palette */

:root {
    --omc-map-bg: #0f172a;
    --omc-map-panel: #1e293b;
    --omc-map-border: #334155;
    --omc-map-text: #e2e8f0;
    --omc-map-muted: #94a3b8;
    --omc-map-accent: #3b82f6;
    --omc-map-success: #22c55e;
    --omc-map-danger: #ef4444;
    --omc-map-warning: #f59e0b;
}

.omc-map-page {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--omc-map-bg);
    z-index: 1030;
    display: flex;
    flex-direction: column;
}

.omc-map-header {
    padding: 10px 18px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.85));
    border-bottom: 1px solid var(--omc-map-border);
    color: var(--omc-map-text);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    backdrop-filter: blur(6px);
    z-index: 1050;
}

.omc-map-header .title {
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.omc-map-header .sub {
    color: var(--omc-map-muted);
    font-size: 0.82rem;
}

/* Header buttons — override bootstrap outline-light that disappears on dark bg */
.omc-map-header .btn-outline-light {
    color: var(--omc-map-text);
    border-color: var(--omc-map-border);
    background: rgba(51, 65, 85, 0.45);
}
.omc-map-header .btn-outline-light:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--omc-map-accent);
    color: #fff;
}

.omc-map-container {
    flex: 1;
    position: relative;
    background: var(--omc-map-bg);
}

#omc-map {
    width: 100%;
    height: 100%;
}

/* Tile CSS filter — makes standard OSM tiles look dark */
.omc-map-tiles-filtered {
    filter: brightness(0.65) invert(1) contrast(0.9) hue-rotate(200deg) saturate(0.45) brightness(0.95);
}

/* Leaflet control overrides */
.leaflet-container {
    background: var(--omc-map-bg) !important;
    font-family: inherit;
}

.leaflet-control-zoom a,
.leaflet-bar a {
    background-color: var(--omc-map-panel) !important;
    color: var(--omc-map-text) !important;
    border-color: var(--omc-map-border) !important;
    transition: all 0.15s ease;
}

.leaflet-control-zoom a:hover,
.leaflet-bar a:hover {
    background-color: var(--omc-map-border) !important;
    color: #fff !important;
}

.leaflet-bar {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid var(--omc-map-border) !important;
}

.leaflet-control-attribution {
    background: rgba(15, 23, 42, 0.85) !important;
    color: var(--omc-map-muted) !important;
    font-size: 0.7rem !important;
    padding: 2px 8px !important;
    border-top-left-radius: 4px;
    border: 1px solid var(--omc-map-border);
    border-bottom: 0; border-right: 0;
}

.leaflet-control-attribution a {
    color: var(--omc-map-accent) !important;
}

/* Popup dark */
.leaflet-popup-content-wrapper {
    background: var(--omc-map-panel) !important;
    color: var(--omc-map-text) !important;
    border: 1px solid var(--omc-map-border) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
    border-radius: 10px !important;
}

.leaflet-popup-tip {
    background: var(--omc-map-panel) !important;
    border: 1px solid var(--omc-map-border) !important;
}

.leaflet-popup-close-button {
    color: var(--omc-map-muted) !important;
    font-size: 18px !important;
    line-height: 1 !important;
    padding: 4px !important;
    width: 22px !important;
    height: 22px !important;
    top: 6px !important;
    right: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.leaflet-popup-content {
    margin: 14px 26px 14px 14px !important;
}

.leaflet-popup-close-button:hover {
    color: var(--omc-map-text) !important;
}

.omc-popup {
    min-width: 200px;
}

.omc-popup .omc-popup-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: #fff;
}

.omc-popup .omc-popup-sub {
    color: var(--omc-map-muted);
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.omc-popup .omc-popup-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.82rem;
    border-top: 1px solid var(--omc-map-border);
}

.omc-popup .omc-popup-row:first-of-type {
    border-top: 0;
}

.omc-popup .omc-popup-key {
    color: var(--omc-map-muted);
}

.omc-popup .omc-popup-value {
    color: var(--omc-map-text);
    font-weight: 500;
}

.omc-popup .omc-popup-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    background: var(--omc-map-accent);
    color: #fff !important;
    border-radius: 6px;
    text-decoration: none !important;
    font-size: 0.8rem;
    transition: background 0.15s;
}

.omc-popup .omc-popup-btn:hover {
    background: #2563eb;
}

/* Custom marker (divIcon) */
.omc-marker {
    position: relative;
    width: 36px;
    height: 46px;
    cursor: pointer;
    transform: translate(-50%, -100%);
    left: 50%; top: 50%;
}

.omc-marker-body {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--omc-map-accent), #1d4ed8);
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.omc-marker-body i {
    transform: rotate(45deg);
    color: #fff;
    font-size: 14px;
}

.omc-marker.online .omc-marker-body {
    background: linear-gradient(135deg, #22c55e, #15803d);
}

.omc-marker.offline .omc-marker-body {
    background: linear-gradient(135deg, #64748b, #334155);
}

.omc-marker.alarm .omc-marker-body {
    background: linear-gradient(135deg, #ef4444, #991b1b);
}

.omc-marker:hover .omc-marker-body {
    transform: rotate(-45deg) scale(1.15);
}

/* Pulsing halo for live (online) marker */
.omc-marker.online::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.5);
    animation: omc-pulse 2s ease-out infinite;
    z-index: -1;
}

@keyframes omc-pulse {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}

.omc-marker-label {
    position: absolute;
    top: -4px;
    left: 100%;
    margin-left: 6px;
    background: var(--omc-map-panel);
    color: var(--omc-map-text);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    border: 1px solid var(--omc-map-border);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.omc-marker:hover .omc-marker-label {
    opacity: 1;
}

/* Route waypoint dot */
.omc-waypoint {
    width: 10px; height: 10px;
    background: var(--omc-map-accent);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
    transform: translate(-50%, -50%);
}

.omc-waypoint.long {
    background: var(--omc-map-warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.omc-waypoint.start {
    width: 14px; height: 14px;
    background: var(--omc-map-success);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.8);
}

.omc-waypoint.end {
    width: 14px; height: 14px;
    background: var(--omc-map-danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

/* Floating info panel (top-right) */
.omc-map-info-panel {
    position: absolute;
    top: 18px;
    right: 18px;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--omc-map-border);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--omc-map-text);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    z-index: 1000;
    min-width: 220px;
    font-size: 0.85rem;
}

.omc-map-info-panel .info-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: #fff;
}

.omc-map-info-panel .info-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-top: 1px solid var(--omc-map-border);
}

.omc-map-info-panel .info-row:first-of-type {
    border-top: 0;
}

.omc-map-info-panel .info-key {
    color: var(--omc-map-muted);
}

/* Floating control panel (top-left under zoom) */
.omc-map-controls {
    position: absolute;
    top: 18px;
    left: 60px;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--omc-map-border);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    z-index: 1000;
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.omc-map-controls .btn-group-sm .btn {
    font-size: 0.78rem;
    padding: 3px 10px;
    background: transparent;
    border: 1px solid var(--omc-map-border);
    color: var(--omc-map-text);
}

.omc-map-controls .btn-group-sm .btn:hover {
    background: var(--omc-map-border);
    color: #fff;
}

.omc-map-controls .btn-group-sm .btn.active {
    background: var(--omc-map-accent);
    border-color: var(--omc-map-accent);
    color: #fff;
}

.omc-map-controls select,
.omc-map-controls input[type="datetime-local"] {
    background: var(--omc-map-bg);
    border: 1px solid var(--omc-map-border);
    color: var(--omc-map-text);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.78rem;
}

.omc-map-controls select:focus,
.omc-map-controls input:focus {
    outline: none;
    border-color: var(--omc-map-accent);
}

/* Marker cluster */
.omc-cluster {
    background: rgba(59, 130, 246, 0.25);
    border: 2px solid var(--omc-map-accent);
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
}

/* Loading overlay */
.omc-map-loading {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(4px);
}

.omc-map-loading .spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--omc-map-border);
    border-top-color: var(--omc-map-accent);
    border-radius: 50%;
    animation: omc-spin 0.9s linear infinite;
}

@keyframes omc-spin {
    to { transform: rotate(360deg); }
}

.omc-map-empty {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--omc-map-muted);
    text-align: center;
    font-size: 0.9rem;
    background: rgba(30, 41, 59, 0.85);
    padding: 24px 32px;
    border: 1px solid var(--omc-map-border);
    border-radius: 10px;
    backdrop-filter: blur(6px);
    max-width: 400px;
}

.omc-map-empty i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
    color: var(--omc-map-accent);
}
