/* ============================================================
   Algorithm Labs Design System V2.1 — Page Layout
   Extracted from reference/ui_kit/ai_blueprint.html (브랜드 가이드라인 일치)
   토큰 의존: colors_and_type.css 에 :root 변수 정의됨
   ============================================================ */

body { background: var(--gray-010); overflow: hidden; }

/* ── App grid ── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "brand topbar" "nav main";
  height: 100vh;
}
/* Rail mode — 60px 폭의 아이콘 전용 사이드바.
   햄버거로 토글, 사용자 선택은 localStorage 에 영속 (hooks/useSidebar). */
.app.nav-collapsed { grid-template-columns: 60px 1fr; }
.app.nav-collapsed .brand { padding: 0; justify-content: center; }
.app.nav-collapsed .brand img { display: none; }

/* 카테고리 헤더 + 카운트 chip 숨김 */
.app.nav-collapsed .nav-title,
.app.nav-collapsed .nav-item .ct { display: none; }

/* nav-item: 아이콘만 중앙 정렬, 라벨 hidden (title 속성이 tooltip) */
.app.nav-collapsed .nav-item {
  padding: 11px 0;
  justify-content: center;
  gap: 0;
  border-left-width: 0;
  border-right: 3px solid transparent;
}
.app.nav-collapsed .nav-item.active {
  border-left-width: 0;
  border-right-color: var(--blue-050);
}
.app.nav-collapsed .nav-item .label { display: none; }

/* CTA: 정사각 아이콘 버튼 */
.app.nav-collapsed .nav-top {
  padding: 6px 8px 12px;
}
.app.nav-collapsed .nav-cta {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 auto;
  gap: 0;
}
.app.nav-collapsed .nav-cta .label { display: none; }

/* ── Brand corner ── */
.brand {
  grid-area: brand;
  background: #fff;
  border-right: 1px solid var(--gray-020);
  border-bottom: 1px solid var(--gray-020);
  display: flex;
  align-items: center;
  padding: 0 20px;
}
.brand img { height: 32px; }

/* ── Topbar ── */
.topbar {
  grid-area: topbar;
  background: #fff;
  border-bottom: 1px solid var(--gray-020);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
}
.crumb { font-size: 13px; color: var(--gray-070); }
.crumb b { color: var(--navy-060); }
.topbar .sp { flex: 1; }
.topbar [data-icon],
.topbar > .icon-btn [data-icon] {
  width: 20px;
  height: 20px;
  color: var(--gray-070);
  display: inline-flex;
}
.topbar [data-icon] svg { width: 100%; height: 100%; }
.icon-btn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--gray-070);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { color: var(--navy-060); }
.av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2EB7FF, #0276E3);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ── Hamburger toggle ── */
.navToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-right: 6px;
  border: 1px solid var(--gray-030);
  border-radius: 6px;
  background: #fff;
  color: var(--navy-060);
  cursor: pointer;
  transition: background .14s, border-color .14s;
}
.navToggle:hover {
  background: var(--gray-010);
  border-color: var(--gray-050);
}
.navToggle [data-icon] { width: 16px; height: 16px; }
.navToggle [data-icon] svg { width: 100%; height: 100%; }

/* ── Role / Datasw toggles (시연용) ── */
.role,
.datasw {
  display: inline-flex;
  background: var(--gray-010);
  border-radius: 99px;
  padding: 3px;
  border: 1px solid var(--gray-030);
  font-size: 11px;
  font-weight: 700;
}
.role span,
.datasw span {
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
  color: var(--gray-070);
  user-select: none;
}
.role span.on { background: var(--blue-050); color: #fff; }
.datasw span.on { background: var(--navy-060); color: #fff; }

/* ── Nav ── */
.nav {
  grid-area: nav;
  background: #fff;
  border-right: 1px solid var(--gray-020);
  padding: 14px 0 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .92px;
  color: var(--gray-070);
  text-transform: uppercase;
  padding: 10px 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--navy-060);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .14s;
  user-select: none;
  text-decoration: none;
}
.nav-item [data-icon] {
  width: 18px;
  height: 18px;
  color: var(--gray-070);
  display: inline-flex;
}
.nav-item [data-icon] svg { width: 100%; height: 100%; }
.nav-item:hover { background: var(--gray-010); }
.nav-item.active {
  background: #E5F4FF;
  color: var(--blue-060);
  border-left-color: var(--blue-050);
  font-weight: 700;
}
.nav-item.active [data-icon] { color: var(--blue-050); }
.nav-item .ct {
  margin-left: auto;
  font-family: var(--font-numeric);
  font-size: 11px;
  color: var(--gray-060);
}
.nav-item.active .ct { color: var(--blue-050); }

/* ── Nav top slot CTA ── */
.nav-top {
  padding: 6px 16px 14px;
  border-bottom: 1px solid var(--gray-020);
  margin-bottom: 10px;
}
.nav-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: linear-gradient(135deg, #2EB7FF 0%, #0099FE 100%);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition: filter .14s, transform .14s;
  text-decoration: none;
}
.nav-cta:hover { filter: brightness(1.05); }
.nav-cta:active { transform: translateY(1px); }
.nav-cta [data-icon] { width: 16px; height: 16px; color: #fff; display: inline-flex; }
.nav-cta [data-icon] svg { width: 100%; height: 100%; }

/* ── Main ── */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 32px 40px;
  background: var(--gray-010);
}
/* SSPDetail 처럼 풀스크린 layout 페이지는 자기 자체 스크롤 컨테이너를 가짐.
   부모 .main 이 overflow-y: auto 면 자식 패널 스크롤이 부모로 전파되어 끊김.
   flush 모드에서는 main 의 스크롤을 끄고 자식이 책임. */
.main.flush { padding: 0; overflow: hidden; }

/* ── Page header ── */
.pageH {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.pageH h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy-050);
  margin: 0;
  letter-spacing: -0.01em;
}
.pageH p {
  color: var(--gray-070);
  font-size: 13px;
  margin-top: 6px;
}
[data-icon] { display: inline-flex; }
[data-icon] svg { width: 100%; height: 100%; }

/* ── KPI cards ── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--gray-020);
  border-radius: var(--r-sm);
  padding: 18px 20px;
  box-shadow: var(--shadow-regular);
}
.kpi .lab {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--gray-070);
}
.kpi .val {
  font-family: var(--font-numeric);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin: 8px 0 4px;
  color: var(--navy-050);
}
.kpi .delta { font-size: 11px; color: var(--gray-070); }
.kpi.green .val { color: var(--phase-p3-text); }
.kpi.orange .val { color: var(--phase-p2); }
.kpi.blue .val { color: var(--blue-050); }
.kpi.navy .val { color: var(--navy-050); }

/* ── Panel ── */
.panel {
  background: #fff;
  border: 1px solid var(--gray-020);
  border-radius: var(--r-sm);
  padding: 20px;
}
.panel h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-060);
  margin: 0 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel .more {
  font-size: 12px;
  color: var(--blue-050);
  cursor: pointer;
  font-weight: 700;
}

/* ── Table ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--gray-070);
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-030);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-020);
  color: var(--navy-060);
}
tr:last-child td { border-bottom: none; }
tr.row-hover:hover { background: var(--gray-010); cursor: pointer; }

/* ── Phase pill ── */
.pp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.pp.draft { background: #F0F1F2; color: #304156; }
.pp.gap { background: #E5F4FF; color: #0276E3; }
.pp.act { background: #E8F8EE; color: #1f8a47; }
.pp.danger { background: #FEEFEF; color: #B00020; }
.pp.info { background: #E5F4FF; color: #0276E3; }

/* ── Phase status block (SSP detail header) ── */
.pstatus {
  background: #FAFBFB;
  border: 1px solid var(--gray-020);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.pstatus .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.pstatus .stage-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--gray-070);
}
.pstatus .stage-now {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-060);
}
.pstatus .stage-now b { color: var(--phase-p2); }
.pstatus .next { font-size: 12px; color: var(--gray-070); }
.pstatus .next .cta {
  color: var(--blue-050);
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
}

/* ──────────────────────────────────────────────────────────────────────
 * Segmented progress bar — StageProgress
 * 3-phase 진행 바 (P1/P2/P3). 완료 = mint 채움, 현재 = blue 부분 채움 (%),
 * 대기 = gray. mockup: /mockups/stage-stepper.html Variant A.
 * ────────────────────────────────────────────────────────────────────── */
.segbar { padding: 2px 0; }
.segbar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.segbar-head .lbl {
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--gray-070);
  font-weight: 700;
  margin-bottom: 4px;
}
.segbar-head .left { min-width: 0; }
.segbar-head .left .stage-now {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy-060);
  line-height: 1.3;
}
.segbar-head .left .stage-now .ct {
  color: var(--blue-070);
  margin-left: 6px;
}
.segbar-head .left .stage-now.done { color: var(--phase-p3-text); }
.segbar-head .left .stage-now.failed { color: var(--state-danger); }
.segbar-head .right { text-align: right; min-width: 0; }
.segbar-head .right .next {
  font-size: 13px;
  color: var(--navy-060);
  font-weight: 500;
  line-height: 1.3;
}
.segbar-head .right .next a {
  color: var(--blue-050);
  font-weight: 700;
  margin-left: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.segbar-head .right .next a [data-icon] {
  width: 12px;
  height: 12px;
}
.segbar-head .right .next a:hover { text-decoration: underline; }

.segbar-track {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.segbar-seg {
  height: 10px;
  border-radius: 99px;
  background: var(--gray-030);
  transition: background var(--d-normal) var(--ease-standard);
}
.segbar-seg.done { background: var(--phase-p3); }
.segbar-seg.active {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    to right,
    var(--blue-050) var(--fill, 50%),
    var(--blue-030) var(--fill, 50%)
  );
}
/* "작동 중" 시각 신호 — 활성 segment 위로 가벼운 sheen 이 좌→우 이동.
   substep 갱신 없이 같은 % 에 오래 머무는 동안 (e.g., gap_orchestrator 1~3분)
   사용자가 "멈춤" 으로 오해하지 않도록. */
.segbar-seg.active::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 25%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  animation: segbarShine 2.4s linear infinite;
  pointer-events: none;
}
/* waiting: 사용자 입력 대기 (gap_pending) — LLM 안 돌므로 shine 억제. */
.segbar-seg.active.waiting::after { display: none; }
@keyframes segbarShine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(500%); }
}
.segbar-seg.failed { background: var(--state-danger); }

.segbar-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
}
.segbar-labels > div { display: flex; }
.segbar-labels > div:nth-child(1) { justify-content: flex-start; }
.segbar-labels > div:nth-child(2) { justify-content: center; }
.segbar-labels > div:nth-child(3) { justify-content: flex-end; }
.segbar-lbl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.segbar-lbl.done    { color: var(--phase-p3-text); }
.segbar-lbl.active  { color: var(--blue-070); }
.segbar-lbl.pending { color: var(--gray-070); }
.segbar-lbl.failed  { color: var(--state-danger); }
.segbar-lbl [data-icon] { width: 13px; height: 13px; }
.segbar-lbl .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-050);
  display: inline-block;
}
/* active 라벨의 dot 가 가볍게 호흡 — 작동 중 보조 시각 신호. */
.segbar-lbl.active .dot {
  animation: segbarDotPulse 1.6s ease-in-out infinite;
}
@keyframes segbarDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.7); }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy-060);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(48, 65, 86, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  color: var(--content-tertiary);
  text-align: center;
}
.empty-state [data-icon] {
  width: 48px;
  height: 48px;
  color: var(--gray-050);
}
.empty-state [data-icon] svg { width: 100%; height: 100%; }
.empty-state h3 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--t-headline);
  color: var(--navy-050);
}
.empty-state p {
  margin: 0;
  font-size: var(--t-body-2);
  color: var(--content-tertiary);
  max-width: 360px;
  line-height: var(--leading-snug);
}
.empty-state .btn,
.empty-state .nav-cta { margin-top: 4px; }
.empty-state--compact {
  padding: 32px 16px;
  gap: 8px;
}
.empty-state--compact [data-icon] { width: 28px; height: 28px; }
.empty-state--compact h3 { font-size: var(--t-subheadline); }
.empty-state--compact p { font-size: var(--t-caption-1); }
.empty-state--danger [data-icon] { color: var(--state-danger); }
.empty-state--danger h3 { color: var(--state-danger); }

/* ────────────────────────────────────────────────────────────────────
 * Context menu — Pipeline 우클릭 (Week 2 Step 5)
 * ──────────────────────────────────────────────────────────────────── */
.context-menu {
  background: var(--white);
  border: 1px solid var(--border-secondary);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-drawer-l);
  padding: 4px;
  z-index: 200;
  min-width: 180px;
  display: flex;
  flex-direction: column;
}
.context-menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: var(--navy-050); font-size: var(--t-body-2);
  text-align: left;
}
.context-menu button:hover { background: var(--gray-010); }

/* ────────────────────────────────────────────────────────────────────
 * Mention autocomplete dropdown — CommentTab (Week 3 Step 1)
 * ──────────────────────────────────────────────────────────────────── */
.mention-dropdown {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--white);
  border: 1px solid var(--border-secondary);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-drawer-l);
  padding: 4px;
  z-index: 200;
  min-width: 160px;
  display: flex;
  flex-direction: column;
}
.mention-dropdown button {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: var(--navy-050); font-size: var(--t-body-2);
  text-align: left; border-radius: var(--r-xs);
}
.mention-dropdown button:hover,
.mention-dropdown button[data-active="true"] { background: var(--gray-010); }

/* ────────────────────────────────────────────────────────────────────
 * Upload page — 3 진입 방법 (영상 / 템플릿 / 대화)
 * 영상 = 활성, 템플릿·대화 = SOON (비활성 미리보기).
 * ──────────────────────────────────────────────────────────────────── */
.upload-wrap { max-width: 780px; margin: 0 auto; }

.uploadTabs {
  display: flex;
  gap: 2px;
  background: var(--gray-010);
  border: 1px solid var(--gray-020);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}
.uploadTab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-070);
  cursor: pointer;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .14s, color .14s;
}
.uploadTab:hover { color: var(--navy-060); }
.uploadTab.on {
  background: #fff;
  color: var(--navy-060);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(48, 65, 86, 0.08);
}
.uploadTab .soonPill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .6px;
  background: #E5F4FF;
  color: #0276E3;
  padding: 2px 6px;
  border-radius: 99px;
  text-transform: uppercase;
}
.uploadTab.on .soonPill { background: var(--blue-050); color: #fff; }

.uploadTabPanel { display: none; }
.uploadTabPanel.on { display: block; }

/* 비활성 안내 배너 (템플릿 / 대화 패널 상단) */
.tplBanner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #E5F4FF;
  border: 1px solid #9ED9FF;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13px;
  color: #025EB6;
}
.tplBanner b { color: var(--navy-060); font-weight: 700; }
.tplBanner .ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  color: var(--blue-050);
}
.tplBanner .ico [data-icon] svg { width: 100%; height: 100%; }

/* 클릭/선택 불가 미리보기 컨테이너 */
.tplDisable { position: relative; pointer-events: none; user-select: none; }
.tplDisable > * { opacity: .62; }

/* 영상 업로드: dropzone + 입력 카드 */
.dropzone {
  border: 2px dashed var(--gray-040);
  border-radius: var(--r-md);
  background: #fff;
  padding: 60px 32px;
  text-align: center;
  transition: all .14s;
}
.dropzone:hover {
  border-color: var(--blue-050);
  background: #F7FBFF;
}
.dropzone .icon {
  display: inline-flex;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #E5F4FF;
  color: var(--blue-050);
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.dropzone .icon [data-icon] { width: 32px; height: 32px; }
.dropzone .icon [data-icon] svg { width: 100%; height: 100%; }
.dropzone h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-060);
  margin: 0 0 8px;
}
.dropzone p { font-size: 13px; color: var(--gray-070); margin: 0; }

.upload-form {
  margin-top: 24px;
  background: #fff;
  border: 1px solid var(--gray-020);
  border-radius: var(--r-sm);
  padding: 24px;
}
.field-wrap { margin-bottom: 18px; }
.field-wrap label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-060);
  margin-bottom: 6px;
}
.field-wrap .field { width: 100%; box-sizing: border-box; }
.field-wrap textarea.field {
  min-height: 90px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}
.field-wrap .help { font-size: 11px; color: var(--gray-070); margin-top: 4px; }
.field {
  border: 1px solid var(--gray-030);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--navy-060);
  background: #fff;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.field:focus {
  border-color: var(--blue-050);
  box-shadow: 0 0 0 3px rgba(0, 153, 254, 0.15);
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}
