/* ============================================================
   BIJU 생산 현황판 - 공장 현황판(사이니지) 다크 테마
   공정별 색상과 상태 색상은 원본 데스크톱 프로그램 값을 계승.
   ============================================================ */

@font-face { font-family: "PretendardFallback"; src: local("Pretendard"), local("Malgun Gothic"); }

:root {
  --bg:        #16181c;
  --panel:     #1f232a;
  --panel-2:   #262b33;
  --panel-3:   #2d333c;
  --line:      #333a44;
  --line-soft: #2a3038;
  --txt:       #eaecef;
  --txt-2:     #8a929c;
  --txt-3:     #626a74;

  --biju:      #f26b21;   /* 로고 오렌지 */
  --biju-dim:  #b8501a;

  /* 공정 색상 (원본 계승) */
  --p-print:   #e67e22;   /* 인쇄 */
  --p-coat:    #16a085;   /* 코팅 */
  --p-foil:    #d35400;   /* 박 */
  --p-thomson: #f39c12;   /* 톰슨 */
  --p-glue:    #8e44ad;   /* 접착 */

  /* 상태 색상 (원본 계승) */
  --s-done:    #9aa0a6;   /* 완료 */
  --s-audit:   #a566ff;   /* 감리 */
  --s-stop:    #f15f5f;   /* 보류/비가동/중지/퇴근 */
  --s-run:     #59d98a;   /* 작업/준비 */

  --radius: 10px;
  --gap: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: "Pretendard", "PretendardFallback", "Malgun Gothic",
               -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 10px 20px;
  background: linear-gradient(180deg, #1c2026, #171a1f);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo { height: 30px; width: auto; display: block; }
.brand__title {
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
  padding-left: 12px; border-left: 1px solid var(--line);
}
.topbar__now {
  flex: 1 1 auto; text-align: center;
  font-size: 22px; font-weight: 800; letter-spacing: -0.01em;
  color: var(--txt);
}
.topbar__now .dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  margin-right: 10px; vertical-align: middle;
}
.topbar__now .proc { color: var(--txt-2); font-weight: 700; margin-right: 8px; font-size: 18px; }
.clock { text-align: right; line-height: 1.1; }
.clock__time { display: block; font-size: 24px; font-weight: 800; letter-spacing: 0.01em; }
.clock__date { display: block; font-size: 13px; color: var(--txt-2); }

/* ---------- 본문 3분할 ---------- */
.body { flex: 1 1 auto; display: grid; grid-template-columns: 240px 1fr 620px; min-height: 0; }

/* ---------- 설비 레일 ---------- */
.rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto; padding: 12px;
}
.rail__loading { color: var(--txt-2); font-size: 14px; padding: 12px; }
.rgroup { margin-bottom: 16px; }
.rgroup__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; color: var(--txt-2);
  text-transform: none; margin: 0 4px 8px;
}
.rgroup__title::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px;
  background: var(--gc, var(--biju));
}
.rgroup__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.eqbtn {
  appearance: none; cursor: pointer;
  background: var(--panel-2); color: var(--txt);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gc, var(--biju));
  border-radius: 8px; padding: 12px 10px;
  font-size: 15px; font-weight: 700; text-align: left;
  transition: background .12s ease, transform .05s ease;
  position: relative;
}
.eqbtn:hover { background: var(--panel-3); }
.eqbtn:active { transform: translateY(1px); }
.eqbtn:focus-visible { outline: 2px solid var(--biju); outline-offset: 2px; }
.eqbtn.is-active {
  background: color-mix(in srgb, var(--gc) 22%, var(--panel-2));
  border-color: var(--gc); color: #fff;
}
.eqbtn .vid {
  position: absolute; top: 6px; right: 8px; font-size: 10px;
  color: var(--gc); font-weight: 800;
}

/* ---------- 작업 목록 ---------- */
.jobs { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.jobs__head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 14px 18px 10px; border-bottom: 1px solid var(--line-soft);
}
.jobs__title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.jobs__count { color: var(--txt-2); font-size: 14px; }
.jobs__tablewrap { flex: 1 1 auto; overflow-y: auto; }

.jobtable { width: 100%; border-collapse: collapse; }
.jobtable thead th {
  position: sticky; top: 0; z-index: 1;
  background: #1b1f25; color: var(--txt-2);
  font-size: 13px; font-weight: 700; text-align: left;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.jobtable th.col-time, .jobtable td.col-time { width: 68px; text-align: center; }
.jobtable th.col-code, .jobtable td.col-code { width: 96px; }
.jobtable th.col-stt, .jobtable td.col-stt { width: 60px; text-align: center; padding-left: 8px; padding-right: 4px; }
.jobtable td {
  padding: 12px 14px; font-size: 16px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jobtable td.col-item { max-width: 0; }
.jobtable tbody tr { transition: background .1s ease; }
.jobtable tbody tr:hover td { background: rgba(255,255,255,.04); }
.jobtable tbody tr.is-selected td { background: rgba(242,107,33,.16); }
.jobtable__empty td { color: var(--txt-3); text-align: center; padding: 40px; cursor: default; }
.jobtable__empty:hover td { background: none !important; }

/* 상태 배지 */
.badge {
  display: inline-block; padding: 3px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 800; color: #10141a; white-space: nowrap;
}
.badge--done  { background: var(--s-done); }
.badge--audit { background: var(--s-audit); color:#fff; }
.badge--stop  { background: var(--s-stop); color:#fff; }
.badge--run   { background: var(--s-run); }
.badge--plan  { background: var(--panel-3); color: var(--txt-2); }
/* 상태별 행 좌측 표식 */
tr.row--done  td:first-child { box-shadow: inset 4px 0 0 var(--s-done); }
tr.row--audit td:first-child { box-shadow: inset 4px 0 0 var(--s-audit); }
tr.row--stop  td:first-child { box-shadow: inset 4px 0 0 var(--s-stop); }
tr.row--run   td:first-child { box-shadow: inset 4px 0 0 var(--s-run); }

/* ---------- 상세 + 미디어 ---------- */
.detail {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.media {
  position: relative; margin: 16px; border-radius: var(--radius);
  background: #000; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--line); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.media__placeholder { color: var(--txt-3); font-size: 14px; text-align: center; line-height: 1.7; padding: 20px; }
.media__frame, .media__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media__img { width: 100%; height: 100%; object-fit: contain; background: #0a0c0f; cursor: zoom-in; }
.media__back {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(0,0,0,.65); color:#fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.media__back:hover { background: rgba(0,0,0,.85); }

/* 진행률 */
.progress { margin: 0 14px 12px; }
.progress__bar { height: 12px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.progress__fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--biju-dim), var(--biju));
  transition: width .4s ease;
}
.progress__label { margin-top: 6px; font-size: 12px; color: var(--txt-2); text-align: right; }

/* 필드 그리드 */
.fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line-soft); margin: 0 14px 16px; border-radius: var(--radius); overflow: hidden;
}
.field { background: var(--panel-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field__k { font-size: 11px; color: var(--txt-3); font-weight: 700; letter-spacing: .02em; }
.field__v { font-size: 16px; font-weight: 700; color: var(--txt); word-break: break-all; }
.field__v.status-done  { color: var(--s-done); }
.field__v.status-audit { color: var(--s-audit); }
.field__v.status-stop  { color: var(--s-stop); }
.field__v.status-run   { color: var(--s-run); }

/* ---------- 이미지 확대 보기 (라이트박스) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(6, 8, 11, .95);
  display: none; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
.lightbox.open { display: flex; }
.lightbox__img {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0; will-change: transform;
  cursor: grab; user-select: none; -webkit-user-drag: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.lightbox__img.grabbing { cursor: grabbing; }
.lightbox__bar { position: fixed; top: 16px; right: 16px; display: flex; gap: 8px; z-index: 1002; }
.lightbox__btn {
  width: 44px; height: 44px; border-radius: 10px;
  background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.22);
  font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox__btn:hover { background: rgba(255,255,255,.20); }
.lightbox__btn--close { background: rgba(230,80,60,.28); border-color: rgba(230,80,60,.5); }
.lightbox__hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7); font-size: 13px; z-index: 1002;
  background: rgba(0,0,0,.4); padding: 6px 14px; border-radius: 999px; pointer-events: none;
}

/* ---------- 반응형 ---------- */
@media (max-width: 1200px) {
  .body { grid-template-columns: 210px 1fr 480px; }
  .topbar__now { font-size: 18px; }
}
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .body { display: flex; flex-direction: column; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .rgroup__grid { grid-template-columns: repeat(3, 1fr); }
  .detail { border-left: 0; border-top: 1px solid var(--line); }
  .media { aspect-ratio: 16 / 9; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
