/**
 * Dashboard Dark Mode - Fullscreen Map + Floating Popup Layout
 * KT 관리자 화면 벤치마킹: 전체화면 지도 + 플로팅 팝업
 */

/* ============================================================================
   Fullscreen Map Container
   ============================================================================ */
.fullscreen-map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 115px);  /* 헤더60px + 네비55px */
    padding: 0;
    margin: 0;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ============================================================================
   Floating Popup (플로팅 팝업 - KT 스타일)
   ============================================================================ */
.floating-popup {
    position: absolute;
    background: rgba(45, 45, 45, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
    backdrop-filter: blur(10px);
    transition: all var(--transition-medium);
}

.floating-popup.large {
    min-width: 350px;
    max-width: 450px;
}

.floating-popup.hidden {
    display: none;
}

/* ============================================================================
   Popup Header
   ============================================================================ */
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(58, 58, 58, 0.8);
    border-radius: 8px 8px 0 0;
}

.popup-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.popup-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

/* ============================================================================
   Popup Body
   ============================================================================ */
.popup-body {
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.4;
    max-height: 500px;
    overflow-y: auto;
}

.popup-body::-webkit-scrollbar {
    width: 6px;
}

.popup-body::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

/* ============================================================================
   Stats Popup (전체 디바이스 통계)
   ============================================================================ */
.stat-row {
    padding: 0.25rem 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(74, 74, 74, 0.3);
    font-size: 0.7rem;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.65rem;
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.65rem;
}

.stat-value.critical {
    color: var(--danger-color);
}

.stat-value.high {
    color: var(--high-color);
}

.stat-value.warning {
    color: var(--warning-color);
}

.stat-value.success {
    color: var(--success-color);
}

/* ============================================================================
   Issues Popup (실시간 이슈현황)
   ============================================================================ */
.issue-item {
    padding: 0.3rem;
    margin-bottom: 0.25rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 2px solid var(--danger-color);
    font-size: 0.65rem;
}

.issue-item:last-child {
    margin-bottom: 0;
}

.issue-item.no-issue {
    border-left-color: var(--success-color);
    text-align: center;
    color: var(--success-color);
}

.issue-device {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.2rem;
}

.issue-error {
    color: var(--danger-color);
    font-size: 0.75rem;
    display: block;
}

.issue-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    display: block;
    margin-top: 0.2rem;
}

/* ============================================================================
   Device Detail Popup (디바이스 상세정보)
   ============================================================================ */
.detail-section {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(74, 74, 74, 0.3);
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.3rem;
    font-size: 0.7rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.15rem 0;
    font-size: 0.7rem;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 0.65rem;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.65rem;
}

/* ============================================================================
   Top Right Toggle Buttons (우측 상단 토글 버튼)
   ============================================================================ */
.top-right-buttons {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 0.5rem;
    z-index: 1000;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    background: rgba(45, 45, 45, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.toggle-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================================================
   Leaflet Map Dark Theme
   ============================================================================ */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
}

.leaflet-container a {
    color: var(--primary-color);
}

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

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

/* Custom Marker Styles */
.device-marker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.device-marker:hover {
    transform: scale(1.2);
    z-index: 1000;
}

.device-marker.risk-critical {
    background: var(--danger-color);
}

.device-marker.risk-high {
    background: var(--high-color);
}

.device-marker.risk-medium {
    background: var(--warning-color);
}

.device-marker.risk-low {
    background: var(--success-color);
}

/* Region Tooltip */
.region-tooltip {
    background: rgba(6, 182, 212, 0.9) !important;
    border: 1px solid rgba(6, 182, 212, 1) !important;
    color: white !important;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
    .floating-popup {
        max-width: 90%;
        left: 5% !important;
        right: auto !important;
    }

    .floating-popup.large {
        bottom: 5px !important;
        left: 5% !important;
        right: 5% !important;
        max-width: 90%;
    }

    .top-right-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }

    .toggle-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .popup-body {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .floating-popup {
        min-width: 90%;
        max-width: 90%;
    }

    .popup-header {
        padding: 0.5rem 0.75rem;
    }

    .popup-title {
        font-size: 0.85rem;
    }

    .popup-body {
        padding: 0.75rem;
        font-size: 0.8rem;
        max-height: 250px;
    }

    .stat-row,
    .detail-row {
        font-size: 0.8rem;
    }

    .section-title {
        font-size: 0.85rem;
    }
}
