/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Map container - full viewport */
#map {
    width: 100%;
    height: 100vh;
    z-index: 1;
}

/* Windows container for camera feeds */
#windows-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Individual camera window */
.camera-window {
    position: absolute;
    width: 400px;
    min-width: 280px;
    min-height: 200px;
    background: #1a1a1a;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    overflow: hidden;
    resize: both;
    display: flex;
    flex-direction: column;
}

/* Window header - draggable area */
.camera-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.camera-window-header.sdot {
    background: linear-gradient(135deg, #2196F3, #1976D2);
}

.camera-window-header.wsdot {
    background: linear-gradient(135deg, #FF9800, #F57C00);
}

.camera-window-title {
    color: white;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.camera-window-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.camera-window-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Window content area */
.camera-window-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #000;
}

/* Video player styles */
.camera-window-content video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Image viewer styles */
.camera-window-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Image timestamp */
.image-timestamp {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
}

/* Error state */
.camera-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    color: #999;
}

.camera-error-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.camera-error-message {
    font-size: 14px;
    margin-bottom: 16px;
}

.camera-retry-btn {
    background: #444;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.camera-retry-btn:hover {
    background: #555;
}

/* Loading state */
.camera-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.camera-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #333;
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Custom marker styles */
.camera-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.camera-marker:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.camera-marker.sdot {
    background: #2196F3;
}

.camera-marker.wsdot {
    background: #FF9800;
}

/* Active marker state (window is open) */
.camera-marker.active {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.6);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(33, 150, 243, 0);
    }
}

.camera-marker.wsdot.active {
    animation: pulse-orange 1.5s ease-in-out infinite;
}

@keyframes pulse-orange {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 152, 0, 0);
    }
}

/* Legend styles */
#legend {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-size: 13px;
}

#legend h4 {
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 6px 0;
    color: #666;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.legend-dot.sdot {
    background: #2196F3;
}

.legend-dot.wsdot {
    background: #FF9800;
}

/* Leaflet tooltip customization */
.leaflet-tooltip {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 4px;
    color: white;
    padding: 6px 10px;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before,
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before {
    border-color: transparent;
}

/* Marker cluster customization */
.marker-cluster {
    background: rgba(33, 150, 243, 0.3);
}

.marker-cluster div {
    background: rgba(33, 150, 243, 0.8);
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.marker-cluster-small {
    background: rgba(33, 150, 243, 0.3);
}

.marker-cluster-small div {
    background: rgba(33, 150, 243, 0.7);
}

.marker-cluster-medium {
    background: rgba(33, 150, 243, 0.4);
}

.marker-cluster-medium div {
    background: rgba(33, 150, 243, 0.8);
}

.marker-cluster-large {
    background: rgba(33, 150, 243, 0.5);
}

.marker-cluster-large div {
    background: rgba(33, 150, 243, 0.9);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .camera-window {
        width: 320px;
        min-width: 260px;
    }

    #legend {
        bottom: 10px;
        left: 10px;
        padding: 10px 12px;
        font-size: 12px;
    }
}
