@charset "UTF-8";

/* ==========================================================================
   STB MONITORING SYSTEM - MODERN INTEGRATED DASHBOARD CSS
   ========================================================================== */

:root {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    margin: 0;
    padding: 20px;
    color: var(--text-dark);
}
body.modal-open { overflow: hidden !important; touch-action: none; }

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.stb-card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px;
    box-sizing: border-box;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stb-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.stb-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stb-card-title {
    font-size: 15px;
    font-weight: bold;
    color: var(--text-dark);
}

.stb-status-badge {
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--success-bg);
    color: var(--success-text);
}

.stb-status-badge.offline {
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* 3. 카드 내부 하단 인프라 정보 텍스트 및 개별 제어판 */
.stb-meta-zone {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 10px;
    background: #f8fafc;
    padding: 6px 10px;
    border-radius: 6px;
}

.stb-card-actions {
    display: flex;
    gap: 6px;
}

.stb-card-actions button {
    flex: 1;
    padding: 6px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    background: #fff;
    transition: background 0.2s, color 0.2s;
}

.stb-card-actions button:hover {
    background: #f1f5f9;
}

.stb-card-actions .btn-select {
    background: var(--primary-color);
    color: white;
    border: none;
}

.stb-card-actions .btn-select:hover {
    background: var(--primary-hover);
}

.control-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.control-bar select {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
    cursor: pointer;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color, #e2e8f0);
}

.range-control input[type="number"] {
    width: 90px;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    text-align: right;
    outline: none;
    background-color: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.range-control input[type="number"]:hover {
    border-color: #94a3b8;
}

.range-control input[type="number"]:focus {
    border-color: var(--primary-color, #0284c7);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15); /* 푸른색 강조선 */
}

.range-control input[type="number"]::-webkit-inner-spin-button,
.range-control input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    cursor: pointer;
}

.main-content {
    display: flex;
    gap: 20px;
    height: 550px;
}

.proc-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

#procList {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-size: 13px;
    line-height: 2;
    background: #fff;
}

#procList label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

#procList label:hover {
    background: #f1f5f9;
}

#memChartContainer {
    flex: 1.2;
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.leak-panel {
    width: 320px;
    background: #fff5f5;
    border: 1px solid #ffcccc;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.stb-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    margin-top: 10px;
}

.stb-table th {
    padding: 12px 10px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 13px;
}

.stb-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    vertical-align: middle;
}

.stb-table tbody tr:hover {
    background-color: #f8fafc;
}

div[style*="sticky"] {
    position: sticky !important;
    top: 20px !important;
    width: 290px !important;
    flex-shrink: 0 !important;
    display: block !important;
}

.dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 14px !important;
    margin-bottom: 20px !important;
}

/* =========================================
   1. 테이블 영역: 글자 넘침 방지 및 가로 스크롤
   ========================================= */
/* 테이블을 감싸는 컨테이너에 가로 스크롤 허용 */
.table-container, .device-table-wrapper {
	width: 100%;
	overflow-x: auto; 
	-webkit-overflow-scrolling: touch;
}

/* 테이블 셀 내부 텍스트가 구역을 넘어가면 '...' 으로 처리 */
table th, table td {
	white-space: nowrap;       /* 줄바꿈 방지 */
	overflow: hidden;          /* 넘치는 텍스트 숨김 */
	text-overflow: ellipsis;   /* 말줄임표(...) 적용 */
	max-width: 150px;          /* 필요에 따라 최대 너비 조정 */
}

/* =========================================
   2. 콘솔 창: 커맨드 입력창 하단 고정
   ========================================= */
/* 콘솔 전체 영역을 Flex Column으로 구성 */
.console-container, #consolePanel {
	display: flex;
	flex-direction: column;
	height: 100%; 
	min-height: 300px; /* 너무 작아지지 않도록 최소 높이 보장 */
}

/* 콘솔 로그가 찍히는 화면 (남은 공간을 모두 차지하도록) */
.console-logs, #consoleOutput {
	flex: 1 1 auto;      /* 공간 확장 허용 */
	overflow-y: auto;    /* 세로 스크롤 활성화 */
}

/* 커맨드 입력 영역 (항상 바닥에 고정) */
.console-input-area, .command-input-wrapper {
	flex: 0 0 auto;      /* 크기 축소/확장 방지 */
	margin-top: auto;    /* 위쪽 여백을 최대로 밀어서 바닥에 붙임 */
	padding-top: 10px;
}

/* =========================================
   3. 스크립트 실행 창 & 대시보드 그리드 찌그러짐 방지
   ========================================= */
/* CSS Grid나 Flexbox 자식 요소가 부모 크기를 뚫고 나가는 것을 차단 */
.dashboard-grid > div, .panel, .card {
	min-width: 0; 
	min-height: 0;
}

.force-hidden {
    display: none !important;
}

.video-card {
    position: relative; 
    overflow: hidden !important; /* 영역 밖으로 튀어나가는 비디오 숨김 */
}

/* Video.js 내부 실제 비디오 태그에 변형(Transform) 적용 */
.video-card .vjs-tech,
.video-card video {
    transform-origin: top left !important;
    transition: transform 0.1s ease-out !important;
}

/* 톱니바퀴(조율) 버튼 스타일 */
.crop-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 50;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.crop-btn:hover { background: rgba(0, 0, 0, 0.8); }

/* ==========================================================================
   스트리밍 화면 조정
   ========================================================================== */

.video-crop-viewport {
    width: 280px !important; /* 기존 100%에서 고정 픽셀로 변경하여 카드 크기가 변해도 영상 틀은 유지 */
    min-width: 280px !important;
    height: 200px !important;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    margin-bottom: 8px;
    margin: 0 auto; /* 틀이 고정되었으므로 카드 중앙에 정렬 */
}

.video-crop-viewport .video-tech {
    position: absolute !important;
    max-width: none !important;
}

/* 스트리밍 화면 크기 조정 */
.stream-8div .video-tech { width: 1110px !important; height: 398px !important; object-fit: fill !important; }
.stream-4div .video-tech { width: 560px !important; height: 400px !important; object-fit: fill !important; }

/* 스트리밍 화면 위치 조정 (8분할 화면) */
.video-tech.crop-local-1 { left: 0; top: 0; }
.video-tech.crop-local-2 { left: -278px; top: 0; }
.video-tech.crop-local-3 { left: -556px; top: 0; }
.video-tech.crop-local-4 { left: -834px; top: 0; }
.video-tech.crop-local-5 { left: 0; top: -200px; }
.video-tech.crop-local-6 { left: -278px; top: -200px; } 
.video-tech.crop-local-7 { left: -556px; top: -200px; } 
.video-tech.crop-local-8 { left: -834px; top: -200px; }

/* 스트리밍 화면 위치 조정 (4분할 화면) */
.stream-4div .video-tech.crop-local-1 { left: 0; top: 0; }
.stream-4div .video-tech.crop-local-2 { left: -280px; top: 0; }
.stream-4div .video-tech.crop-local-3 { left: 0; top: -200px; }
.stream-4div .video-tech.crop-local-4 { left: -280px; top: -200px; }

/* ==========================================================================
   🚀 HLS (Video.js) 전용 크롭 및 위치 조정 보완 (기존 코드 하단 추가)
   ========================================================================== */

/* 1. HLS 껍데기(video-js)는 크기를 키우거나 이동시키지 않고, 뷰포트(280x200)에 꽉 차게 고정 */
.video-crop-viewport .video-js.video-tech {
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    top: 0 !important;
}

/* 2. 실제 영상 알맹이(.vjs-tech)의 크기를 기존 로직에 맞춰 강제 확대 */
.stream-8div .video-tech .vjs-tech {
    width: 1110px !important;
    height: 398px !important;
    object-fit: fill !important;
    position: absolute !important;
    max-width: none !important;
}

.stream-4div .video-tech .vjs-tech {
    width: 560px !important;
    height: 400px !important;
    object-fit: fill !important;
    position: absolute !important;
    max-width: none !important;
}

/* 3. 실제 영상 알맹이(.vjs-tech)의 위치 직접 이동 (8분할) */
.crop-local-1 .vjs-tech { left: 0 !important; top: 0 !important; }
.crop-local-2 .vjs-tech { left: -278px !important; top: 0 !important; }
.crop-local-3 .vjs-tech { left: -556px !important; top: 0 !important; }
.crop-local-4 .vjs-tech { left: -834px !important; top: 0 !important; }
.crop-local-5 .vjs-tech { left: 0 !important; top: -200px !important; }
.crop-local-6 .vjs-tech { left: -278px !important; top: -200px !important; }
.crop-local-7 .vjs-tech { left: -556px !important; top: -200px !important; }
.crop-local-8 .vjs-tech { left: -834px !important; top: -200px !important; }

/* 4. 실제 영상 알맹이(.vjs-tech)의 위치 직접 이동 (4분할) */
.stream-4div .crop-local-1 .vjs-tech { left: 0 !important; top: 0 !important; }
.stream-4div .crop-local-2 .vjs-tech { left: -280px !important; top: 0 !important; }
.stream-4div .crop-local-3 .vjs-tech { left: 0 !important; top: -200px !important; }
.stream-4div .crop-local-4 .vjs-tech { left: -280px !important; top: -200px !important; }

/* 로그인 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: #121212; 
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.modal-content {
  background: #1e1e24;
  color: #ffffff;
  padding: 30px 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 340px;
  box-sizing: border-box;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  border: 1px solid #2a2a35;
  text-align: center;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 20px;
  color: #fff;
}

.login-subtext {
  font-size: 13px;
  color: #888899;
  margin-bottom: 24px;
}

.input-group {
  margin-bottom: 18px;
  text-align: left;
}

.input-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #aaaabb;
}

.input-group input {
  width: 100%;
  padding: 10px 12px;
  box-sizing: border-box;
  background: #2a2a35;
  border: 1px solid #3a3a48;
  color: #fff;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.input-group input:focus {
  border-color: #007bff;
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 15px;
  margin-top: 10px;
}

.btn-login:hover {
  background: #0056b3;
}

.error-msg {
  color: #ff5555;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.admin-only.hidden {
  display: none !important;
}

.mobile-rcu-trigger-zone {
  display: none;
}

@media (max-width: 768px) {
  .mobile-rcu-trigger-zone {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 10px;
    
    position: sticky !important;
    top: 10px;
    z-index: 9999 !important;
    
    margin: 10px 0 16px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #334155;
  }

  .trigger-text {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .btn-mobile-rcu-open {
    background: var(--primary-color, #0284c7);
    color: white;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.3);
  }

  #rcuControlPanel {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-height: 75vh;
    overflow-y: auto;
    border-radius: 24px 24px 0 0 !important;
    background: #1e293b !important;
    
    transform: translateY(100%) !important; 
    transition: transform 0.3s ease-in-out !important;
    z-index: 100000 !important;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.5) !important;
  }
  
  #rcuControlPanel.mobile-open {
    transform: translateY(0) !important;
  }
}

/* ========================================== */
/* 확대 모달 전용 스타일 */
/* ========================================== */
.stream-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.stream-modal-overlay.show {
    display: flex;
}

.stream-modal-content {
    background: #1e1e24;
    border: 1px solid #33333d;
    border-radius: 12px;
    width: 800px; /* 모달 가로 크기 */
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.stream-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; background: #25252d; border-bottom: 1px solid #33333d;
}
.stream-modal-header h3 { margin: 0; color: #fff; font-size: 1.1rem; }
.btn-modal-close { background: transparent; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

.stream-modal-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 550px; /* 확대된 화면이 들어갈 충분한 높이 */
    background: #000;
}

/* 🌟 기존 280x200 뷰포트를 2.5배 뻥튀기 (700x500 사이즈로 보임) */
.modal-scale-wrapper {
    transform: scale(2.5);
    transform-origin: center center;
    /* 화질이 깨지지 않고 픽셀이 뚜렷하게 보이도록 설정 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}