/* ====================================================================
   DASHBOARD MINI-MAP WIDGET
   ==================================================================== */

.dashboard-map-card {
    border-radius: 12px;
    overflow: hidden;
}

.dashboard-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.dashboard-map-container {
    position: relative;
    height: 400px;
    min-height: 280px;
    background: #f5f5f5;
}

/* Dashboard Map Canvas - MUST have explicit size for MapLibre */
.dashboard-map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

.dashboard-map-container .maplibregl-map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Dashboard Map Legend */
.dashboard-map-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    border: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 11px;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

.dashboard-map-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.legend-dot.site {
    background: #1976D2;
    transform: rotate(45deg);
    border-radius: 2px;
}

.legend-dot.online {
    background: #4CAF50;
}

.legend-dot.offline {
    background: #F44336;
}

.legend-dot.no-location {
    background: #9E9E9E;
}

/* Dashboard Map Empty State */
.dashboard-map-empty {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    color: #757575;
    text-align: center;
    padding: 24px;
}

.dashboard-map-empty .empty-icon {
    font-size: 48px;
    opacity: 0.5;
    margin-bottom: 12px;
}

.dashboard-map-empty .empty-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #424242;
}

.dashboard-map-empty .empty-text {
    font-size: 13px;
    max-width: 280px;
}

/* Dashboard Map Loading State */
.dashboard-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    z-index: 5;
}

/* Dashboard Map Error State */
.dashboard-map-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    color: #757575;
    text-align: center;
    padding: 24px;
}

.dashboard-map-error .error-icon {
    font-size: 48px;
    color: #F44336;
    opacity: 0.7;
    margin-bottom: 12px;
}

/* Dashboard Map Popup Styling */
.dashboard-popup .maplibregl-popup-content {
    border-radius: 10px !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    overflow: hidden;
    max-width: 280px;
    min-width: 200px;
}

/* Ensure popup stays within map bounds */
.dashboard-popup.maplibregl-popup {
    max-width: calc(100% - 24px) !important;
}

.dashboard-popup .maplibregl-popup-tip {
    border-top-color: white !important;
}

.dashboard-map-popup {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-width: 180px;
    max-width: 260px;
}

.dashboard-map-popup .popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-bottom: 1px solid #eee;
}

.dashboard-map-popup .popup-header.site {
    background: linear-gradient(135deg, #E3F2FD 0%, #fff 100%);
}

.dashboard-map-popup .popup-header.device {
    background: linear-gradient(135deg, #E8F5E9 0%, #fff 100%);
}

.dashboard-map-popup .popup-icon {
    font-size: 16px;
}

.dashboard-map-popup .popup-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.dashboard-map-popup .popup-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(0,0,0,0.02);
}

.dashboard-map-popup .popup-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dashboard-map-popup .popup-details {
    padding: 10px 14px;
}

.dashboard-map-popup .popup-detail {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dashboard-map-popup .popup-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.dashboard-map-popup .popup-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-align: center;
    background: #1976D2;
    color: white;
}

.dashboard-map-popup .popup-btn:hover {
    background: #1565C0;
}

.dashboard-map-popup .popup-btn.outline {
    background: white;
    color: #1976D2;
    border: 1px solid #1976D2;
}

.dashboard-map-popup .popup-btn.outline:hover {
    background: #E3F2FD;
}

.dashboard-map-popup .popup-btn.primary {
    background: #1976D2;
    color: white;
}

.dashboard-map-popup .popup-btn.primary:hover {
    background: #1565C0;
}

/* Dashboard Site Marker */
.dashboard-site-marker {
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: filter 0.15s ease-out;
}

.dashboard-site-marker.marker-hover {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)) brightness(1.1);
}

/* Responsive Dashboard Map */
@media (max-width: 960px) {
    .dashboard-map-container {
        height: 280px;
    }

    .dashboard-map-legend {
        bottom: 8px;
        left: 8px;
        padding: 8px 10px;
        gap: 8px;
        font-size: 10px;
    }
}

/* Dark Mode Support */
.mud-theme-dark .dashboard-map-header {
    background: #1e1e1e;
    border-bottom-color: #333;
    color: #e0e0e0;
}

.mud-theme-dark .dashboard-map-container {
    background: #2d2d2d;
}

.mud-theme-dark .dashboard-map-legend {
    background: rgba(30, 30, 30, 0.95);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.mud-theme-dark .legend-dot {
    border-color: #333;
}

.mud-theme-dark .dashboard-map-empty,
.mud-theme-dark .dashboard-map-loading,
.mud-theme-dark .dashboard-map-error {
    background: #2d2d2d;
    color: #b0b0b0;
}

.mud-theme-dark .dashboard-map-empty .empty-title,
.mud-theme-dark .dashboard-map-error .empty-title {
    color: #e0e0e0;
}

.mud-theme-dark .dashboard-map-popup .popup-header {
    background: linear-gradient(135deg, #2d2d2d 0%, #1e1e1e 100%);
    border-bottom-color: #444;
}

.mud-theme-dark .dashboard-map-popup .popup-header.site {
    background: linear-gradient(135deg, #1a2a3a 0%, #1e1e1e 100%);
}

.mud-theme-dark .dashboard-map-popup .popup-header.device {
    background: linear-gradient(135deg, #1a2e1a 0%, #1e1e1e 100%);
}

.mud-theme-dark .dashboard-map-popup .popup-title {
    color: #e0e0e0;
}

.mud-theme-dark .dashboard-map-popup .popup-status {
    background: rgba(255, 255, 255, 0.04);
}

.mud-theme-dark .dashboard-map-popup .popup-details {
    background: #1e1e1e;
}

.mud-theme-dark .dashboard-map-popup .popup-detail {
    color: #b0b0b0;
}

.mud-theme-dark .dashboard-map-popup .popup-actions {
    background: #2d2d2d;
    border-top-color: #444;
}

.mud-theme-dark .dashboard-map-popup .popup-btn {
    background: #90CAF9;
    color: #1e1e1e;
}

.mud-theme-dark .dashboard-map-popup .popup-btn:hover {
    background: #64B5F6;
}

.mud-theme-dark .dashboard-map-popup .popup-btn.outline {
    background: #1e1e1e;
    color: #90CAF9;
    border-color: #90CAF9;
}

.mud-theme-dark .dashboard-map-popup .popup-btn.outline:hover {
    background: rgba(144, 202, 249, 0.1);
}

.mud-theme-dark .dashboard-popup .maplibregl-popup-content {
    background: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.mud-theme-dark .dashboard-popup .maplibregl-popup-tip {
    border-top-color: #1e1e1e !important;
}

/* Responsive popup for smaller dashboard maps */
@media (max-width: 600px) {
    .dashboard-popup .maplibregl-popup-content {
        max-width: 220px;
        min-width: 160px;
    }

    .dashboard-map-popup .popup-header {
        padding: 10px 12px;
    }

    .dashboard-map-popup .popup-title {
        font-size: 13px;
    }

    .dashboard-map-popup .popup-actions {
        flex-direction: column;
        gap: 6px;
        padding: 8px 12px;
    }

    .dashboard-map-popup .popup-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
}

/* Ensure MapLibre controls don't overlap with popups */
.dashboard-map-container .maplibregl-ctrl-top-right {
    top: 8px;
    right: 8px;
}

/* Hide any marker elements that might appear outside map bounds */
.dashboard-map-container .maplibregl-marker {
    /* Ensure markers are only visible when properly positioned */
    visibility: visible;
}
