/* =============================================================
   Vision-AI — Emerald Lens Edition
   Foundation: tokens · reset · layout · utilities
   ============================================================= */

/* ─── Tokens ─── */
:root {
  /* 베이스 — 검정에 가까운 어두운 그린 */
  --bg:           #050a08;
  --bg-elevated:  #0a1410;
  --bg-deep:      #030605;
  --bg-deeper:    #020403;

  /* 표면 */
  --surface:    rgba(255,255,255,0.03);
  --surface-2:  rgba(255,255,255,0.05);
  --surface-3:  rgba(255,255,255,0.08);

  /* 보더 */
  --border:        rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --border-emerald:rgba(52,211,153,0.30);
  --border-faint:  rgba(255,255,255,0.04);

  /* 텍스트 */
  --text:        rgba(255,255,255,0.94);
  --text-muted:  rgba(255,255,255,0.62);
  --text-dim:    rgba(255,255,255,0.42);
  --text-faint:  rgba(255,255,255,0.22);

  /* 시그니처 — Emerald */
  --emerald:        #34d399;
  --emerald-light:  #6ee7b7;
  --emerald-deep:   #10b981;
  --emerald-soft:   rgba(52,211,153,0.10);
  --emerald-glow:   0 0 20px rgba(52,211,153,0.45);
  --emerald-grad:   linear-gradient(135deg, #34d399 0%, #10b981 100%);

  /* 검출 박스 컬러 (객체 클래스별) */
  --bbox-person:  #fbbf24;
  --bbox-defect:  #f87171;
  --bbox-product: #22d3ee;
  --bbox-vehicle: #a78bfa;
  --bbox-text:    #34d399;

  /* Confidence 단계 */
  --conf-high:    #10b981;
  --conf-mid:     #fbbf24;
  --conf-low:     #fb7185;

  /* 보조 */
  --cyan:    #22d3ee;
  --violet:  #a78bfa;
  --amber:   #fbbf24;
  --rose:    #fb7185;

  --cyan-soft:   rgba(34,211,238,0.10);
  --violet-soft: rgba(167,139,250,0.10);
  --amber-soft:  rgba(251,191,36,0.10);
  --rose-soft:   rgba(251,113,133,0.10);

  /* 글래스 */
  --glass-bg:   rgba(10,20,16,0.72);
  --glass-blur: blur(20px) saturate(140%);

  /* 라운드 */
  --r-sm:   6px;
  --r:      8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-pill: 999px;

  /* 모노 (--kr/--en 은 style.css 글로벌 사용) */
  --mono: 'JetBrains Mono', 'Roboto Mono', ui-monospace, 'SF Mono', monospace;

  /* 모션 */
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 380ms;
  --ease:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in:  cubic-bezier(0.4, 0, 1, 1);

  /* 그림자 */
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.20);
  --shadow-md:      0 8px 24px rgba(0,0,0,0.32);
  --shadow-lg:      0 20px 48px rgba(0,0,0,0.42);
  --shadow-emerald: 0 0 24px rgba(52,211,153,0.22);
  --ring-emerald:   0 0 0 3px rgba(52,211,153,0.18);

  /* 레이아웃 */
  --side-w:        72px;
  --side-w-open:   240px;
  --topbar-h:      52px;
  --content-pad:   24px;
}

/* ─── Reset & base ─── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: var(--kr);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at top left, rgba(52,211,153,0.05), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(34,211,238,0.03), transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

::selection { background: rgba(52,211,153,0.35); color: #fff; }

/* 스크롤바 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ─── Layout: Topbar ─── */
.v-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  z-index: 100;
}

.v-topbar__hamburger {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.v-topbar__hamburger:hover { color: var(--emerald); border-color: var(--border-emerald); }

.v-topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.v-topbar__logo {
  width: 32px; height: 32px;
  background: var(--emerald-grad);
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #022;
  font-size: 15px;
  box-shadow: var(--emerald-glow);
}
.v-topbar__title {
  font-family: var(--kr);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.v-topbar__badge {
  font-family: var(--en);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--emerald-soft);
  border: 1px solid var(--border-emerald);
  color: var(--emerald);
  letter-spacing: 0.10em;
}

/* 카메라 카운트 라이브 */
.v-topbar__cams {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.v-topbar__cams i { font-size: 11px; color: var(--emerald); }
.v-topbar__cams b { color: var(--text); }
.v-topbar__cams .v-rec-dot {
  width: 6px; height: 6px;
  background: var(--rose);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--rose);
  animation: v-rec-blink 1.4s ease-in-out infinite;
}

.v-topbar__spacer { flex: 1; }

.v-topbar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  padding: 0 12px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-muted);
  transition: all var(--t-base) var(--ease);
}
.v-topbar__search:hover { border-color: var(--border-strong); }
.v-topbar__search:focus-within {
  border-color: var(--emerald);
  box-shadow: var(--ring-emerald);
}
.v-topbar__search i { font-size: 12px; color: var(--text-dim); }
.v-topbar__search input {
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.v-topbar__search input::placeholder { color: var(--text-faint); }
.v-topbar__search kbd {
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-dim);
}

.v-topbar__btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--t-fast) var(--ease);
}
.v-topbar__btn:hover { color: var(--emerald); border-color: var(--border-emerald); }
.v-topbar__btn-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 6px; height: 6px;
  background: var(--rose);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--rose);
}

.v-topbar__user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.v-topbar__avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--emerald-grad);
  color: #022;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

/* ─── Layout: Sidebar ─── */
.v-side {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--side-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  z-index: 90;
  transition: width var(--t-base) var(--ease);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.v-side:hover,
.v-side.is-open { width: var(--side-w-open); }

.v-side__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}
.v-side__nav::-webkit-scrollbar { width: 4px; }

.v-side__group {
  font-family: var(--en);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.14em;
  padding: 12px 20px 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.v-side:hover .v-side__group,
.v-side.is-open .v-side__group { opacity: 1; }

.v-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: all var(--t-fast) var(--ease);
}
.v-nav-item i {
  width: 22px;
  font-size: 14px;
  text-align: center;
  flex-shrink: 0;
}
.v-nav-item span {
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.v-side:hover .v-nav-item span,
.v-side.is-open .v-nav-item span { opacity: 1; }

.v-nav-item:hover {
  background: var(--surface);
  color: var(--text);
}
.v-nav-item.is-active {
  background: var(--emerald-soft);
  color: var(--emerald);
}
.v-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--emerald);
  box-shadow: var(--emerald-glow);
}
.v-nav-item.is-active i { color: var(--emerald); }

.v-side__divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

.v-side__bottom {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.v-side-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 89;
}
.v-side-backdrop.is-open { display: block; }

/* ─── Layout: Main ─── */
.v-main {
  margin-left: var(--side-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: var(--content-pad);
}

/* ─── Page head ─── */
.v-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.v-page-head h1 {
  margin: 0 0 4px;
  font-family: var(--kr);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.v-page-head h1 i {
  margin-right: 8px;
  font-size: 18px;
}
.v-page-head__sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.v-page-head__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─── Grids ─── */
.v-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.v-kpi-grid--5 { grid-template-columns: repeat(5, 1fr); }
.v-kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }
.v-kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }

.v-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.v-grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}
.v-grid-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 18px;
}

/* ─── Utilities ─── */
.u-mono       { font-family: var(--mono); }
.u-en         { font-family: var(--en); }
.u-tabular    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.u-text-emerald { color: var(--emerald); }
.u-text-cyan    { color: var(--cyan); }
.u-text-violet  { color: var(--violet); }
.u-text-amber   { color: var(--amber); }
.u-text-rose    { color: var(--rose); }

.u-text-conf-high { color: var(--conf-high); }
.u-text-conf-mid  { color: var(--conf-mid); }
.u-text-conf-low  { color: var(--conf-low); }

.u-text-dim   { color: var(--text-dim); }
.u-text-faint { color: var(--text-faint); }
.u-text-muted { color: var(--text-muted); }

.u-mb-0  { margin-bottom: 0; }
.u-mb-8  { margin-bottom: 8px; }
.u-mb-12 { margin-bottom: 12px; }
.u-mb-16 { margin-bottom: 16px; }
.u-mb-20 { margin-bottom: 20px; }
.u-mt-12 { margin-top: 12px; }
.u-mt-16 { margin-top: 16px; }
.u-mt-20 { margin-top: 20px; }

.u-flex      { display: flex; }
.u-flex-1    { flex: 1; }
.u-gap-6     { gap: 6px; }
.u-gap-8     { gap: 8px; }
.u-gap-12    { gap: 12px; }
.u-items-center    { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-justify-center  { justify-content: center; }

.u-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Responsive ─── */
@media (max-width: 1280px) {
  .v-kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .v-kpi-grid--5 { grid-template-columns: repeat(3, 1fr); }
  .v-kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }
  .v-topbar__search { width: 200px; }
}

@media (max-width: 960px) {
  .v-grid-2,
  .v-grid-2-1,
  .v-grid-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root {
    --content-pad: 14px;
    --side-w: 0;
  }
  .v-main { margin-left: 0; }
  .v-side {
    width: var(--side-w-open);
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease);
  }
  .v-side.is-open { transform: translateX(0); }
  .v-side .v-nav-item span,
  .v-side .v-side__group { opacity: 1; }

  .v-kpi-grid,
  .v-kpi-grid--5,
  .v-kpi-grid--4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .v-page-head h1 { font-size: 20px; }
  .v-page-head__actions { width: 100%; }

  .v-topbar__search { display: none; }
  .v-topbar__cams { display: none; }
  .v-topbar__user span { display: none; }
}

@media (max-width: 480px) {
  .v-kpi-grid,
  .v-kpi-grid--5,
  .v-kpi-grid--4 { grid-template-columns: 1fr; }
}
