/* ===========================================
   KY MES BI Dashboard - BI Theme
   =========================================== */

/* ===== 기본 설정 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans KR', 'Roboto', sans-serif;
  background: #1f2a36;
  min-height: 100vh;
  color: #e6edf3;
  overflow-x: hidden;
}

/* ===== CSS 변수 (BI 테마) ===== */
:root {
  --bg: #1f2a36;
  --card: #28343f;
  --border: #364150;
  --text: #e6edf3;
  --text-muted: #8b95a5;
  --mint: #00d5bd;
  --blue: #24c1ed;
  --purple: #954ce9;
  --red: #ef6670;
  --orange: #ffb347;
  --green: #48c15e;
  --yellow: #f0c940;
}

/* ===========================================
   Layout
   =========================================== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ===========================================
   Hamburger Menu
   =========================================== */
#menuToggle {
  display: block;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 200;
  -webkit-user-select: none;
  user-select: none;
}

#menuToggle input {
  display: block;
  width: 38px;
  height: 32px;
  position: absolute;
  top: -6px;
  left: -4px;
  cursor: pointer;
  opacity: 0;
  z-index: 202;
}

/* 햄버거 바 - 직접 자식만 선택 */
#menuToggle > span {
  display: block;
  width: 28px;
  height: 3px;
  margin-bottom: 6px;
  position: relative;
  background: var(--text-muted);
  border-radius: 2px;
  z-index: 201;
  transform-origin: 4px 0px;
  transition: transform 0.4s ease, background 0.4s ease, opacity 0.4s ease;
}

#menuToggle > span:first-of-type {
  transform-origin: 0% 0%;
}

#menuToggle > span:nth-of-type(3) {
  transform-origin: 0% 100%;
  margin-bottom: 0;
}

/* X 상태일 때 */
#menuToggle input:checked ~ span:first-of-type {
  transform: rotate(45deg) translate(-2px, -1px);
  background: var(--mint);
}

#menuToggle input:checked ~ span:nth-of-type(2) {
  opacity: 0;
  transform: scale(0.2);
}

#menuToggle input:checked ~ span:nth-of-type(3) {
  transform: rotate(-45deg) translate(0, -1px);
  background: var(--mint);
}

#menuToggle input:checked ~ aside.sidebar {
  transform: translateX(0) !important;
}

/* 사이드바 오버레이 */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#menuToggle input:checked ~ .sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

/* ===========================================
   Sidebar
   =========================================== */
.sidebar {
  width: 260px;
  background: rgba(50, 62, 75, 0.98);
  color: var(--text);
  padding: 60px 25px 30px 25px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  transform: translateX(-280px);
  transition: transform 0.4s ease;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.logo {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 20px 20px;
  margin: -20px -20px 15px -20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  position: sticky;
  top: 0;
  background: rgba(50, 62, 75, 0.98);
  z-index: 10;
}

.logo-img {
  width: 70px;
  height: 40px;
  object-fit: contain;
  margin-top: 3px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.logo-text .company-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.logo-text .bi-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--mint);
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-text .bi-label::before {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--mint);
  margin: 0 0 0 5px;
}

.sidebar nav {
  padding-top: 15px;
}

.menu-section {
  margin-bottom: 15px;
}

.menu-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 1px;
  font-weight: 500;
}

.menu-item {
  padding: 12px 0;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.menu-item:hover {
  color: var(--mint);
}

.menu-item.active {
  color: var(--mint);
}

.menu-item.logout-item {
  color: var(--red);
  border-bottom: none;
}

.menu-item.logout-item:hover {
  color: #ff8a8a;
}

.menu-item.logout-item i {
  color: var(--red);
}

.menu-item i {
  width: 18px;
  min-width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.menu-item span {
  flex: 1;
}

.menu-item.active i,
.menu-item:hover i {
  color: var(--mint);
}

/* ===========================================
   Main Content
   =========================================== */
.main-content {
  flex: 1;
  margin-left: 0;
  padding: 20px;
  padding-left: 70px;
  min-height: 100vh;
}

/* ===========================================
   Header
   =========================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  background: var(--card);
  padding: 15px 20px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.mobile-menu-spacer {
  display: none;
}

/* 헤더 삼각형 장식 */
.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 25px 25px;
  border-color: transparent transparent var(--mint) transparent;
}

.header-title h1 {
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-title p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Filter Controls */
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}

.filter-group i {
  color: var(--text-muted);
}

.filter-group select {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.filter-group select option {
  background: var(--card);
  color: var(--text);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.btn-primary {
  background: var(--mint);
  color: #1f2a36;
}

.btn-primary:hover {
  background: #00b8a3;
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(0, 213, 189, 0.1);
  border-color: var(--mint);
}

/* ===========================================
   Loading Overlay
   =========================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(31, 42, 54, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===========================================
   KPI Cards (Mini Style)
   =========================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--card);
  padding: 15px 20px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
}

/* KPI 카드 삼각형 장식 */
.kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 25px 25px;
  border-color: transparent;
}

.kpi-card:nth-child(1)::after { border-color: transparent transparent var(--mint) transparent; }
.kpi-card:nth-child(2)::after { border-color: transparent transparent var(--blue) transparent; }
.kpi-card:nth-child(3)::after { border-color: transparent transparent var(--orange) transparent; }
.kpi-card:nth-child(4)::after { border-color: transparent transparent var(--red) transparent; }

.kpi-info {
  flex: 1;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.kpi-value {
  font-size: 28px;
  font-weight: 300;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.kpi-unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.kpi-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin-top: 8px;
  margin-bottom: 10px;
  font-weight: 500;
}

.trend-up { color: var(--mint); }
.trend-down { color: var(--red); }
.trend-neutral { color: var(--text-muted); }

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.kpi-icon.blue { background: rgba(36, 193, 237, 0.2); color: var(--blue); }
.kpi-icon.green { background: rgba(0, 213, 189, 0.2); color: var(--mint); }
.kpi-icon.red { background: rgba(239, 102, 112, 0.2); color: var(--red); }
.kpi-icon.orange { background: rgba(255, 179, 71, 0.2); color: var(--orange); }

/* ===========================================
   Chart Cards
   =========================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--card);
  padding: 20px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

/* 차트 카드 삼각형 장식 */
.chart-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 25px 25px;
  border-color: transparent;
}

.chart-card:nth-child(1)::after { border-color: transparent transparent var(--mint) transparent; }
.chart-card:nth-child(2)::after { border-color: transparent transparent var(--purple) transparent; }
.chart-card:nth-child(3)::after { border-color: transparent transparent var(--blue) transparent; }
.chart-card:nth-child(4)::after { border-color: transparent transparent var(--orange) transparent; }

.chart-card.full-width {
  grid-column: span 2;
}

.chart-card.full-width::after {
  border-color: transparent transparent var(--mint) transparent;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-left: 12px;
  border-left: 3px solid var(--mint);
}

.chart-title i {
  color: var(--mint);
  font-size: 16px;
  margin-right: 8px;
}

.chart-actions {
  display: flex;
  gap: 8px;
}

.chart-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.chart-btn:hover {
  background: rgba(0, 213, 189, 0.1);
  color: var(--text);
}

.chart-btn.active {
  background: var(--mint);
  color: #1f2a36;
  border-color: var(--mint);
}

.chart-container {
  position: relative;
  height: 280px;
}

/* ===========================================
   Data Tables
   =========================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr {
  transition: background 0.3s ease;
}

.data-table tbody tr:hover {
  background: rgba(0, 213, 189, 0.05);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success { background: rgba(0, 213, 189, 0.2); color: var(--mint); }
.badge-danger { background: rgba(239, 102, 112, 0.2); color: var(--red); }
.badge-warning { background: rgba(255, 179, 71, 0.2); color: var(--orange); }
.badge-info { background: rgba(36, 193, 237, 0.2); color: var(--blue); }

/* Progress Bar in Table */
.rate-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  max-width: 80px;
}

.rate-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--blue));
  border-radius: 2px;
}

/* ===========================================
   Utilities
   =========================================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ===========================================
   Responsive Design
   =========================================== */
@media (max-width: 1400px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-card.full-width {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.4s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 15px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
  }

  .mobile-menu-spacer {
    display: block;
    width: 33px;
    min-width: 33px;
    flex-shrink: 0;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .kpi-value {
    font-size: 24px;
  }
}

/* ===========================================
   Animations
   =========================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* ===========================================
   Scrollbar Styling
   =========================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
