/* ==========================================================================
   DocuScan AI — LG U+ 프리미엄 디자인 시스템
   스캔 문서 VLM 분석 서비스를 위한 메인 스타일시트
   ========================================================================== */

/* --------------------------------------------------------------------------
   Noto Sans KR & Nanum Gothic 웹폰트 임포트 — 글로벌 표준 한글 폰트
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Nanum+Gothic:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

/* --------------------------------------------------------------------------
   CSS 커스텀 속성 (디자인 토큰)
   -------------------------------------------------------------------------- */
:root, [data-theme="light"] {
  /* 브랜드 컬러 — 2안: Muted Rose (차분한 와인/장미색) */
  --primary: #BE185D;
  --primary-dark: #9F1239;
  --primary-light: #F472B6;

  /* 배경 컬러 — 2안: Premium Slate (따뜻한 웜그레이/스톤 기반) */
  --bg-main: #FAFAF9;
  --bg-card: #FFFFFF;
  --bg-hover: #F5F5F4;
  --bg-surface: #FFFFFF;

  /* 보더 & 구분선 */
  --border: #E7E5E4;
  --border-active: var(--primary);

  /* 텍스트 컬러 — 따뜻한 톤의 Stone 계열 */
  --text-primary: #1C1917;
  --text-secondary: #78716C;
  --text-muted: #A8A29E;

  /* 시맨틱 컬러 */
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;

  /* 공통 스타일 토큰 (라이트 섀도우) */
  --gradient: linear-gradient(135deg, var(--primary), var(--primary-dark));
  --gradient-hover: linear-gradient(135deg, var(--primary-light), var(--primary));
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.05);
  --shadow-primary: 0 4px 16px rgba(190, 24, 93, 0.15);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);

  /* 레이아웃 */
  --header-height: 56px;
  --sidebar-width: 280px;
}

[data-theme="dark"] {
  /* 브랜드 컬러 — 3안: Teal (톤 다운된 청록색) */
  --primary: #0D9488;
  --primary-dark: #115E59;
  --primary-light: #14B8A6;

  /* 배경 컬러 — 3안: Zinc Gray (금속성 차가운 다크 그레이) */
  --bg-main: #09090B;
  --bg-card: #09090B;
  --bg-hover: #18181B;
  --bg-surface: #121214;

  /* 보더 & 구분선 */
  --border: #27272A;
  --border-active: var(--primary);

  /* 텍스트 컬러 — 차가운 톤의 Zinc/Gray 계열 */
  --text-primary: #F4F4F5;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;

  /* 시맨틱 컬러 */
  --success: #059669;
  --warning: #D97706;
  --error: #DC2626;

  /* 다크 섀도우 */
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-primary: 0 4px 20px rgba(20, 184, 166, 0.25);
}

/* --------------------------------------------------------------------------
   CSS 리셋
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 17px; /* 전체 폰트 크기 약간 확장 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Noto Sans KR', 'Nanum Gothic', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--primary-light);
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  outline: none;
}

/* --------------------------------------------------------------------------
   앱 컨테이너 — 100vh 풀스크린 레이아웃
   -------------------------------------------------------------------------- */
.app-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   헤더 — 상단 네비게이션 바
   -------------------------------------------------------------------------- */
.header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 기존 헤더 왼쪽 그라데이션 보더 효과는 너무 튀어 삭제 (모던하게 변경) */

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 로고 스타일 */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--gradient);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 사용자 이메일 표시 */
.user-email {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   앱 바디 — 사이드바 + 메인 콘텐츠 레이아웃
   -------------------------------------------------------------------------- */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   사이드바 — 왼쪽 문서 목록 패널
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition);
}

/* 사이드바 — 검색 영역 */
.sidebar-search {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px 0 36px;
  color: var(--text-primary);
  font-size: 0.8125rem;
  transition: var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.search-input:focus {
  border-color: var(--primary);
  background-color: var(--bg-hover);
  box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* 사이드바 — 문서 리스트 영역 */
.document-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* --------------------------------------------------------------------------
   문서 카드 — 사이드바 내 개별 문서 항목
   -------------------------------------------------------------------------- */
.document-card {
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.document-card:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 선택된 문서 강조 스타일 */
.document-card.active {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(230, 0, 126, 0.2), var(--shadow);
}

.document-card .doc-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-card .doc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.document-card .doc-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   메인 콘텐츠 영역
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --------------------------------------------------------------------------
   업로드 영역 — 드래그 앤 드롭
   -------------------------------------------------------------------------- */
.upload-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  animation: fadeIn 0.4s ease-out;
}

.upload-zone {
  width: 100%;
  max-width: 560px;
  padding: 60px 40px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

/* 업로드 영역 — 배경 광채 효과 */
.upload-zone::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(230, 0, 126, 0.03) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  transition: var(--transition);
}

.upload-zone:hover {
  border-color: var(--primary);
  background: rgba(230, 0, 126, 0.04);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.upload-zone:hover::before {
  background: radial-gradient(circle, rgba(230, 0, 126, 0.08) 0%, transparent 70%);
}

/* 드래그 오버 시 활성 스타일 */
.upload-zone.dragover {
  border-color: var(--primary-light);
  background: rgba(230, 0, 126, 0.08);
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-primary), var(--shadow-lg);
}

.upload-zone.dragover::before {
  background: radial-gradient(circle, rgba(230, 0, 126, 0.15) 0%, transparent 60%);
  animation: pulse 1.5s ease-in-out infinite;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
  opacity: 0.7;
  transition: var(--transition);
}

.upload-zone:hover .upload-icon {
  opacity: 1;
  transform: scale(1.1);
}

.upload-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.upload-formats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 16px;
}

/* 숨겨진 파일 인풋 */
#file-input {
  display: none;
}

/* --------------------------------------------------------------------------
   뷰어 컨테이너 — 2단 레이아웃 (미리보기 + 필드)
   -------------------------------------------------------------------------- */
.viewer-section {
  flex: 1;
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.viewer-section.active {
  display: flex;
}

.viewer-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   PDF 미리보기 영역
   -------------------------------------------------------------------------- */
.pdf-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

.pdf-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 20px;
}

#pdf-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xs);
}

/* PDF 페이지 네비게이션 바 */
.page-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.page-nav button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  font-size: 0.875rem;
}

.page-nav button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.page-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#page-info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 60px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   필드 목록 패널 — 오른쪽 사이드
   -------------------------------------------------------------------------- */
.fields-panel {
  width: 400px;
  min-width: 360px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fields-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fields-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#doc-filename {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* 필드 목록 스크롤 영역 */
.fields-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* --------------------------------------------------------------------------
   개별 필드 아이템
   -------------------------------------------------------------------------- */
.field-item {
  padding: 6px 10px;
  margin-bottom: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  animation: slideIn 0.3s ease-out both;
}

.field-item:hover {
  border-color: rgba(230, 0, 126, 0.3);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.field-name {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.field-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.field-value {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.field-edit-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.field-edit-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* 필드 — 편집 가능 입력 */
.field-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
}

.field-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.15);
}

/* 필드 — 신뢰도 프로그레스 바 */
.confidence-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confidence-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.confidence-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-main);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.confidence-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* 신뢰도 높음 (>= 0.8) */
.confidence-bar-fill.high {
  background: var(--success);
  box-shadow: 0 0 6px rgba(0, 200, 83, 0.4);
}

/* 신뢰도 중간 (0.5 ~ 0.8) */
.confidence-bar-fill.medium {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(255, 179, 0, 0.4);
}

/* 신뢰도 낮음 (< 0.5) */
.confidence-bar-fill.low {
  background: var(--error);
  box-shadow: 0 0 6px rgba(255, 23, 68, 0.4);
}

.confidence-value {
  font-size: 0.6875rem;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

.confidence-value.high { color: var(--success); }
.confidence-value.medium { color: var(--warning); }
.confidence-value.low { color: var(--error); }

/* 필드 — 하단 액션 버튼 영역 */
.fields-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   버튼 시스템
   -------------------------------------------------------------------------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary span {
  position: relative;
  z-index: 1;
}

/* 세컨더리 버튼 — 투명 보더 */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(230, 0, 126, 0.05);
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* 아이콘 버튼 — 작은 원형 */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

/* 작은 버튼 변형 */
.btn-sm {
  padding: 6px 14px;
  font-size: 0.75rem;
}

/* 위험 버튼 변형 */
.btn-danger {
  border-color: var(--error);
  color: var(--error);
}

.btn-danger:hover {
  background: rgba(255, 23, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

/* --------------------------------------------------------------------------
   상태 뱃지
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 100px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 대기 중 */
.badge.pending {
  background: rgba(102, 102, 102, 0.2);
  color: var(--text-muted);
  border: 1px solid rgba(102, 102, 102, 0.3);
}

/* 분석 중 */
.badge.analyzing {
  background: rgba(255, 179, 0, 0.15);
  color: var(--warning);
  border: 1px solid rgba(255, 179, 0, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

/* 분석 완료 */
.badge.analyzed {
  background: rgba(0, 200, 83, 0.15);
  color: var(--success);
  border: 1px solid rgba(0, 200, 83, 0.3);
}

/* 오류 */
.badge.error {
  background: rgba(255, 23, 68, 0.15);
  color: var(--error);
  border: 1px solid rgba(255, 23, 68, 0.3);
}

/* Admin 뱃지 */
.badge.admin {
  background: rgba(230, 0, 126, 0.15);
  color: var(--primary-light);
  border: 1px solid rgba(230, 0, 126, 0.3);
}

/* 기본 프롬프트 뱃지 */
.badge.default {
  background: rgba(230, 0, 126, 0.15);
  color: var(--primary);
  border: 1px solid rgba(230, 0, 126, 0.3);
}

/* --------------------------------------------------------------------------
   모달 — 오버레이 다이얼로그
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   토스트 알림 — 하단 알림
   -------------------------------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 380px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--error);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.info {
  border-left: 3px solid var(--primary);
}

.toast-icon {
  font-size: 1.125rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
}

.toast.removing {
  animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --------------------------------------------------------------------------
   로딩 스피너 — 마젠타 회전 애니메이션
   -------------------------------------------------------------------------- */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner.sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* --------------------------------------------------------------------------
   진행률 바 — 분석 진행 표시
   -------------------------------------------------------------------------- */
.progress-bar-wrapper {
  width: 100%;
  max-width: 400px;
  margin: 16px 0;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* 진행률 바 — 빛나는 효과 */
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

/* --------------------------------------------------------------------------
   분석 중 화면
   -------------------------------------------------------------------------- */
.analyzing-section {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  animation: fadeIn 0.4s ease-out;
}

.analyzing-section.active {
  display: flex;
}

.analyzing-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

#progress-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   로그인 화면 — 중앙 정렬 레이아웃
   -------------------------------------------------------------------------- */
.login-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

/* 로그인 — 배경 장식 효과 */
.login-container::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(230, 0, 126, 0.08) 0%, transparent 70%);
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.login-container::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(165, 0, 52, 0.06) 0%, transparent 70%);
  bottom: 15%;
  right: 20%;
  pointer-events: none;
}

.login-box {
  text-align: center;
  z-index: 1;
  animation: fadeIn 0.6s ease-out;
}

/* 로그인 — 큰 로고 */
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.login-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: var(--shadow-primary);
}

.login-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  max-width: 320px;
  line-height: 1.6;
}

/* 구글 로그인 버튼 */
.google-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.google-login-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.google-login-btn:active {
  transform: translateY(0);
}

.google-login-btn svg {
  width: 20px;
  height: 20px;
}

.login-footer {
  margin-top: 48px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   빈 상태 화면 — 아이콘 + 메시지
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Admin — 통계 카드 (Dashboard)
   -------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: rgba(230, 0, 126, 0.4);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}

.stat-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.125rem;
  font-weight: bold;
}

.stat-label-text {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-value-text {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Admin — 프롬프트 에디터
   -------------------------------------------------------------------------- */
.prompt-editor-layout {
  display: flex;
  gap: 20px;
  flex: 1;
  overflow: hidden;
}

/* 프롬프트 목록 */
.prompts-list-panel {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.prompt-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.prompt-card:hover {
  border-color: rgba(230, 0, 126, 0.3);
  background: var(--bg-hover);
}

.prompt-card.active {
  border-color: var(--primary);
  background: var(--bg-surface);
}

.prompt-card-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.prompt-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 프롬프트 에디터 폼 */
.prompt-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.1);
}

.form-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: 'Courier New', 'Consolas', monospace;
  line-height: 1.7;
  resize: vertical;
  transition: var(--transition);
}

.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.1);
}

.form-textarea::placeholder {
  color: var(--text-muted);
}

/* 체크박스 스타일 */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-checkbox-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* 버튼 그룹 */
.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 8px;
}

/* --------------------------------------------------------------------------
   Admin — 설정 탭
   -------------------------------------------------------------------------- */
.settings-section {
  max-width: 100%;
  width: 100%;
}

.settings-group {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.settings-group:last-child {
  border-bottom: none;
}

.settings-group-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* 라디오 버튼 그룹 */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.radio-item:hover {
  border-color: rgba(230, 0, 126, 0.3);
}

.radio-item input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.radio-item label {
  flex: 1;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* 슬라이더 스타일 */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.slider-wrapper input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: var(--transition-fast);
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--primary-light);
}

#temperature-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 36px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Admin — 최근 문서 테이블
   -------------------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.data-table th,
.data-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

.data-table td {
  color: var(--text-primary);
}

.data-table tbody tr {
  transition: var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

/* --------------------------------------------------------------------------
   Admin — 탭 네비게이션
   -------------------------------------------------------------------------- */
.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.tab-btn {
  padding: 14px 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  padding: 24px;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Admin — 레이아웃
   -------------------------------------------------------------------------- */
.admin-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   페이지네이션 바
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
}

.pagination-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.pagination-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(230, 0, 126, 0.05);
}

.pagination-btn.active {
  background: var(--gradient);
  border-color: var(--primary);
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   커스텀 스크롤바
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox 스크롤바 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* --------------------------------------------------------------------------
   키프레임 애니메이션
   -------------------------------------------------------------------------- */

/* 페이드 인 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 슬라이드 인 (좌측에서) */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 슬라이드 인 (우측에서) */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 펄스 — 깜빡이는 효과 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* 스핀 — 로딩 회전 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 시머 — 진행률 바 빛나는 효과 */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* 토스트 등장 */
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* 토스트 퇴장 */
@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.9);
  }
}

/* 페이지 전환 */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.page-enter {
  animation: pageEnter 0.3s ease-out;
}

/* 필드 아이템 순차 등장 (JS에서 --delay 변수 설정) */
.field-item:nth-child(1) { animation-delay: 0.05s; }
.field-item:nth-child(2) { animation-delay: 0.1s; }
.field-item:nth-child(3) { animation-delay: 0.15s; }
.field-item:nth-child(4) { animation-delay: 0.2s; }
.field-item:nth-child(5) { animation-delay: 0.25s; }
.field-item:nth-child(6) { animation-delay: 0.3s; }
.field-item:nth-child(7) { animation-delay: 0.35s; }
.field-item:nth-child(8) { animation-delay: 0.4s; }
.field-item:nth-child(9) { animation-delay: 0.45s; }
.field-item:nth-child(10) { animation-delay: 0.5s; }

/* --------------------------------------------------------------------------
   유틸리티 클래스
   -------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}

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

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

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

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

.mt-auto {
  margin-top: auto;
}

.flex-1 {
  flex: 1;
}

.gap-8 {
  gap: 8px;
}

.gap-16 {
  gap: 16px;
}

/* --------------------------------------------------------------------------
   반응형 — 768px 이하 (모바일/태블릿)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* 사이드바 기본 숨김 */
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* 뷰어 — 단일 컬럼 스택 레이아웃 */
  .viewer-container {
    flex-direction: column;
  }

  .fields-panel {
    width: 100%;
    min-width: 100%;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  /* 헤더 반응형 조정 */
  .header {
    padding: 0 16px;
  }

  .user-email {
    display: none;
  }

  /* 업로드 영역 축소 */
  .upload-zone {
    padding: 40px 20px;
  }

  /* 모달 전체 너비 */
  .modal {
    max-width: 95%;
    padding: 24px;
  }

  /* 토스트 위치 조정 */
  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    max-width: 100%;
  }

  /* Admin 프롬프트 에디터 스택 */
  .prompt-editor-layout {
    flex-direction: column;
  }

  .prompts-list-panel {
    width: 100%;
    min-width: 100%;
    max-height: 200px;
    flex-direction: row;
    overflow-x: auto;
  }

  .prompt-card {
    min-width: 200px;
  }

  /* 통계 그리드 단일 컬럼 */
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   반응형 — 480px 이하 (소형 모바일)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .login-logo {
    font-size: 1.5rem;
  }

  .login-logo-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .login-desc {
    font-size: 0.8125rem;
  }

  .google-login-btn {
    padding: 12px 24px;
    font-size: 0.875rem;
  }

  .fields-actions {
    flex-direction: column;
  }

  .fields-actions .btn-primary,
  .fields-actions .btn-secondary {
    width: 100%;
  }

  .admin-tabs {
    overflow-x: auto;
    padding: 0 16px;
  }
}

/* --------------------------------------------------------------------------
   인쇄 스타일
   -------------------------------------------------------------------------- */
@media print {
  .header,
  .sidebar,
  .upload-section,
  .fields-actions,
  #toast-container {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .fields-panel {
    width: 100%;
    border: none;
  }
}

/* ==========================================================================
   Admin 로그 탭 전용 스타일
   ========================================================================== */
.badge-info {
  background-color: rgba(0, 145, 234, 0.15) !important;
  color: #00b0ff !important;
  border: 1px solid rgba(0, 145, 234, 0.3) !important;
}

.badge-warn {
  background-color: rgba(255, 179, 0, 0.15) !important;
  color: var(--warning) !important;
  border: 1px solid rgba(255, 179, 0, 0.3) !important;
}

.badge-error {
  background-color: rgba(255, 23, 68, 0.15) !important;
  color: var(--error) !important;
  border: 1px solid rgba(255, 23, 68, 0.3) !important;
}

.log-details-details pre {
  margin-top: 8px;
  padding: 12px;
  background: #111111;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: monospace;
}

/* ==========================================================================
   가로형 프롬프트 카드 & 모달 (Magenta 액센트) 스타일
   ========================================================================== */

.prompts-grid-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 6px;
  box-sizing: border-box;
}

.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  transition: var(--transition);
  width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  min-height: auto;
}

.prompt-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(230, 0, 126, 0.12);
}

.prompt-card.default {
  border-left: 4px solid var(--primary);
}

/* 카드 내부 아이콘 콤팩트 크기 및 시인성 향상 */
.prompt-card .btn-icon {
  width: 30px;
  height: 30px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}

.reorder-up-btn,
.reorder-down-btn {
  color: var(--primary) !important;
  font-weight: bold;
}

.reorder-up-btn:hover,
.reorder-down-btn:hover {
  background: rgba(230, 0, 126, 0.1) !important;
  border-color: var(--primary) !important;
}

.test-prompt-btn {
  color: #00C853 !important;
  border-color: rgba(0, 200, 83, 0.3) !important;
}

.test-prompt-btn:hover {
  background: rgba(0, 200, 83, 0.1) !important;
  border-color: #00C853 !important;
}

.edit-prompt-btn {
  color: #FFB300 !important;
  border-color: rgba(255, 179, 0, 0.3) !important;
}

.edit-prompt-btn:hover {
  background: rgba(255, 179, 0, 0.1) !important;
  border-color: #FFB300 !important;
}

.delete-prompt-btn {
  color: #FF1744 !important;
  border-color: rgba(255, 23, 68, 0.3) !important;
}

.delete-prompt-btn:hover {
  background: rgba(255, 23, 68, 0.1) !important;
  border-color: #FF1744 !important;
}

/* 다크 마젠타 팝업 모달 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
  opacity: 1 !important;
  visibility: visible !important;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 650px;
  border-radius: var(--radius);
  border: 2.5px solid var(--primary);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(230, 0, 126, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
  padding: 18px 24px;
  background: var(--gradient);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  color: white !important;
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.modal-header .close-btn {
  font-size: 1.75rem;
  color: rgba(255, 255, 255, 0.7);
  transition: var(--transition-fast);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

.modal-header .close-btn:hover {
  color: white;
  transform: scale(1.15);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background-color: var(--bg-main);
}

.modal-body .form-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-body .form-input,
.modal-body .form-textarea {
  background-color: var(--bg-card);
  border-color: var(--border);
}

.modal-body .form-input:focus,
.modal-body .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.15);
}

.modal-footer {
  padding: 16px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-footer button {
  height: 38px;
  padding: 0 20px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-top: 4px;
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-checkbox-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  user-select: none;
}

/* ==========================================================================
   Bounding Box 하이라이트 및 위치 대조 스타일
   ========================================================================== */

/* 캔버스 래퍼 디스플레이 개선 */
.pdf-canvas-wrapper {
  position: relative;
}

#canvas-container {
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xs);
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

/* 바운딩 박스 기본 스타일 */
.bbox-rect {
  position: absolute;
  border: 1px solid rgba(230, 0, 126, 0.4);
  background: rgba(230, 0, 126, 0.08);
  box-sizing: border-box;
  cursor: pointer;
  pointer-events: auto; /* 마우스 오버 감지 */
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
  z-index: 10;
}

/* 마우스 호버 시 효과 */
.bbox-rect:hover,
.bbox-rect.active {
  border: 2px solid var(--primary) !important;
  background: rgba(230, 0, 126, 0.25) !important;
  box-shadow: 0 0 10px rgba(230, 0, 126, 0.5);
  z-index: 20;
}

/* 바운딩 박스 툴팁 말풍선 */
.bbox-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(20, 20, 20, 0.95);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(230, 0, 126, 0.3);
}

/* 화살표 추가 */
.bbox-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px;
  border-style: solid;
  border-color: rgba(20, 20, 20, 0.95) transparent transparent transparent;
}

/* 활성화 시 툴팁 보임 */
.bbox-rect:hover .bbox-tooltip,
.bbox-rect.active .bbox-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-10px);
}

/* 우측 필드 목록 아이템 hover/active 연동 */
.field-item {
  position: relative;
  border-left: 3px solid transparent !important;
}

.field-item:hover,
.field-item.active {
  background: var(--bg-hover) !important;
  border-left: 3px solid var(--primary) !important;
  border-color: rgba(230, 0, 126, 0.3) !important;
}

/* 필드 정합성 검증 에러/경고 카드 테두리 스타일 */
.field-item.val-invalid {
  border: 1.5px solid var(--error) !important;
  border-left: 4px solid var(--error) !important;
  background-color: rgba(255, 23, 68, 0.02) !important;
}

.field-item.val-invalid:hover,
.field-item.val-invalid.active {
  background-color: rgba(255, 23, 68, 0.05) !important;
}

.field-item.val-warning {
  border: 1.5px solid var(--warning) !important;
  border-left: 4px solid var(--warning) !important;
  background-color: rgba(255, 179, 0, 0.02) !important;
}

.field-item.val-warning:hover,
.field-item.val-warning.active {
  background-color: rgba(255, 179, 0, 0.05) !important;
}

/* 문서 카드 선택(체크) 상태 스타일 */
.document-card.selected {
  border-color: var(--primary) !important;
  background-color: rgba(230, 0, 126, 0.03) !important;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr !important; /* 처리량 추이는 넓게, 도넛형 분석 상태는 좁게 동적 배치 */
  gap: 20px;
  width: 100%;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr !important; /* 1024px 이하에서는 1열로 세로 정렬 */
  }
}

/* --------------------------------------------------------------------------
   code 태그 스타일 통일 (영문키 폰트 이질감 해소 및 비주얼 최적화)
   -------------------------------------------------------------------------- */
code {
  font-family: 'Noto Sans KR', 'Nanum Gothic', -apple-system, BlinkMacSystemFont, system-ui, sans-serif !important;
  font-weight: 500;
  font-size: 0.85em !important;
  background-color: rgba(0, 176, 255, 0.08) !important; /* 밝은 파란색 투명 배경 */
  border: 1px solid rgba(0, 176, 255, 0.2) !important;
  color: #00B0FF !important; /* 밝은 파란색 (네온 블루) 강조 적용 */
  padding: 3px 8px !important;
  border-radius: 6px !important;
  display: inline-block;
  letter-spacing: -0.01em;
}
