/* =============================================================
   LinkBuilder — 페이지(앱) 레이아웃
   design-system.css의 토큰만 사용. 컴포넌트가 아닌 화면 레이아웃 전용.
   ============================================================= */

/* ---------- Topbar ---------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--ink-200);
}
.app-topbar .bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-brand { display: flex; align-items: center; gap: 10px; }
.app-brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--brand-600);
  color: #fff;
}
.app-brand .logo svg { width: 20px; height: 20px; }
.app-brand .name { font-size: 17px; font-weight: 700; color: var(--ink-900); letter-spacing: -.01em; }
.app-brand .sub { font-size: 12px; color: var(--ink-400); margin-top: 1px; }

/* 페이지 전환 네비게이션 */
.app-nav { display: flex; gap: 4px; margin-left: auto; }
.app-nav-link {
  padding: 7px 14px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500; color: var(--ink-500);
  transition: background .12s ease, color .12s ease;
}
.app-nav-link:hover { background: var(--ink-100); color: var(--ink-800); }
.app-nav-link.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

/* ---------- Page container (콘텐츠 + 우측 스텝 레일) ---------- */
.app-main {
  min-width: 1100px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 40px;
  align-items: start;
}
.app-content { min-width: 0; }

/* ---------- 우측 진행 단계 스텝퍼 ---------- */
.stepper-rail { position: sticky; top: 88px; }
.rail-title {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-400); margin-bottom: 18px;
}
.stepper { list-style: none; margin: 0; padding: 0; }
.stepper .step { position: relative; display: flex; gap: 12px; padding-bottom: 26px; }
.stepper .step:last-child { padding-bottom: 0; }
/* 단계 연결선 */
.stepper .step::before {
  content: ""; position: absolute; left: 13px; top: 30px; bottom: 4px;
  width: 2px; background: var(--ink-200);
}
.stepper .step:last-child::before { display: none; }
.stepper .step.is-done::before { background: var(--brand-600); }

.step-dot {
  flex: none; position: relative; z-index: 1;
  width: 28px; height: 28px; border-radius: var(--r-full);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: #fff; border: 2px solid var(--ink-200); color: var(--ink-400);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.step.is-active .step-dot { border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }
.step.is-done .step-dot { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.step.is-done .step-num { display: none; }
.step.is-done .step-dot::after {
  content: ""; width: 12px; height: 12px;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>") center / contain no-repeat;
}

.step-text { display: flex; flex-direction: column; gap: 2px; padding-top: 3px; }
.step-title { font-size: 14px; font-weight: 600; color: var(--ink-500); }
.step.is-active .step-title, .step.is-done .step-title { color: var(--ink-900); }
.step-desc { font-size: 12px; color: var(--ink-400); line-height: 1.4; }

@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; gap: 0; }
  .stepper-rail { display: none; }
}
.page-head { margin-bottom: 24px; }
.page-head p { margin-top: 6px; color: var(--ink-500); line-height: 1.6; }

/* ---------- Step / section ---------- */
.section + .section { margin-top: 24px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.step-no {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--brand-600);
  color: #fff;
  font-size: 13px; font-weight: 700;
}
.section-head .step-no.is-done { background: var(--success); }
/* 제목 옆 info 툴팁 아이콘 */
.section-head .tooltip {
  display: inline-flex;
  align-items: center;
  color: var(--ink-400);
  cursor: help;
  transition: color .12s ease;
}
.section-head .tooltip:hover,
.section-head .tooltip:focus-visible { color: var(--brand-600); }

/* ---------- Field grid ---------- */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.field-grid .col-full { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
}

/* 그리드 안에서는 .field 세로 자동간격 대신 grid gap 사용 */
.field-grid .field + .field { margin-top: 0; }

/* ---------- Selected project banner ---------- */
.project-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--brand-100);
  background: var(--brand-50);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
}
.project-banner .meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-banner .p-name { font-weight: 600; color: var(--brand-900); }
.project-banner .p-id { font-size: 12px; color: var(--brand-700); opacity: .8; }

/* ---------- Result ---------- */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.result-actions { display: flex; gap: 8px; }
.result-title { display: flex; align-items: center; gap: 6px; }
.result-title .tooltip { display: inline-flex; color: var(--ink-400); cursor: help; }
.result-title .tooltip:hover, .result-title .tooltip:focus-visible { color: var(--brand-600); }
/* 긴 설명은 여러 줄로 감싸 폭 제한 */
.result-title .tooltip::after { white-space: normal; width: 280px; line-height: 1.55; text-align: left; }

/* codeblock 안 URL 줄바꿈 */
.codeblock code { white-space: pre-wrap; word-break: break-all; }

.hidden { display: none !important; }

/* 프로젝트 옵션의 상태 배지 — 축소 방지 */
.select-option .badge { flex: none; }
.select-option .opt-name { font-weight: 500; }

/* 멀티셀렉트 요약 모드(선택 N개) — 선택됨을 브랜드 색으로 */
.ms-summary { color: var(--brand-700); font-weight: 600; }

/* 생성 결과 요약 줄: 배지(좌) + 검증 유도 안내(우) */
.result-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.verify-hint {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--brand-700); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.verify-hint svg { width: 15px; height: 15px; flex: none; color: var(--brand-600); }

/* ---------- 광고 단위: 캐스케이딩 리스트박스 (4열 리스트 패널) ---------- */
.mcol-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .mcol-grid { grid-template-columns: 1fr; } }

.mcol {
  display: flex; flex-direction: column;
  height: 288px; min-width: 0;
  border: 1px solid var(--ink-200); border-radius: var(--r-lg);
  background: #fff; overflow: hidden;
}
.mcol-head {
  flex: none; padding: 9px 12px; border-bottom: 1px solid var(--ink-100);
  font-size: 13px; font-weight: 600; color: var(--ink-800);
  display: flex; align-items: center; gap: 6px;
}
.mcol-count { color: var(--brand-600); font-weight: 600; }
.mcol-head .req { color: var(--danger); }   /* 필수 * — .label 밖이라 별도 지정 */
.mcol-all {
  margin-left: auto; flex: none;
  border: 1px solid var(--brand-200); background: var(--brand-50);
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; color: var(--brand-700); cursor: pointer;
  transition: background .12s ease;
}
.mcol-all:hover { background: var(--brand-100); }
.mcol-all.is-on { color: var(--ink-600); background: var(--ink-100); border-color: var(--ink-200); }
.mcol-search {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid var(--ink-100); color: var(--ink-400);
}
.mcol-search svg { width: 15px; height: 15px; flex: none; }
.mcol-search input { border: none; outline: none; background: transparent; width: 100%; font: inherit; font-size: 13px; color: var(--ink-800); }
.mcol-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; }
.mcol-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--ink-700); line-height: 1.35;
}
.mcol-item:hover { background: var(--brand-50); }
.mcol-item.is-selected { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.mcol-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.mcol-sub { color: var(--ink-400); font-weight: 400; }
.mcol-box {
  flex: none; width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--ink-300); display: grid; place-items: center;
  color: transparent; transition: background .1s, border-color .1s;
}
.mcol-box svg { width: 11px; height: 11px; }
.mcol-item.is-selected .mcol-box { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.mcol-empty { padding: 14px 10px; color: var(--ink-400); font-size: 13px; text-align: center; }
/* 로딩 상태 — 스피너 + 텍스트 */
.mcol-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px 12px; color: var(--brand-600); font-size: 13px; font-weight: 600;
}
.mcol-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--brand-100); border-top-color: var(--brand-600);
  animation: mcolSpin .7s linear infinite;
}
@keyframes mcolSpin { to { transform: rotate(360deg); } }

.select-path { color: var(--ink-500); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

/* ---------- 대량 생성 ---------- */
.bulk-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.dropzone.is-dragover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}

.bulk-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

#bulk-tbody .row-error td { background: color-mix(in srgb, var(--danger-bg, #fef2f2) 60%, #fff); }
/* 링크 셀: 좁게 유지하고 말줄임(전체 링크는 title 툴팁 + 끝의 열기/복사로 확인) */
#bulk-tbody .cell-link,
#result-tbody .cell-link { max-width: 260px; }
#bulk-tbody .cell-link .cell-mono,
#result-tbody .cell-link .cell-mono { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; cursor: help; }

.bulk-copy.is-copied { color: var(--success); }
#bulk-tbody .row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
#bulk-tbody .row-actions .btn-sm { padding: 0 8px; }

.text-danger { color: var(--danger); }

/* 최종 검수 카드 하단 등록 바 */
.review-foot { margin-top: 16px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-foot .badge { flex: none; }

/* 미리보기 파라미터 요약 표 여백 */
.section .table-wrap { margin-top: 4px; }

/* 스크롤바 유무로 인한 가로폭 흔들림 방지 — 스크롤바 공간을 항상 확보 */
html { scrollbar-gutter: stable; }

/* ---------- Sticky footer (짧은 페이지에서도 푸터를 하단에 고정) ---------- */
body { min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar, .app-footer { flex-shrink: 0; }
.app-main { flex: 1 0 auto; }

/* ---------- App footer ---------- */
.app-footer { border-top: 1px solid var(--ink-200); background: #fff; margin-top: 40px; }
.app-footer .bar {
  max-width: 1180px; margin: 0 auto; padding: 14px 24px;
  display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: space-between;
}
@media (min-width: 768px) { .app-footer .bar { flex-direction: row; } }

/* 검증 진행 중 '중단' 버튼(위험색) */
#verify-btn.is-cancel, #bulk-verify.is-cancel { background: var(--danger); border-color: var(--danger); color: #fff; }
#verify-btn.is-cancel:hover, #bulk-verify.is-cancel:hover { filter: brightness(.95); }
