/* ==========================================================================
   엔터프라이즈 B2B 제조·전자계약 디자인 시스템 (common.css)
   원칙: 무채색 90% (화이트·슬레이트·먹색) + 단일 브랜드 트러스트 블루(#1d4ed8) 10%
   ========================================================================== */

:root,
html[data-theme="light"] {
  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #f1f5f9;
  --text-main: #0f172a;
  --text-sub: #334155;
  --text-muted: #64748b;
  --border-col: #e2e8f0;
  --border-strong: #cbd5e1;
  --brand-primary: #1d4ed8;
  --brand-primary-hover: #1e40af;
  --brand-soft: #eff6ff;
  --brand-border: #bfdbfe;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 20px 45px -12px rgba(15, 23, 42, 0.22);
}

html[data-theme="dark"] {
  --bg-main: #0b1120;
  --bg-card: #111827;
  --bg-subtle: #1e293b;
  --bg-elevated: #0f172a;
  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #94a3b8;
  --border-col: #263348;
  --border-strong: #334155;
  --brand-primary: #3b82f6;
  --brand-primary-hover: #2563eb;
  --brand-soft: rgba(37, 99, 235, 0.14);
  --brand-border: rgba(59, 130, 246, 0.35);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 24px 48px -12px rgba(0, 0, 0, 0.65);
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  transition: background-color 0.16s ease, color 0.16s ease;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
}

/* ── 기본 서피스 & 타이포그래피 ── */
.theme-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-col);
  box-shadow: var(--shadow-card);
}

.theme-subtle {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-col);
}

.theme-text-sub {
  color: var(--text-sub);
}

.theme-text-muted {
  color: var(--text-muted);
}

/* 상단 고정 헤더 (GNB) */
header.top-nav,
header.fp-gnb {
  background-color: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-col);
  backdrop-filter: blur(10px);
}

html[data-theme="dark"] header.top-nav,
html[data-theme="dark"] header.fp-gnb {
  background-color: rgba(17, 24, 39, 0.94);
}

/* 라이트 모드에서 기존 유틸리티 텍스트 고대비 보정 */
html[data-theme="light"] .text-emerald-300,
html[data-theme="light"] .text-emerald-400,
html[data-theme="light"] .text-emerald-500 { color: #047857 !important; }
html[data-theme="light"] .text-amber-200,
html[data-theme="light"] .text-amber-300,
html[data-theme="light"] .text-amber-400,
html[data-theme="light"] .text-amber-500 { color: #b45309 !important; }
html[data-theme="light"] .text-cyan-300,
html[data-theme="light"] .text-cyan-400,
html[data-theme="light"] .text-cyan-500 { color: #1d4ed8 !important; }
html[data-theme="light"] .text-blue-300,
html[data-theme="light"] .text-blue-400 { color: #1d4ed8 !important; }
html[data-theme="light"] .text-indigo-300,
html[data-theme="light"] .text-indigo-400 { color: #3730a3 !important; }
html[data-theme="light"] .text-rose-300,
html[data-theme="light"] .text-rose-400 { color: #be123c !important; }
html[data-theme="light"] .text-slate-300 { color: #334155 !important; }
html[data-theme="light"] .text-slate-400 { color: #475569 !important; }

/* 어두운 뷰어·히어로 오버레이(.bg-slate-900 / .bg-slate-950 / .bg-black) 내부에서는 밝은 텍스트 명도 보존 */
html[data-theme="light"] .bg-slate-900 .text-slate-300,
html[data-theme="light"] .bg-slate-950 .text-slate-300,
html[data-theme="light"] .bg-black .text-slate-300 { color: #cbd5e1 !important; }
html[data-theme="light"] .bg-slate-900 .text-slate-400,
html[data-theme="light"] .bg-slate-950 .text-slate-400,
html[data-theme="light"] .bg-black .text-slate-400 { color: #94a3b8 !important; }
html[data-theme="light"] .bg-slate-900 .text-blue-300,
html[data-theme="light"] .bg-slate-950 .text-blue-300,
html[data-theme="light"] .bg-slate-900 .text-cyan-300,
html[data-theme="light"] .bg-slate-950 .text-cyan-300 { color: #93c5fd !important; }

/* .fp-btn-*, .fp-badge, .fp-sig-placeholder 등의 display 선언보다 .hidden이 항상 우선하도록 강제 */
.hidden,
[hidden] {
  display: none !important;
}

/* ── 표준 입력 필드 & 엔터프라이즈 버튼 ── */
.inp,
.fp-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  padding: 0.52rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

html[data-theme="dark"] .inp,
html[data-theme="dark"] .fp-input {
  background: var(--bg-subtle);
}

.inp:focus,
.fp-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.fp-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background-color: var(--brand-primary);
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 0.5rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.85rem;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, transform 0.08s ease;
  cursor: pointer;
}
.fp-btn-primary:hover:not(:disabled) {
  background-color: var(--brand-primary-hover);
}
.fp-btn-primary:disabled {
  background-color: #94a3b8;
  color: #f1f5f9 !important;
  cursor: not-allowed;
  opacity: 0.7;
}

.fp-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background-color: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  border-radius: 0.5rem;
  padding: 0.58rem 1rem;
  font-size: 0.82rem;
  border: 1px solid var(--border-strong);
  transition: border-color 0.15s ease, background-color 0.15s ease;
  cursor: pointer;
}
.fp-btn-secondary:hover:not(:disabled) {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background-color: var(--brand-soft);
}

/* ── 시맨틱 단색 상태 배지 (네온·이모지 배제) ── */
.fp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 0.375rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid var(--border-col);
  background-color: var(--bg-subtle);
  color: var(--text-sub);
}
.fp-badge-blue {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.fp-badge-emerald {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.fp-badge-amber {
  background-color: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.fp-badge-rose {
  background-color: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}
html[data-theme="dark"] .fp-badge-blue {
  background-color: rgba(37, 99, 235, 0.18);
  border-color: rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}
html[data-theme="dark"] .fp-badge-emerald {
  background-color: rgba(16, 185, 129, 0.16);
  border-color: rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}
html[data-theme="dark"] .fp-badge-amber {
  background-color: rgba(245, 158, 11, 0.16);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fcd34d;
}
html[data-theme="dark"] .fp-badge-rose {
  background-color: rgba(244, 63, 94, 0.16);
  border-color: rgba(251, 113, 133, 0.35);
  color: #fda4af;
}

/* ── SK 엔카 · 카파형 수평 리스트 행 & 제원 테이블 ── */
.fp-list-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.05rem 1.15rem;
  background-color: var(--bg-card);
  transition: background-color 0.12s ease;
  cursor: pointer;
}
@media (min-width: 640px) {
  .fp-list-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
  }
}
.fp-list-row:hover {
  background-color: var(--bg-subtle);
}

.fp-spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  border: 1px solid var(--border-col);
  border-radius: 0.5rem;
  overflow: hidden;
}
.fp-spec-table th,
.fp-spec-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-col);
  text-align: left;
  vertical-align: middle;
}
.fp-spec-table th {
  width: 24%;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.76rem;
}
.fp-spec-table td {
  color: var(--text-main);
  font-weight: 600;
}

/* ── 수평 슬림 공정 프로그레스 바 (6단계 스테퍼) ── */
.fp-slim-stepper {
  border: 1px solid var(--border-col);
  background-color: var(--bg-card);
  border-radius: 0.65rem;
  padding: 0.85rem 1rem;
}
.fp-slim-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
}
.fp-slim-step {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.fp-slim-bar {
  height: 4px;
  border-radius: 9999px;
  background-color: var(--border-col);
  transition: background-color 0.2s ease;
}
.fp-slim-step.is-done .fp-slim-bar { background-color: #1d4ed8; }
.fp-slim-step.is-current .fp-slim-bar { background-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); }
.fp-slim-step.is-error .fp-slim-bar { background-color: #e11d48; }
.fp-slim-label {
  font-size: 0.69rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-slim-step.is-done .fp-slim-label { color: var(--text-sub); font-weight: 700; }
.fp-slim-step.is-current .fp-slim-label { color: var(--brand-primary); font-weight: 800; }
.fp-slim-step.is-error .fp-slim-label { color: #e11d48; font-weight: 800; }

/* ── 우측 Sticky 액션 카드 ── */
@media (min-width: 1024px) {
  .fp-sticky-panel {
    position: sticky;
    top: 5.25rem;
  }
}

/* ── 모두싸인·도큐사인급 정식 A4 법률 전자계약서 뷰어 (.ec-document) ── */
.ec-sheet-frame {
  background-color: #e2e8f0;
  padding: 1.25rem;
  border-radius: 0.5rem;
}
html[data-theme="dark"] .ec-sheet-frame {
  background-color: #0f172a;
}

.ec-document {
  background-color: #ffffff !important;
  color: #0f172a !important;
  text-align: left;
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 2.25rem;
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  font-family: 'Pretendard', 'Malgun Gothic', sans-serif;
  line-height: 1.65;
  font-size: 12.5px;
}
@media (max-width: 640px) {
  .ec-sheet-frame { padding: 0.5rem; }
  .ec-document { padding: 1.15rem 1rem; font-size: 12px; }
}
.ec-doc-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.ec-doc-badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #475569 !important;
  margin-bottom: 8px;
}
.ec-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.ec-status-signed { background: #eff6ff; color: #1d4ed8 !important; border: 1px solid #bfdbfe; }
.ec-status-preview { background: #f8fafc; color: #475569 !important; border: 1px solid #cbd5e1; }
.ec-doc-title {
  margin: 0 0 5px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a !important;
  text-align: center;
}
.ec-doc-subtitle {
  margin: 0;
  font-size: 11.5px;
  color: #475569 !important;
  text-align: center;
}
.ec-section { margin-bottom: 16px; }
.ec-sec-heading {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a !important;
  background: #f8fafc;
  border-left: 3px solid #1d4ed8;
  padding: 5px 10px;
  margin: 0 0 8px;
}
.ec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.8px;
  color: #0f172a !important;
}
.ec-table th,
.ec-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 9px;
  text-align: left;
  vertical-align: middle;
  color: #0f172a !important;
}
.ec-table th {
  background: #f8fafc;
  color: #334155 !important;
  font-weight: 700;
  width: 18%;
}
.ec-table th.ec-th-group {
  width: 12%;
  text-align: center;
  background: #f1f5f9;
  color: #0f172a !important;
}
.ec-money-strong {
  font-size: 13px;
  font-weight: 800;
  color: #1d4ed8 !important;
}
.ec-clause {
  margin-bottom: 10px;
  font-size: 11.8px;
  color: #1e293b !important;
}
.ec-clause h3 {
  margin: 0 0 3px;
  font-size: 12.3px;
  font-weight: 800;
  color: #0f172a !important;
}
.ec-clause p { margin: 0 0 3px; color: #1e293b !important; }
.ec-clause ol { margin: 0; padding-left: 18px; list-style: decimal; }
.ec-clause li { margin-bottom: 2.5px; color: #1e293b !important; }
.ec-sign-declaration {
  font-size: 11.8px;
  font-weight: 700;
  color: #0f172a !important;
  margin: 0 0 10px;
}
.ec-sign-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) {
  .ec-sign-grid { grid-template-columns: 1fr; }
}
.ec-sign-box {
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 12px;
  background: #ffffff !important;
}
.ec-sign-role {
  font-size: 11px;
  font-weight: 800;
  color: #1d4ed8 !important;
  margin-bottom: 3px;
}
.ec-sign-company {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a !important;
  margin-bottom: 3px;
}
.ec-sign-meta {
  font-size: 11.2px;
  color: #475569 !important;
  margin-bottom: 2px;
}
.ec-sign-canvas-wrap {
  margin-top: 8px;
  min-height: 82px;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.ec-sign-img {
  max-height: 76px;
  max-width: 100%;
  object-fit: contain;
}
.ec-sign-placeholder {
  font-size: 11px;
  color: #64748b !important;
  text-align: center;
}
.ec-audit-box {
  margin-top: 16px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  color: #0f172a !important;
}
.ec-audit-title {
  font-weight: 800;
  color: #0f172a !important;
  margin-bottom: 6px;
  font-size: 11.5px;
}
.ec-audit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}
@media (max-width: 600px) {
  .ec-audit-grid { grid-template-columns: 1fr; }
}
.ec-audit-grid > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ec-audit-grid span { color: #64748b !important; }
.ec-audit-grid strong,
.ec-audit-grid code {
  color: #0f172a !important;
  word-break: break-all;
  font-size: 11px;
}
.ec-audit-wide { grid-column: 1 / -1; }

/* ── HTML5 자필 전자서명 패드 위젯 (.fp-sig-pad) ── */
.fp-sig-widget {
  border: 1px solid var(--border-strong);
  border-radius: 0.6rem;
  background-color: var(--bg-card);
  padding: 0.85rem;
}
.fp-sig-canvas-shell {
  position: relative;
  border: 1.5px dashed #94a3b8;
  border-radius: 0.5rem;
  background-color: #ffffff !important;
  overflow: hidden;
  touch-action: none;
}
.fp-sig-canvas {
  display: block;
  width: 100%;
  height: 128px;
  cursor: crosshair;
  touch-action: none;
}
.fp-sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
}

/* ── 공통 신뢰 푸터 ── */
.fp-trust-footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-col);
  margin-top: auto;
}

/* ── 비침투형 순수 진행률 바 & 완료 자동 반영 토스트 ── */
.fp-progress-track {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-col);
  overflow: hidden;
}

.fp-progress-track-sm {
  height: 6px;
}

.fp-progress-bar {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 60%, #1d4ed8 100%);
  background-size: 200% 100%;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  animation: fpProgressShimmer 2.2s linear infinite;
}

.fp-progress-bar.is-done {
  background: #059669;
  animation: none;
}

/* 가격 방식 선택 카드 — 고른 카드 테두리 강조 */
.fp-mode-option:has(input:checked) {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 1px var(--brand-primary) inset;
}

/* 진행률을 알 수 없는 구간(대기·한 번의 요청으로 끝나는 작업) — 숫자 없이 움직이는 막대만 보여 줌 (가짜 % 금지) */
.fp-progress-bar.is-indeterminate {
  width: 35% !important;
  transition: none;
  animation: fpProgressIndeterminate 1.3s ease-in-out infinite;
}

@keyframes fpProgressIndeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(290%); }
}

@media (prefers-reduced-motion: reduce) {
  .fp-progress-bar, .fp-progress-bar.is-indeterminate { animation: none; }
}

@keyframes fpProgressShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.fp-toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(23rem, calc(100vw - 2rem));
  pointer-events: none;
}

.fp-toast-card {
  pointer-events: auto;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--brand-border);
  border-left: 4px solid var(--brand-primary);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-modal);
  animation: fpToastSlideUp 0.22s ease-out;
}

@keyframes fpToastSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 카드 강조 애니메이션 */
@keyframes orderHighlightPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(29, 78, 216, 0); }
}
.order-card-highlight {
  animation: orderHighlightPulse 1.5s ease-in-out 3;
  border-color: var(--brand-primary) !important;
  border-width: 2px !important;
}
