@charset "UTF-8";
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700;800&family=Pacifico&family=Pretendard:wght@300;400;500;600;700;800;900&display=swap');

/* ==========================================================================
   1. 기본 전역 변수 및 고시인성 엔터프라이즈 라이트 테마
   ========================================================================== */
:root {
    --primary-blue: #2563eb;
    --primary-blue-hover: #1d4ed8;
    --primary-blue-light: #eff6ff;
    --cyan-accent: #0891b2;
    --teal-accent: #0d9488;
    --purple-ai: #7c3aed;
    --purple-ai-hover: #6d28d9;
    --purple-ai-light: #f5f3ff;
    
    /* 4단계 상태 판정 고대비 색상 체계 */
    --status-normal: #10b981;   /* 정상 가동 */
    --status-normal-bg: #ecfdf5;
    --status-caution: #f59e0b;  /* 주의/경고 감지 */
    --status-caution-bg: #fffbeb;
    --status-critical: #ef4444; /* 장애/심각 */
    --status-critical-bg: #fef2f2;
    --status-offline: #64748b;  /* 오프라인 */
    --status-offline-bg: #f8fafc;

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-dark: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-sub: #334155;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100dvh;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Malgun Gothic", "맑은 고딕", sans-serif;
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
    text-rendering: optimizeLegibility;
    color-scheme: light !important;
    background-color: var(--bg-main) !important;
    color: var(--text-main) !important;
    -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   2. PC 24인치 100% 디폴트 최적화 & 모바일(iOS/Android) 반응형 자동조정
   ========================================================================== */
@media (min-width: 1024px) {
    html, body {
        height: 100vh;
        overflow: hidden !important;
    }

    #pdf-report-area {
        height: 100vh !important;
        overflow: hidden !important;
        padding: 0.65rem !important;
    }

    #dashboard {
        height: calc(100vh - 128px) !important;
        min-height: 0 !important;
    }
}

@media (max-width: 1023px) {
    html, body {
        height: auto !important;
        min-height: 100%;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom, 24px);
    }

    #pdf-report-area {
        height: auto !important;
        overflow-y: visible !important;
        padding: 0.5rem !important;
        padding-bottom: 4rem !important;
    }

    #dashboard {
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    #dashboard > div,
    .dashboard-card-section {
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
        margin-bottom: 0.5rem !important;
    }

    .chart-container-box {
        position: relative !important;
        height: 220px !important;
        width: 100% !important;
        min-height: 220px !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    #pc-server-monitoring-section,
    #network-status-map-section {
        min-height: 280px !important;
        height: auto !important;
    }

    #inline-netmap-container {
        min-height: 240px !important;
        height: 240px !important;
    }

    #urgent-alert-section {
        margin-top: 0.5rem !important;
        height: auto !important;
        min-height: auto !important;
    }

    #sidebar-remote-support-menu {
        display: none !important;
    }
}

body {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

body.auth-ready {
    visibility: visible;
    opacity: 1;
}

/* ==========================================================================
   3. 모바일 상단 헤더 2열 줄바꿈 및 당일 날짜 표기 최적화
   ========================================================================== */
header {
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

header select {
    text-overflow: ellipsis;
    white-space: nowrap;
    word-wrap: normal;
}

@media (max-width: 1023px) {
    header .flex-col {
        gap: 0.5rem !important;
    }

    header .flex-1.min-w-0 {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.35rem !important;
    }

    header select {
        flex: 1 1 auto !important;
        min-width: 90px !important;
        max-width: none !important;
        font-size: 11.5px !important;
        padding-left: 0.4rem !important;
        padding-right: 0.4rem !important;
        height: 32px !important;
    }

    #mobile-menu-btn {
        height: 32px !important;
        padding: 0 0.6rem !important;
    }

    #tenant-fixed-badge {
        flex: 1 1 auto !important;
        max-width: none !important;
        height: 32px !important;
        display: inline-flex !important;
        align-items: center !important;
        padding: 0 0.5rem !important;
    }

    header .border-t {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding-top: 0.45rem !important;
        flex-wrap: nowrap !important;
        gap: 0.35rem !important;
    }

    #header-clock-container {
        display: flex !important;
        align-items: center !important;
        gap: 0.35rem !important;
        flex-shrink: 0 !important;
    }

    #clock-date {
        display: inline !important;
        font-size: 10.5px !important;
        color: #64748b !important;
        font-family: 'JetBrains Mono', monospace !important;
    }

    #clock {
        font-size: 10.5px !important;
        padding: 2px 5px !important;
    }
}

@media (max-width: 480px) {
    header select {
        font-size: 11px !important;
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    header .border-t {
        gap: 0.25rem !important;
    }

    #clock-date {
        font-size: 10px !important;
    }

    #clock {
        font-size: 10px !important;
        padding: 2px 4px !important;
    }
}

#asset-vertical-status-section .flex-1.h-0 {
    min-height: 0 !important;
    overflow: hidden !important;
}

/* ==========================================================================
   4. 웹 접근성 (.sr-only) 및 텍스트 선택/복사 보존
   ========================================================================== */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.select-text,
.copyable-text,
main,
#dashboard,
#log-box,
#cmd-log-box,
#dashboard-global-log-table-body,
#urgent-alert-feed,
#ai-troubleshoot-feed,
#recent-events,
table,
td,
th {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

/* ==========================================================================
   5. 테이블 시인성 & 최근 이벤트 로그 및 종합현황
   ========================================================================== */
.table-responsive-wrapper {
    width: 100% !important;
    overflow-x: hidden !important;
}

.mobile-fit-table {
    table-layout: fixed !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    border-collapse: collapse !important;
}

.mobile-fit-table th,
.mobile-fit-table td {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: keep-all !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
    vertical-align: middle !important;
    line-height: 1.45 !important;
}

#tenant-summary-tbody tr td,
#dashboard-global-log-table-body tr td {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: keep-all !important;
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}

#tenant-summary-tbody td.font-mono,
#dashboard-global-log-table-body td.font-mono,
.mobile-fit-table td.font-mono {
    font-variant-numeric: tabular-nums !important;
    letter-spacing: -0.02em !important;
}

#event-log-history-modal table th,
#event-log-history-modal table td {
    white-space: nowrap !important;
    overflow: hidden !important;
}

@media (max-width: 640px) {
    .mobile-fit-table th {
        font-size: 9px !important;
        padding-top: 4px !important;
        padding-bottom: 4px !important;
    }
    .mobile-fit-table td {
        font-size: 10px !important;
        padding-top: 5px !important;
        padding-bottom: 5px !important;
    }
}

/* ==========================================================================
   6. 로그인 모달 & 인증 화면
   ========================================================================== */
#login-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(241, 245, 249, 0.92);
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 2.25rem 2rem;
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.08);
}

.login-input {
    width: 100%;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 1rem;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #0f172a !important;
}

.login-input:focus {
    border-color: var(--primary-blue);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-btn {
    width: 100%;
    padding: 11px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

/* ==========================================================================
   7. SweetAlert2 전역 팝업 라이트 테마 및 정기 보고서 모달 최적화
   ========================================================================== */
.swal2-container {
    z-index: 99999999 !important;
}

html.swal2-shown, body.swal2-shown {
    height: 100% !important;
    overflow: hidden !important;
    padding-right: 0px !important;
    margin-right: 0px !important;
}

body.swal2-height-auto {
    height: 100% !important;
}

.swal2-popup {
    border-radius: 18px !important;
    font-size: 0.92rem !important;
    padding: 1.4rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.16) !important;
    background: #ffffff !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}

.swal2-title {
    color: var(--text-main) !important;
    font-weight: 800 !important;
    font-size: 1.2rem !important;
    letter-spacing: -0.02em !important;
}

.swal2-html-container {
    color: #334155 !important;
    font-size: 0.85rem !important;
    line-height: 1.55 !important;
    text-align: left;
}

.swal2-input, .swal2-select, .swal2-textarea {
    background-color: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    font-size: 12.5px !important;
}

.swal2-input:focus, .swal2-select:focus, .swal2-textarea:focus {
    border-color: var(--primary-blue) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

/* 정기 보고서 주기 설정 모달 전용 레이아웃 보존 클래스 */
.pdf-auto-day-modal-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 0.25rem;
    font-size: 0.75rem;
}

.pdf-auto-tenant-list {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .swal2-popup {
        width: 94vw !important;
        padding: 1rem !important;
        border-radius: 14px !important;
    }
    .swal2-title {
        font-size: 1.1rem !important;
    }
    #it-asset-modal > div, 
    #network-topology-modal > div, 
    #quick-remote-history-modal > div, 
    #simulation-batch-modal > div,
    #developer-agent-manager-modal > div {
        width: 98vw !important;
        height: 96vh !important;
        max-width: 98vw !important;
        border-radius: 14px !important;
    }
}

/* ==========================================================================
   8. 상세 제어 슬라이드 패널 & 원격 명령어 및 배지
   ========================================================================== */
.slide-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    height: 100vh !important;
    z-index: 200001 !important;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
}

.slide-panel.open {
    transform: translateX(0);
}

#agent-control-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.cmd-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid #cbd5e1;
    user-select: none;
    text-align: center;
    background: #f8fafc;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    min-height: 38px;
}

.cmd-btn:hover {
    background: #ffffff;
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.cmd-btn:active {
    transform: translateY(0);
}

.cmd-btn.network {
    border-color: rgba(37, 99, 235, 0.3);
    color: var(--primary-blue);
    background: rgba(37, 99, 235, 0.04);
}
.cmd-btn.network:hover {
    background: #ffffff;
    border-color: var(--primary-blue);
}

.cmd-btn.reboot {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--status-critical);
    background: rgba(239, 68, 68, 0.04);
}
.cmd-btn.reboot:hover {
    background: #ffffff;
    border-color: var(--status-critical);
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.12);
}

/* ==========================================================================
   9. 로그 뷰 & 모노스페이스 숫자 최적화
   ========================================================================== */
#log-box,
#cmd-log-box {
    font-size: 10px !important;
    line-height: 1.5 !important;
}

#log-box .border-b,
#cmd-log-box .rounded-lg {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

.data-container {
    scrollbar-width: thin;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace !important;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   10. 장비 모니터링 맵
   ========================================================================== */
#topology-view {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 3px !important;
    contain: layout paint;
}

#topology-view .grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    align-content: start !important;
    width: 100% !important;
    padding: 2px !important;
    gap: 0.5rem !important;
}

#topology-view .grid > div {
    position: relative;
    box-sizing: border-box !important;
    margin: 0 !important;
    contain: paint;
    border-radius: 12px;
}

#topology-view .grid > div:hover {
    transform: none !important;
    box-shadow: inset 0 0 0 2px var(--primary-blue) !important;
    z-index: 1;
}

#topology-view .grid > div.selected-normal {
    background-color: var(--status-normal-bg) !important;
    border-color: var(--status-normal) !important;
    box-shadow: 0 0 0 2px var(--status-normal) !important;
}

.node-hostname,
#topology-view .node-hostname,
#topology-view .truncate {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: keep-all !important;
    letter-spacing: -0.02em !important;
}

/* ==========================================================================
   11. 시스템 리소스 요약 도넛 게이지 & 버전 차트
   ========================================================================== */
#gauge-cpu-donut,
#gauge-ram-donut,
#gauge-disk-donut,
#gauge-net-donut,
#device-type-donut-chart,
#agent-version-bar-chart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.donut-chart-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

@media (max-width: 1023px) {
    .donut-chart-wrapper {
        width: 70px;
        height: 70px;
    }
}

/* ==========================================================================
   12. 네트워크 상태 맵 (Dagre-D3 & 줌/새로고침 컨트롤 영역)
   ========================================================================== */
#inline-netmap-container,
#network-topology-modal-content {
    background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
    background-size: 16px 16px;
    background-color: rgba(248, 250, 252, 0.85);
    border-radius: 12px;
}

.dagre-node rect {
    stroke-width: 1.8px !important;
    rx: 8px !important;
    ry: 8px !important;
    transition: all 0.2s ease;
}

.dagre-node:hover rect {
    stroke-width: 2.5px !important;
    filter: drop-shadow(0 4px 12px rgba(37, 99, 235, 0.2));
    cursor: pointer;
}

.dagre-node text {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
    fill: #0f172a !important;
    letter-spacing: -0.02em !important;
    pointer-events: none !important;
}

.dagre-node .label-container {
    background: transparent !important;
}

.dagre-edgePath path {
    stroke: #94a3b8 !important;
    stroke-width: 1.5px !important;
    fill: none !important;
    stroke-dasharray: 4 2 !important;
    transition: stroke 0.2s ease;
}

.dagre-edgePath:hover path {
    stroke: var(--primary-blue) !important;
    stroke-width: 2px !important;
    stroke-dasharray: none !important;
}

/* ==========================================================================
   13. 우측 3칸 긴급 알림 & AI 추천 패널 스타일
   ========================================================================== */
#urgent-alert-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

#urgent-alert-feed {
    scrollbar-gutter: stable;
}

#ai-troubleshoot {
    background: linear-gradient(180deg, #ffffff 0%, #faf5ff 100%);
    border: 1px solid rgba(196, 181, 253, 0.6);
    border-radius: 12px;
}

#quick-remote-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

/* ==========================================================================
   14. 모바일 반응형 사이드바 & 상용화 규격 Beta 배지 (문제점 3 해결)
   ========================================================================== */
@media (max-width: 1023px) {
    #main-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100000;
        box-shadow: 10px 0 25px rgba(0, 0, 0, 0.12);
        background: #ffffff;
    }
    
    #main-sidebar.mobile-open {
        transform: translateX(0);
    }
}

/* 기본적으로 display: none으로 안전 차단하여 무조건적인 강제 표시를 방지 */
.badge-beta-pro,
#sidebar-beta-badge {
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', 'Pretendard', sans-serif;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #4338ca;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
    border: 1.5px solid #a5b4fc;
    border-radius: 9999px;
    padding: 1.5px 7px;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    user-select: none;
    line-height: 1.2;
    vertical-align: middle;
}

/* JS에서 .active를 추가하거나 inline-flex 스타일을 지정했을 때만 정상 표시 */
#sidebar-beta-badge.active,
#sidebar-beta-badge.show {
    display: inline-flex !important;
}

.tech-support-box {
    font-size: 10.5px;
    color: #64748b;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-top: 6px;
}

/* ==========================================================================
   15. 스마트 전역 툴팁 & 커스텀 슬림 스크롤바
   ========================================================================== */
#global-smart-tooltip {
    position: fixed;
    z-index: 99999999;
    pointer-events: none;
    display: none;
    padding: 7px 11px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.45;
    max-width: 300px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.22);
    transition: opacity 0.15s ease;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #334155;
    color: #f8fafc;
}

.custom-scroll::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

#pwa-install-banner {
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.16);
    animation: slideDownFade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}