/* ===================================================
   증평투어패스 설문 보고서 생성기 - 메인 스타일
   =================================================== */

:root {
  --primary:       #1a5c8a;
  --primary-dark:  #0f3d5e;
  --primary-light: #e8f2f9;
  --accent:        #2e9e6b;
  --accent-light:  #e6f5ef;
  --warning:       #e07b2a;
  --danger:        #d94040;
  --gray-50:  #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  --font:      'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.14);
  --radius:    12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  font-size: 14px;
}

/* ===================================================
   화면 전환 — upload-screen은 flex 레이아웃이므로
   display를 직접 제어하지 않고 visibility/opacity 사용
   =================================================== */
.screen { display: none; }

/* 업로드 화면: flex 레이아웃 */
.screen.upload-screen-layout { display: flex !important; }
.screen.upload-screen-layout.hidden-screen { display: none !important; }

/* 보고서 화면: block 레이아웃 */
.screen.report-screen-layout { display: block !important; }
.screen.report-screen-layout.hidden-screen { display: none !important; }

.hidden { display: none !important; }

/* ===================================================
   공통 버튼
   =================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); }

.btn-generate {
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 24px;
  border-radius: var(--radius);
  margin-top: 24px;
  box-shadow: 0 4px 15px rgba(26,92,138,.3);
  letter-spacing: .3px;
}
.btn-generate:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(26,92,138,.42);
  filter: brightness(1.05);
}

.btn-back {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  font-size: 13px;
}
.btn-back:hover { background: rgba(255,255,255,.25) !important; transform: none !important; }

.btn-export {
  background: #fff;
  color: var(--primary);
  border: 1px solid rgba(255,255,255,.5);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
}
.btn-export:hover { background: var(--primary-light) !important; }

.btn-gdocs { color: #1a73e8; }
.btn-gdocs:hover { background: #e8f0fe !important; }

.btn-print { color: var(--gray-700); border-color: rgba(255,255,255,.35); }
.btn-print:hover { background: rgba(255,255,255,.2) !important; }

/* ===================================================
   업로드 화면
   =================================================== */
#upload-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(140deg, #0f3d5e 0%, #1a5c8a 55%, #2e9e6b 100%);
}

.upload-container {
  width: 100%;
  max-width: 740px;
  background: #fff;
  border-radius: 20px;
  padding: 48px 44px 44px;
  box-shadow: var(--shadow-lg);
}

.upload-header {
  text-align: center;
  margin-bottom: 36px;
}

.logo-badge {
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #fff;
  margin-bottom: 18px;
  box-shadow: 0 6px 18px rgba(26,92,138,.35);
}

.upload-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.35;
  margin-bottom: 8px;
}
.upload-header h1 span { color: var(--primary); }
.upload-header p { color: var(--gray-500); font-size: 14px; }

/* 드롭존 */
.upload-box {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 36px;
  text-align: center;
  cursor: pointer;
  background: var(--gray-50);
  transition: border-color .2s, background .2s, box-shadow .2s;
  margin-bottom: 28px;
  position: relative;
}
.upload-box:hover,
.upload-box.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(26,92,138,.08);
}
.upload-box.success {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-icon {
  font-size: 52px;
  color: var(--primary);
  margin-bottom: 14px;
  transition: color .2s;
}
.upload-box.success .upload-icon { color: var(--accent); }

.upload-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 16px;
  transition: color .2s;
}
.upload-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--gray-400);
  line-height: 1.5;
}

/* 업로드 상태 */
.upload-status {
  text-align: center;
  padding: 20px;
}
.status-icon { font-size: 36px; color: var(--primary); margin-bottom: 10px; }

.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 99px;
  margin-top: 16px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width .35s ease;
}

/* 메타 폼 */
.meta-form {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 28px 32px;
  border: 1px solid var(--gray-200);
}
.meta-form h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.optional {
  font-size: 10px;
  color: var(--gray-400);
  text-transform: none;
  font-weight: 400;
}
.form-group input {
  padding: 9px 13px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,92,138,.12);
}

/* ===================================================
   보고서 화면 - 상단바
   =================================================== */
.report-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.topbar-title {
  flex: 1;
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  opacity: .92;
  letter-spacing: .2px;
}
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===================================================
   보고서 본문 레이아웃
   =================================================== */
.report-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 100px;
}

/* ===================================================
   표지 — 심플 버전 (배경 그라디언트/장식 제거)
   =================================================== */
.report-cover {
  background: #fff;
  border-radius: var(--radius);
  padding: 60px 60px 48px;
  text-align: center;
  color: var(--gray-900);
  margin-bottom: 36px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.cover-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 20px;
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cover-meta {
  font-size: 14px;
  color: var(--gray-500);
}
.cover-sep { margin: 0 10px; opacity: .4; }
.cover-logo {
  margin-top: 36px;
  font-size: 44px;
  color: var(--primary);
  opacity: .18;
}

/* ===================================================
   섹션 공통
   =================================================== */
.report-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 36px 40px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--primary-light);
}
.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
  padding: 0 6px;
}

/* ===================================================
   조사 개요 테이블
   =================================================== */
.overview-table { width: 100%; border-collapse: collapse; }
.overview-table th,
.overview-table td {
  padding: 14px 20px;
  border: 1px solid var(--gray-200);
  vertical-align: top;
  line-height: 1.7;
}
.overview-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  white-space: nowrap;
  width: 160px;
}
.overview-table td { color: var(--gray-800); }
.overview-bullets { list-style: none; padding: 0; }
.overview-bullets li::before {
  content: '• ';
  color: var(--primary);
  font-weight: bold;
}

/* ===================================================
   문항 카드
   =================================================== */
.question-group { margin-bottom: 52px; }
.question-group:last-child { margin-bottom: 0; }

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}
.question-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 0 10px;
  flex-shrink: 0;
  margin-top: 2px;
}
/* PNG 다운로드 버튼 */
.btn-png-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
  font-family: var(--font);
  white-space: nowrap;
}
.btn-png-dl:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-png-dl:disabled { opacity: .5; cursor: not-allowed; }

/* 인쇄/PDF 시 PNG 버튼 숨김 */
@media print { .btn-png-dl { display: none !important; } }
body.printing .btn-png-dl { display: none !important; }

.question-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.5;
}
.question-sub-info {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 3px;
}

/* ===================================================
   차트 컨테이너
   =================================================== */
.chart-wrap {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.chart-canvas-box { flex: 0 0 auto; }
.chart-canvas-box.pie-box { width: 260px; }
.chart-canvas-box.bar-box { flex: 1; min-width: 300px; }
.chart-canvas-box canvas { max-width: 100%; }

/* ===================================================
   통계 테이블
   =================================================== */
.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.stat-table th {
  background: var(--gray-100);
  color: var(--gray-700);
  font-weight: 600;
  padding: 9px 12px;
  text-align: left;
  border: 1px solid var(--gray-200);
}
.stat-table td {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  color: var(--gray-800);
  vertical-align: middle;
}
.stat-table tr:nth-child(even) td { background: var(--gray-50); }
.stat-table .bar-cell { min-width: 130px; }

/* 인라인 바 */
.inline-bar { display: flex; align-items: center; gap: 8px; }
.inline-bar-track {
  flex: 1;
  height: 10px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}
.inline-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width .6s ease;
  min-width: 2px;
}
.inline-bar-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}

.count-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 12px;
}

/* 상위 순위 강조 */
.rank-1 { color: #b07800; font-weight: 700; }
.rank-2 { color: var(--gray-600); font-weight: 600; }
.rank-3 { color: #8b5e3c; font-weight: 600; }

/* ===================================================
   만족도 점수 스타일
   =================================================== */
.satisfaction-score {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.star { color: #f0c040; font-size: 14px; }
.star.empty { color: var(--gray-300); }
.score-num {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  margin-left: 5px;
}

/* 리커트 그룹 테이블 */
.likert-wrap { overflow-x: auto; }
.likert-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 620px;
}
.likert-table th {
  background: var(--primary-dark);
  color: #fff;
  padding: 10px 12px;
  text-align: center;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.15);
  font-size: 12px;
  line-height: 1.4;
}
.likert-table th.label-col {
  text-align: left;
  min-width: 200px;
}
.likert-table td {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  text-align: center;
  color: var(--gray-800);
  font-size: 12px;
  line-height: 1.4;
}
.likert-table td.label-col {
  text-align: left;
  font-weight: 500;
  background: var(--gray-50);
  font-size: 13px;
}
.likert-table tr:hover td { background: var(--primary-light); }
.likert-table tr:hover td.label-col { background: var(--primary-light); }
.likert-avg { font-weight: 700; color: var(--primary); font-size: 14px; }

/* ===================================================
   텍스트 응답 (주관식)
   =================================================== */
.text-response-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 6px;
}
.text-response-list::-webkit-scrollbar { width: 4px; }
.text-response-list::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 99px;
}
.text-item {
  background: var(--gray-50);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.65;
}
.text-item .text-num {
  font-size: 11px;
  color: var(--gray-400);
  margin-bottom: 4px;
}

/* ===================================================
   요약 카드 그리드
   =================================================== */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.summary-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.summary-card:hover { box-shadow: var(--shadow-md); }
.summary-card .sc-icon { font-size: 30px; margin-bottom: 10px; }
.summary-card .sc-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.summary-card .sc-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 6px;
  line-height: 1.5;
}

/* ===================================================
   로딩 오버레이
   =================================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,61,94,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
}
.loading-box {
  background: #fff;
  border-radius: 16px;
  padding: 44px 64px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
}
.loading-spinner { font-size: 44px; color: var(--primary); margin-bottom: 16px; }
.loading-box p { font-size: 15px; color: var(--gray-700); font-weight: 500; }

/* ===================================================
   인쇄 / PDF 스타일
   =================================================== */
@media print {
  .no-print, .report-topbar { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .report-content { max-width: 100%; padding: 0; margin: 0; }
  .report-section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
    margin-bottom: 16px;
    padding: 20px 24px;
  }
  .report-cover { break-after: page; border-radius: 0; }
  .question-group { break-inside: avoid; }
  .chart-canvas-box canvas { max-height: 260px; }
  .text-response-list { max-height: none; overflow: visible; }
}

/* PDF 내보내기용 (html2canvas가 이 클래스 사용) */
body.printing .no-print { display: none !important; }
body.printing .report-topbar { display: none !important; }
body.printing .report-section { box-shadow: none; }

/* ===================================================
   반응형
   =================================================== */
@media (max-width: 680px) {
  .upload-container { padding: 32px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .report-topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .topbar-title { font-size: 13px; }
  .topbar-actions { gap: 6px; flex-wrap: wrap; }
  .btn-export { font-size: 12px; padding: 7px 10px; }
  .report-section { padding: 22px 18px; }
  .report-cover { padding: 56px 24px 44px; }
  .cover-title { font-size: 22px; }
  .chart-canvas-box.pie-box { width: 100%; }
  .chart-wrap { flex-direction: column; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .likert-table { min-width: 480px; }
}

/* ===================================================
   유틸리티
   =================================================== */
.text-primary  { color: var(--primary); }
.text-accent   { color: var(--accent); }
.text-muted    { color: var(--gray-500); font-size: 13px; }
.font-bold     { font-weight: 700; }

.tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px;
}
.tag.green { background: var(--accent-light); color: var(--accent); }

/* 리커트 점수 색상 */
.score-5 { color: #2e9e6b; font-weight: 700; }
.score-4 { color: #5cb85c; font-weight: 600; }
.score-3 { color: #e07b2a; font-weight: 600; }
.score-2 { color: #d94040; font-weight: 600; }
.score-1 { color: #a02020; font-weight: 700; }
