/* ===== MODERN MARKER PIN STYLES ===== */
.custom-marker-icon {
    background: none !important;
    border: none !important;
}

.device-marker-pin {
    position: relative;
    width: 30px;
    height: 42px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
    transition: all 0.2s ease;
    cursor: pointer;
}

.device-marker-pin:hover {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}

.device-marker-pin .pin-head {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: translateX(-50%) rotate(-45deg);
    border: 3px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.device-marker-pin .pin-point {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 12px solid;
}

/* Pin colors by status */
.device-marker-pin.ok .pin-head {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.device-marker-pin.ok .pin-point {
    border-top-color: #059669;
}

.device-marker-pin.warning .pin-head {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.device-marker-pin.warning .pin-point {
    border-top-color: #d97706;
}

.device-marker-pin.critical .pin-head {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: pulse-critical 2s ease-in-out infinite;
}

.device-marker-pin.critical .pin-point {
    border-top-color: #dc2626;
}

@keyframes pulse-critical {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ===== CLUSTER STYLES ===== */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.marker-cluster:hover {
    transform: scale(1.1);
}

.marker-cluster div {
    width: 40px;
    height: 40px;
    text-align: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Cluster colors by worst status */
.marker-cluster-ok div {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3), 0 4px 12px rgba(16, 185, 129, 0.4);
}

.marker-cluster-warning div {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.3), 0 4px 12px rgba(245, 158, 11, 0.4);
}

.marker-cluster-critical div {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3), 0 4px 12px rgba(239, 68, 68, 0.4);
    animation: pulse-cluster 2s ease-in-out infinite;
}

@keyframes pulse-cluster {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3), 0 4px 12px rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.2), 0 4px 16px rgba(239, 68, 68, 0.6);
    }
}

/* ===== TOOLTIP STYLES ===== */
.device-tooltip {
    background-color: rgba(30, 41, 59, 0.95) !important;
    border: 2px solid #475569 !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    color: #f1f5f9 !important;
    white-space: nowrap !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8) !important;
}

.device-tooltip.ok {
    border-color: #10b981 !important;
}

.device-tooltip.warning {
    border-color: #f59e0b !important;
}

.device-tooltip.critical {
    border-color: #ef4444 !important;
}

.device-tooltip:before {
    border-top-color: rgba(30, 41, 59, 0.95) !important;
}

/* ===== POPUP STYLES ===== */
.device-popup .leaflet-popup-content-wrapper {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #334155;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    padding: 0;
}

.device-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
    color: #f1f5f9;
    min-width: 280px;
}

.device-popup .leaflet-popup-tip {
    background: #1e293b;
    border: 2px solid #334155;
    border-top: none;
    border-right: none;
}

.device-popup-content {
    padding: 18px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #334155;
}

.device-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #f1f5f9;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.status-badge.ok {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.3) 100%);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-badge.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.3) 100%);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-badge.critical {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.3) 100%);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.popup-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    padding: 4px 0;
}

.detail-label {
    font-weight: 600;
    color: #94a3b8;
    min-width: 80px;
}

.detail-value {
    color: #f1f5f9;
    text-align: right;
    font-weight: 500;
    max-width: 180px;
    word-break: break-word;
}

/* ===== POPUP NOTES STYLES ===== */
.popup-notes {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #334155;
}

.notes-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 700;
    color: #f1f5f9;
    font-size: 0.9rem;
}

.notes-icon {
    font-size: 1rem;
}

.notes-title {
    color: #f1f5f9;
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.note-item {
    background: rgba(51, 65, 85, 0.5);
    border-left: 3px solid #60a5fa;
    border-radius: 4px;
    padding: 10px;
}

.note-text {
    color: #f1f5f9;
    font-size: 0.875rem;
    line-height: 1.4;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.note-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.75rem;
}

.note-author {
    color: #94a3b8;
    font-weight: 600;
}

.note-date {
    color: #64748b;
}

/* ===== MAP CONTAINER STYLES ===== */
.leaflet-container {
    background-color: #0f172a;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.leaflet-control-zoom a {
    background-color: rgba(30, 41, 59, 0.95);
    border: 2px solid #334155;
    color: #f1f5f9;
    font-weight: 700;
    transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
    background-color: #334155;
    border-color: #475569;
}

.leaflet-control-attribution {
    background-color: rgba(30, 41, 59, 0.9);
    color: #cbd5e1;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.7rem;
}

.leaflet-control-attribution a {
    color: #60a5fa;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .device-popup-content {
        padding: 14px;
    }

    .device-name {
        font-size: 1rem;
        max-width: 140px;
    }

    .detail-row {
        font-size: 0.8rem;
    }

    .detail-label {
        min-width: 70px;
    }

    .detail-value {
        max-width: 140px;
    }

    .device-tooltip {
        font-size: 0.7rem !important;
        padding: 4px 8px !important;
    }
}

/* ===== SPIDERFY LINES STYLING ===== */
.leaflet-oldie .marker-cluster-small {
    background-color: rgba(16, 185, 129, 0.6);
}

.leaflet-oldie .marker-cluster-small div {
    background-color: rgba(5, 150, 105, 0.8);
}

.leaflet-oldie .marker-cluster-medium {
    background-color: rgba(245, 158, 11, 0.6);
}

.leaflet-oldie .marker-cluster-medium div {
    background-color: rgba(217, 119, 6, 0.8);
}

.leaflet-oldie .marker-cluster-large {
    background-color: rgba(239, 68, 68, 0.6);
}

.leaflet-oldie .marker-cluster-large div {
    background-color: rgba(220, 38, 38, 0.8);
}

/* Customize spiderfy lines */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

/* ===== FULLSCREEN MAP STYLES ===== */
#device-map.map-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
}

/* Fullscreen mode background */
#device-map:fullscreen {
    background-color: #0f172a;
}

#device-map:-webkit-full-screen {
    background-color: #0f172a;
}

#device-map:-moz-full-screen {
    background-color: #0f172a;
}

#device-map:-ms-fullscreen {
    background-color: #0f172a;
}

/* ===== EXIT FULLSCREEN BUTTON ===== */
.exit-fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: none;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    gap: 8px;
    align-items: center;
}

.exit-fullscreen-btn:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(185, 28, 28, 0.95) 100%);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.5);
}

.exit-fullscreen-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.exit-fullscreen-btn .oi {
    margin-right: 6px;
    font-size: 0.85rem;
}

/* Show exit button only in fullscreen mode */
#device-map.map-fullscreen .exit-fullscreen-btn,
#device-map:fullscreen .exit-fullscreen-btn,
#device-map:-webkit-full-screen .exit-fullscreen-btn,
#device-map:-moz-full-screen .exit-fullscreen-btn,
#device-map:-ms-fullscreen .exit-fullscreen-btn {
    display: inline-flex;
}

/* Responsive styling for exit button */
@media (max-width: 768px) {
    .exit-fullscreen-btn {
        top: 10px;
        right: 10px;
        padding: 10px 16px;
        font-size: 0.8rem;
    }
}
