/* 민원·생활지도 답변서 도우미 - 모던 업무툴 스타일 v2.2 */

/* 디자인 토큰 */
:root {
  --bg-app: #f6f7fb;
  --bg-panel: #ffffff;
  --bg-surface: #fafbfd;
  --bg-subtle: #f3f4f7;
  --border-soft: #e6e8ef;
  --border-mid: #d7dae4;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px -2px rgba(15, 23, 42, 0.08);
  --radius-md: 10px;
  --radius-lg: 14px;
}

html, body {
  background: var(--bg-app);
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR',
    'Apple SD Gothic Neo', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
}

/* 앱 셸 레이아웃 - 사이드바 + 메인 */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

.side-nav {
  background: #ffffff;
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .side-nav {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
@media (max-width: 1024px) {
  .brand { border-bottom: none; margin-bottom: 0; padding: 0 8px; }
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
}

.brand-text .title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.brand-text .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 8px 6px;
}
@media (max-width: 1024px) {
  .nav-section-label { display: none; }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
}
.nav-item i {
  width: 16px;
  color: inherit;
  font-size: 13px;
}

/* 메인 콘텐츠 */
.main-content {
  padding: 24px 28px 40px;
  max-width: 1380px;
  width: 100%;
}
@media (max-width: 768px) {
  .main-content { padding: 16px; }
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.top-bar h1 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.top-bar .desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* 모드 토글(세그먼트) */
.mode-seg {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border-soft);
}
.mode-seg button {
  background: transparent;
  border: none;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode-seg button:hover { color: var(--text-primary); }
.mode-seg button.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* 패널 (카드) */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.panel-header h2 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.panel-header h2 i { color: var(--accent); font-size: 13px; }
.panel-body { padding: 18px; }

/* 입력 필드 모던화 */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.input, .select, .textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
  transition: border 0.12s, box-shadow 0.12s;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.textarea { resize: vertical; line-height: 1.55; }
.input-mono { font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace; font-size: 12px; }

/* 버튼 모던화 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.14s ease;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-mid);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

/* 키 입력 특수 블록 */
.key-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
}
.key-block + .key-block { margin-top: 10px; }
.key-block .k-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.key-block .k-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 6px;
}
.key-block .k-title i { color: var(--accent); font-size: 12px; }
.key-block .k-status {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 500;
}
.key-block .k-status.ok { background: #ecfdf5; color: #047857; }
.key-block .k-status.warn { background: #fffbeb; color: #b45309; }
.key-block .k-status.bad { background: #fef2f2; color: #b91c1c; }

/* 탭 버튼 스타일 */
.tab-btn {
  color: #64748b;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: #2563eb;
  background: #f1f5f9;
}

.tab-btn.active-tab {
  color: #2563eb;
  background: #ffffff;
  border-color: #e2e8f0;
  margin-bottom: -1px;
  font-weight: 600;
}

/* 결과 카드 */
.result-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.result-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-card-title i {
  color: #3b82f6;
}

/* 복사 버튼 */
.copy-btn {
  font-size: 0.75rem;
  padding: 4px 10px;
  background: #f1f5f9;
  color: #475569;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background: #e0e7ff;
  color: #3730a3;
  border-color: #c7d2fe;
}

.copy-btn.copied {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

/* 칩(뱃지) */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

.chip-amber {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.chip-green {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.chip-red {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.chip-slate {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

/* 드래프트 본문 - 공문 느낌 */
.draft-body {
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 0.9rem;
  color: #1e293b;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'Pretendard', 'Malgun Gothic', -apple-system, sans-serif;
}

/* 민원번호 플레이스홀더 하이라이트 */
.placeholder-mark {
  background: #fde68a;
  color: #92400e;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px dashed #f59e0b;
  font-weight: 600;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.85em;
}

/* 민원번호 + 담당자 정보 입력 박스 */
.complaint-id-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

/* 플레이스홀더 입력 그리드 */
.ph-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 4px;
}

@media (min-width: 900px) {
  .ph-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.ph-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 4px 6px 4px 8px;
}

.ph-label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-width: 88px;
}

.ph-key {
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: #92400e;
  background: #fde68a;
  padding: 1px 5px;
  border-radius: 3px;
}

.ph-count {
  font-size: 10px;
  color: #b45309;
  font-weight: 500;
}

.ph-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11.5px;
  font-family: 'Pretendard', 'Malgun Gothic', -apple-system, sans-serif;
  outline: none;
  background: #fafafa;
}

.ph-input:focus {
  border-color: #f59e0b;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.ph-hint {
  font-size: 10px;
  color: #d97706;
  width: 14px;
  text-align: center;
}

.ph-hint-muted {
  color: #cbd5e1;
}

/* 리스크 항목 */
.risk-item {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
}

.risk-item.risk-legal {
  border-left-color: #dc2626;
  background: #fef2f2;
}

.risk-item .risk-original {
  font-size: 0.85rem;
  color: #78350f;
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 6px 0;
  border: 1px dashed #fcd34d;
}

.risk-item.risk-legal .risk-original {
  color: #7f1d1d;
  border-color: #fca5a5;
}

.risk-item .risk-safer {
  font-size: 0.85rem;
  color: #065f46;
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 6px;
  border-left: 3px solid #10b981;
}

/* 법령 리스트 */
.law-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.law-item:hover {
  background: #f1f5f9;
}

/* 검증 결과 */
.verify-item {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 8px;
  background: #ffffff;
}

.verify-item.verify-valid {
  border-left: 4px solid #10b981;
}
.verify-item.verify-invalid {
  border-left: 4px solid #dc2626;
  background: #fef2f2;
}
.verify-item.verify-unverifiable {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
}

/* 리스트 기본 */
.key-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.key-list li {
  position: relative;
  padding: 4px 0 4px 20px;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.55;
}
.key-list li::before {
  content: '\f105';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #3b82f6;
  position: absolute;
  left: 4px;
  top: 5px;
}

/* Provider 선택 옵션 (라디오 카드) */
.provider-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.8rem;
  color: #475569;
}

.provider-option:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.provider-option input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.provider-option span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.provider-option span i {
  color: #64748b;
}

.provider-option input[type='radio']:checked ~ span {
  color: #1d4ed8;
  font-weight: 600;
}

.provider-option input[type='radio']:checked ~ span i {
  color: #2563eb;
}

.provider-option:has(input[type='radio']:checked) {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* 반응형 스크롤 */
@media (max-width: 1024px) {
  aside.lg\:sticky {
    position: static !important;
  }
}

/* 출력 섹션 프린트 스타일 */
@media print {
  aside,
  .tab-btn,
  footer,
  header {
    display: none !important;
  }
  main {
    border: none !important;
    box-shadow: none !important;
  }
}
