/* ══════════════════════════════════════
   NPMS 글로벌 스타일
   서울시교육청 학교 네트워크 장애관리 시스템
══════════════════════════════════════ */

/* ── 웹 폰트 (Pretendard + NanumGothic fallback) ─────────── */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
@font-face {
  font-family: 'NanumGothic';
  src: url('../fonts/NanumGothic.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'NanumGothic';
  src: url('../fonts/NanumGothicBold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --sidebar-width:  230px;
  --sidebar-bg:     #0f172a;
  --sidebar-accent: rgba(99,102,241,.15);
  --header-height:  52px;
  --primary:        #4f46e5;
  --primary-light:  #818cf8;
  --primary-bg:     rgba(79,70,229,.06);
  --surface:        #f1f5f9;
  --surface-card:   #ffffff;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;
  --text-main:      #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.1);
  --font-family:    'Pretendard Variable', 'Pretendard', 'NanumGothic', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --transition:     .2s cubic-bezier(.4,0,.2,1);
}

/* ── 레이아웃 ── */
body.npms-body {
  background: var(--surface);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.84rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

.npms-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  overflow: hidden;
  transition: width .25s ease, transform .25s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}
/* 메뉴 목록만 스크롤, 하단 고정 영역은 항상 표시 */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  flex-wrap: nowrap;
}
.npms-sidebar.collapsed { width: 52px; }
.npms-sidebar.collapsed .sidebar-title,
.npms-sidebar.collapsed .sidebar-section-label,
.npms-sidebar.collapsed .nav-link span,
.npms-sidebar.collapsed .related-links { display: none; }
.npms-sidebar.collapsed .nav-link { justify-content: center; padding: .5rem .6rem; }
.npms-sidebar.collapsed .nav-link i { margin: 0; font-size: 1.1rem; }

.npms-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}
.npms-main.expanded { margin-left: 52px; }

.npms-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226,232,240,.6);
  z-index: 1060;
  gap: .5rem;
}

.npms-content {
  flex: 1;
  padding: .5rem 0;
}

/* ── 사이드바 메뉴 ── */
.sidebar-divider { border-color: rgba(255,255,255,.06); margin: .4rem .75rem; }
.sidebar-section-label {
  font-size: .62rem;
  font-weight: 700;
  color: rgba(255,255,255,.32);
  letter-spacing: .1em;
  padding: .8rem .75rem .25rem;
  text-transform: uppercase;
  white-space: nowrap;
}
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.65);
  border-radius: var(--radius-sm);
  padding: .45rem .75rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .82rem;
  font-weight: 450;
  transition: all var(--transition);
  white-space: nowrap;
  margin-bottom: 1px;
}
.sidebar-nav .nav-link i { font-size: .92rem; flex-shrink: 0; opacity: .8; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.95); }
.sidebar-nav .nav-link:hover i { opacity: 1; }
.sidebar-nav .nav-link.active {
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.sidebar-nav .nav-link.active i { opacity: 1; }

/* 유관기관 링크 */
.related-link {
  display: block;
  font-size: .68rem;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  padding: .1rem .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.related-link:hover { color: rgba(255,255,255,.9); }

/* ── 헤더 뱃지 ── */
.hdr-badge { font-size: .8rem; color: var(--text-muted); }
.hdr-badge i { font-size: .85rem; }

/* ── 전역 카드 ── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
}

/* ── KPI 카드 ── */
.kpi-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-label { font-size: .72rem; font-weight: 600; letter-spacing: .02em; color: var(--text-secondary); }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ── 로그인 ── */
.login-wrapper { background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%); }

/* ── 테이블 ── */
.table { --bs-table-bg: transparent; }
.table th {
  font-size: .73rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom-width: 1px;
}
.table:not(.table-dark) > :not(.table-dark) th { color: var(--text-secondary); }
.table-dark th, .table-dark td,
.table .thead-dark th,
thead.table-dark th { color: #fff !important; }
/* 인라인 어두운 배경 헤더 보호 */
th[style*="background"], td[style*="background"] { color: inherit; }
tr[style*="background"] th, tr[style*="background"] td { color: inherit; }
thead[style*="background"] th { color: #fff !important; }
.table td {
  font-size: .8rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}
.table-hover tbody tr:hover { background-color: var(--primary-bg) !important; }
.cursor-pointer { cursor: pointer; }
.cursor-pointer:hover { background-color: var(--primary-bg) !important; }

/* ── 버튼 ── */
.btn { border-radius: var(--radius-sm); font-weight: 500; transition: all var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; box-shadow: 0 2px 8px rgba(79,70,229,.3); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,70,229,.3); }
.btn-xs { padding: .15rem .45rem; font-size: .72rem; border-radius: 4px; }

/* ── 뱃지 ── */
.badge { font-weight: 550; letter-spacing: .01em; border-radius: 4px; }

/* ── nav-tabs / nav-pills 색상 보호 ── */
.nav-tabs .nav-link { color: var(--text-secondary); }
.nav-tabs .nav-link.active { color: var(--primary); font-weight: 600; }
.nav-tabs .nav-link:hover:not(.active) { color: var(--text-main); }

/* ── 폼 ── */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* ── 모달 ── */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* ── 장애 상태 색상 ── */
.priority-critical { border-left: 3px solid #dc3545 !important; }
.priority-high      { border-left: 3px solid #fd7e14 !important; }
.priority-medium    { border-left: 3px solid #0d6efd !important; }
.priority-low       { border-left: 3px solid #6c757d !important; }

/* ── 반응형 ── */
@media (max-width: 991.98px) {
  /* 모바일: 사이드바를 화면 80% 너비 풀드로어로 */
  .npms-sidebar {
    width: min(320px, 82vw);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 1050;
    pointer-events: none;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .npms-sidebar.mobile-open {
    transform: translateX(0);
    pointer-events: auto;
    box-shadow: 6px 0 24px rgba(0,0,0,.45);
  }
  .npms-main {
    margin-left: 0 !important;
  }

  /* 모바일 메뉴 항목: 더 큰 터치 타깃, 1줄 확보 */
  .sidebar-nav .nav-link {
    font-size: .92rem;
    padding: .65rem 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 46px;
  }
  .sidebar-nav .nav-link i {
    font-size: 1.05rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
  }
  .sidebar-nav .nav-link span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar-section-label {
    font-size: .68rem;
    padding: .7rem 1rem .25rem;
  }

  /* 모바일 닫기(×) 버튼 */
  .sidebar-close-btn {
    display: flex !important;
  }
}

/* 모바일 사이드바 오버레이 */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1049;
  -webkit-tap-highlight-color: transparent;
}
#sidebar-overlay.active { display: block; }

/* 햄버거 / 링크 터치 반응성 */
#sidebar-toggle {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
}
#sidebar .nav-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* 데스크톱에서 닫기 버튼 숨기기 */
.sidebar-close-btn { display: none; }

@media (max-width: 575.98px) {
  .kpi-value { font-size: 1.4rem; }
  .npms-content { padding: .25rem 0; }
}

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── 애니메이션 ── */
@keyframes pulse-dot {
  0%,100% { opacity:1; } 50% { opacity:.4; }
}
.live-dot {
  display: inline-block; width: 7px; height: 7px;
  background: #22c55e; border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

/* 지도 캔버스 고해상도 렌더링 */
#vworld-map canvas,
#gps-map canvas,
#school-map canvas {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ══════════════════════════════════════════
   도움말 버튼
══════════════════════════════════════════ */
.help-btn {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.65);
  border: 1px solid rgba(255,255,255,.12);
  font-size: .75rem;
  padding: .3rem .5rem;
  text-align: left;
  transition: background .15s;
}
.help-btn:hover { background: rgba(255,255,255,.15); color:#fff; }
.npms-sidebar.collapsed .help-btn span { display: none; }
.npms-sidebar.collapsed .help-btn { justify-content: center; }

/* ══════════════════════════════════════════
   Bootstrap 모달 — 헤더(z-index:1060) 위에 표시
   헤더 height(52px)만큼 아래에서 시작
══════════════════════════════════════════ */
.modal             { z-index: 1070; }
.modal-backdrop    { z-index: 1065; }
.modal-dialog      { margin-top: calc(var(--header-height) + 0.75rem); }

/* 전체화면(modal-fullscreen) 계열은 margin-top 제외 */
.modal-dialog.modal-fullscreen,
.modal-dialog.modal-fullscreen-sm-down,
.modal-dialog.modal-fullscreen-md-down,
.modal-dialog.modal-fullscreen-lg-down,
.modal-dialog.modal-fullscreen-xl-down,
.modal-dialog.modal-fullscreen-xxl-down { margin-top: 0; }

/* ══════════════════════════════════════════
   S/N 끝 4자리 후보 드롭다운
══════════════════════════════════════════ */
.sn-candidates {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 1080;
  background: #fff;
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 .375rem .375rem;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.sn-cand-item {
  padding: .35rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f5;
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sn-cand-item:hover { background: #f0f9ff; }
.sn-cand-item:last-child { border-bottom: none; }

/* ══════════════════════════════════════════
   도움말 모달
══════════════════════════════════════════ */
.help-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 2000;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.help-modal-backdrop.d-none { display: none !important; }

.help-modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  overflow: hidden;
}
.help-modal-header { border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.help-tabs { background: #f8fafc; flex-shrink: 0; gap:.35rem !important; }
.help-tab {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  padding: .25rem .7rem;
  font-size: .75rem;
  cursor: pointer;
  transition: all .15s;
  color: #64748b;
}
.help-tab:hover { background: #f1f5f9; }
.help-tab.active { background: var(--primary, #3b82f6); color: #fff; border-color: var(--primary, #3b82f6); }

.help-body {
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  align-content: start;
}
.help-footer { flex-shrink: 0; background: #f8fafc; }

/* 카드 */
.help-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  cursor: default;
}
.help-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.help-card.d-none { display: none !important; }

/* 화면 모형 */
.help-card-screen {
  background: #1e293b;
  padding: .6rem;
  position: relative;
  overflow: hidden;
  height: 120px;
}
.mock-screen { background:#f1f5f9; border-radius:4px; height:100%; padding:.3rem; overflow:hidden; }
.mock-header { height:10px; background:#3b82f6; border-radius:2px; margin-bottom:.3rem; }
.mock-toolbar { height:7px; background:#e2e8f0; border-radius:2px; margin-bottom:.3rem; }
.mock-kpi-row { display:flex; gap:.3rem; margin-bottom:.3rem; }
.mock-kpi { flex:1; height:18px; border-radius:3px; opacity:.7; }
.mock-kpi.red{background:#ef4444;} .mock-kpi.yellow{background:#f59e0b;}
.mock-kpi.green{background:#22c55e;} .mock-kpi.blue{background:#3b82f6;}
.mock-chart-row { display:flex; gap:.3rem; }
.mock-chart-big { flex:2; height:30px; background:#dbeafe; border-radius:3px; }
.mock-chart-sm { flex:1; }
.mock-table { margin-top:.2rem; }
.mock-thead { height:7px; background:#cbd5e1; border-radius:2px; margin-bottom:.2rem; }
.mock-tr { display:flex; align-items:center; gap:.3rem; margin-bottom:.15rem; }
.mock-badge { width:14px; height:6px; border-radius:2px; flex-shrink:0; background:#94a3b8; }
.mock-badge.red{background:#ef4444;} .mock-badge.yellow{background:#f59e0b;}
.mock-badge.green{background:#22c55e;} .mock-badge.blue{background:#3b82f6;}
.mock-td { flex:1; height:6px; background:#e2e8f0; border-radius:2px; }
.mock-td.wide { flex:2; }
.mock-tab-row { display:flex; gap:.2rem; margin-bottom:.3rem; }
.mock-tab { width:28px; height:7px; background:#cbd5e1; border-radius:2px; }
.mock-tab.active { background:#3b82f6; }
.mock-form-group { height:10px; background:#e2e8f0; border-radius:2px; margin-bottom:.25rem; }
.mock-form-group.short { width:60%; }
.mock-contact-hint { height:8px; background:#bfdbfe; border-radius:2px; margin-bottom:.25rem; }
.mock-form-row { display:flex; gap:.3rem; margin-bottom:.25rem; }
.mock-form-half { flex:1; height:10px; background:#e2e8f0; border-radius:2px; }
.mock-btn-row { display:flex; justify-content:flex-end; }
.mock-btn-primary { width:40px; height:9px; background:#3b82f6; border-radius:3px; }
.mock-list-item { height:6px; background:#e2e8f0; border-radius:2px; margin-bottom:.2rem; }
.mock-list-item.short { width:60%; }
.mock-calendar { }
.mock-cal-header { height:8px; background:#3b82f6; border-radius:2px; margin-bottom:.2rem; }
.mock-cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; }
.mock-cal-cell { height:10px; background:#f1f5f9; border-radius:1px; }
.mock-cal-cell.has-event { background:#bfdbfe; }
.mock-card-list { display:flex; flex-direction:column; gap:.2rem; }
.mock-worker-card { height:14px; background:#e2e8f0; border-radius:3px; }
.mock-info-grid { }
.mock-info-row { height:7px; background:#e2e8f0; border-radius:2px; margin-bottom:.2rem; }
.mock-info-row.short { width:55%; }
.mock-building-row { display:flex; gap:.3rem; margin-top:.2rem; }
.mock-bld { flex:1; height:16px; background:#dbeafe; border-radius:3px; }
.mock-map-area { position:relative; height:80px; background:#f8fafc; border-radius:3px; }
.mock-node { position:absolute; width:10px; height:10px; border-radius:50%; left:30%; top:40%; }
.mock-node.green{background:#22c55e;} .mock-node.red{background:#ef4444;}
.mock-progress-list { padding:.2rem; }
.mock-progress-row { height:8px; background:#e2e8f0; border-radius:4px; margin-bottom:.3rem; overflow:hidden; }
.mock-progress-bar { height:100%; background:#22c55e; border-radius:4px; }
.mock-progress-bar.warning { background:#f59e0b; }
.mock-file-list { padding:.2rem; }
.mock-file-row { display:flex; align-items:center; gap:.3rem; height:12px; margin-bottom:.2rem; font-size:.55rem; }
.mock-photo-grid { display:grid; grid-template-columns:1fr 1fr; gap:.2rem; padding:.2rem; }
.mock-photo { background:#cbd5e1; border-radius:2px; height:22px; }

/* 실제 스크린샷 오버레이 */
.help-img-overlay {
  position:absolute; inset:0;
  background: #1e293b;
}
.help-img-overlay img {
  width:100%; height:100%;
  object-fit:cover;
  border-radius:4px;
}

/* 카드 본문 */
.help-card-body { padding: .75rem; }
.help-card-title { font-weight:600; font-size:.85rem; margin-bottom:.4rem; display:flex; align-items:center; gap:.4rem; }
.help-card-desc { font-size:.78rem; color:#475569; line-height:1.5; margin-bottom:.5rem; }
.help-card-steps { display:flex; flex-direction:column; gap:.2rem; }
.step {
  font-size:.72rem; color:#64748b;
  background:#f8fafc; border-radius:4px;
  padding:.2rem .5rem;
  border-left:3px solid #3b82f6;
}

@media(max-width:575px) {
  .help-modal-box { max-height:95vh; border-radius:8px; }
  .help-body { grid-template-columns:1fr; }
}
