/* ===== 기본 설정 및 폰트 ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #317873;
  --background-color: #FDFBF6;
  --text-color: #333;
  --light-gray: #e0e0e0;
  --border-color: #ddd;
  --secondary-bg: #f8fafa;
  --hover-bg: #f2f8f7;
  --active-bg: #e6f2f0;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --border-radius-xl: 30px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative; /* 추가 */
}

.main-content {
  flex: 1;
  display: flex; /* 추가 */
  flex-direction: column; /* 추가 */
  justify-content: center; /* 추가 - 수직 중앙 정렬 */
  align-items: center; /* 추가 */
  width: 100%; /* 추가 */
  padding-bottom: 50px; /* 푸터 높이만큼 여백 */
}

/* ===== 공통 요소 스타일 ===== */
h1 {
  font-size: 2.2rem;
  margin-bottom: 15px;
  color: var(--primary-color);
  font-weight: 700;
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: var(--primary-color);
  font-weight: 600;
}

p {
  font-size: 1.1rem;
  margin-bottom: 20px;
  line-height: 1.6;
}

.subtext {
  font-size: 0.9rem;
  color: #666;
  margin-top: -10px;
  margin-bottom: 25px;
}

/* ===== 로고 스타일 ===== */
.logo {
  width: 120px;
  margin-bottom: 30px;
}

.logo-small {
  width: 80px;
  margin-bottom: 20px;
}

.result-logo {
  width: 60px;
  margin-right: 15px;
}

/* ===== 화면 레이아웃 스타일 ===== */
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  min-height: auto;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

/* ===== 버튼 스타일 ===== */
.btn {
  padding: 12px 30px;
  border-radius: var(--border-radius-xl);
  border: none;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 15px;
  font-family: 'Noto Sans KR', sans-serif;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-secondary {
  background-color: var(--light-gray);
  color: var(--text-color);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

/* ===== 표지 화면 스타일 ===== */
.cover-screen p {
  margin-bottom: 40px;
}

.cover-screen .btn {
  margin-top: 0;
}

/* ===== 월령 선택 화면 스타일 ===== */
.age-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 280px;
  margin-top: 20px;
}

.age-option {
  padding: 16px 30px;
  border-radius: var(--border-radius-md);
  background-color: white;
  border: 1px solid var(--border-color);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Noto Sans KR', sans-serif;
}

.age-option:hover {
  background-color: #f2f2f2;
  border-color: var(--primary-color);
}

/* ===== 입력 화면 스타일 ===== */
.input-container {
  width: 100%;
  max-width: 300px;
  margin-top: 10px;
  position: relative;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 15px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  font-size: 1rem;
  margin-bottom: 20px;
  font-family: 'Noto Sans KR', sans-serif;
}

.input-suffix {
  position: absolute;
  right: 60px;
  top: 16px;
  color: #666;
}

/* ===== 설문 화면 스타일 ===== */
.progress-container {
  width: 100%;
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  position: relative;
}

.back-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--primary-color);
  cursor: pointer;
  margin-right: 10px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background-color: var(--light-gray);
  border-radius: 4px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background-color: var(--primary-color);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.9rem;
  color: #666;
  margin-left: 10px;
  min-width: 40px;
  text-align: right;
}

.question-container {
  width: 100%;
  background-color: white;
  border-radius: var(--border-radius-lg);
  padding: 30px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.question-text {
  font-size: 1.3rem;
  margin-bottom: 30px;
  line-height: 1.5;
  font-weight: 500;
}

.answer-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
}

.answer-option {
  padding: 15px;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  background-color: white;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Noto Sans KR', sans-serif;
}

.answer-option:hover {
  background-color: var(--hover-bg);
  border-color: var(--primary-color);
}

.answer-option:active, 
.answer-option.selected {
  background-color: var(--active-bg);
  border-color: var(--primary-color);
}

/* ===== 결과 화면 스타일 ===== */
.result-intro {
  margin-bottom: 10px; /* 25px에서 축소 */
}

.top-categories {
  display: flex;
  flex-direction: column;
  gap: 5px; /* 15px에서 축소 */
  width: 100%;
  margin-bottom: 10px; /* 30px에서 축소 */
}

.category-item {
  background-color: white;
  border-radius: var(--border-radius-md);
  padding: 8px 10px; /* 15px에서 축소 */
  box-shadow: var(--shadow);
  text-align: left;
  display: flex;
  align-items: center;
}

.category-icon {
  font-size: 1.5rem;
  margin-right: 15px;
  width: 40px;
  height: 40px;
  background-color: var(--hover-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-info {
  flex: 1;
}

.category-name {
  font-weight: 500;
  margin-bottom: 3px;
}

.category-count {
  font-size: 0.9rem;
  color: #666;
}

.result-msg {
  margin-top: 5px; /* 10px에서 축소 */
  margin-bottom: 15px; /* 25px에서 축소 */
  font-size: 1rem;
  color: #555;
}

/* 새로 추가된 스타일 */
/* 버튼 위치 조정 - 위로 올리기 */
.result-screen .btn {
  margin-top: 0;
}

/* 버튼과 배너 사이 여백 두기 */
.promo-banner {
  margin: 15px 0 12px; /* 상단 여백 추가 */
}

/* 제목과 주석 사이 여백 좁히기를 위한 추가 스타일 */
.result-intro h2 {
  margin-bottom: 5px;
}

#result-stats {
  margin-top: 0;
}

/* 팁 카운트 및 카테고리 설명에 필요한 스타일 */
.tip-count {
  background-color: #317873;
  color: white;
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 6px;
}

.category-description {
  margin-top: 2px;
  font-size: 0.85rem;
  color: #666;
  font-weight: normal;
}

/* 모바일 화면 대응 */
@media (max-width: 480px) {
  .main-content {
    justify-content: flex-start; /* 모바일에서는 상단부터 시작 */
    padding-top: 5vh; /* 상단에 약간의 여백 추가 */
  }

  .category-name strong {
    font-size: 0.9rem;
  }
  
  .category-description {
    font-size: 0.8rem;
  }
  
  .top-categories {
    margin-bottom: 5px; /* 모바일에서 더 좁게 */
  }
  
  .promo-banner {
    margin-top: 10px; /* 모바일에서 배너 위치 조정 */
  }
}

/* ===== 상세 결과 스타일 ===== */
.result-container {
  width: 100%;
  max-width: 500px;
  padding: 40px 25px;
  background-color: white;
  border-radius: 0;
}

.result-header {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
}

.result-title {
  font-size: 1.5rem;
  margin-bottom: 0;
}

.customer-info {
  background-color: var(--secondary-bg);
  border-radius: var(--border-radius-md);
  padding: 15px;
  margin-bottom: 25px;
  text-align: left;
}

.info-item {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.result-content {
  text-align: left;
  margin-bottom: 30px;
}

.category-section {
  margin-bottom: 25px;
}

.category-header {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.category-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-left: 2px;
}

.solution-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 15px;
}

/* ===== 솔루션 유형 스타일 ===== */
.solution-type {
  font-size: 0.8rem;
  color: #666;
  margin-left: 8px;
  font-weight: normal;
}

.category-section.detailed-solution {
  background-color: #FAFAF8;
  border-radius: var(--border-radius-md);
  padding: 15px;
  margin-bottom: 15px;
  border: 2px solid var(--primary-color);
}

.category-section.short-solution {
  padding-left: 12px;
  margin-bottom: 15px;
}

.solution-text.detailed {
  font-size: 0.95rem;
  line-height: 1.6;
}

.solution-text.short {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #444;
}

/* ===== 철학 섹션 스타일 ===== */
.philosophy-section {
  padding: 15px;
  margin-bottom: 25px;
}

.philosophy-text {
  font-size: 0.95rem;
  color: var(--text-color);
  line-height: 1.6;
  margin-bottom: 0;
  font-style: italic;
}

/* ===== 프로모션 스타일 ===== */
/* 상담 바로가기 카드 수정 */
.promotion-section {
  background-color: #e6f2f0; /* 배경색 진하게 */
  border-radius: var(--border-radius-md);
  padding: 18px;
  text-align: center;
  border: 1px solid var(--primary-color); /* 테두리 추가 */
  box-shadow: 0 3px 10px rgba(49, 120, 115, 0.15); /* 그림자 추가 */
}

.promotion-section p {
  font-size: 0.95rem;
  margin-bottom: 15px;
  font-weight: 500; /* 글자 두껍게 */
  color: #2c6964; /* 글자색 약간 진하게 */
}

.promotion-section .promo-button {
  padding: 8px 20px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 20px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(49, 120, 115, 0.3); /* 버튼에 그림자 추가 */
}

.promotion-section .promo-button:hover {
  opacity: 0.9;
  transform: translateY(-2px); /* 호버 시 살짝 위로 */
}

.promo-banner {
  width: 100%;
  margin: 12px 0;
}

.promo-card {
  background-color: #f0f7f6; /* 배경색 약간 진하게 */
  border-radius: var(--border-radius-md);
  padding: 10px 12px; /* 패딩 줄이기 */
  border: 1px solid var(--primary-color); /* 테두리 색상 변경 */
  display: flex;
  flex-direction: row; /* 가로 배치로 변경 */
  justify-content: space-between; /* 양끝 정렬 */
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* 살짝 그림자 추가 */
}

.promo-text {
  font-size: 0.85rem; /* 글자 크기 줄이기 */
  font-weight: 500;
  color: var(--primary-color);
  text-align: left; /* 왼쪽 정렬 */
}

.promo-button {
  padding: 6px 14px; /* 버튼 크기 줄이기 */
  background-color: var(--primary-color);
  color: white;
  border-radius: 20px;
  text-decoration: none;
  font-size: 0.8rem; /* 버튼 글자 크기 줄이기 */
  white-space: nowrap; /* 텍스트 줄바꿈 방지 */
  flex-shrink: 0; /* 버튼 크기 유지 */
}

.promo-button:hover {
  opacity: 0.9;
}

/* ===== QR 코드 스타일 ===== */
.qr-code-container {
  display: none; /* 기본적으로 숨김, 이미지 저장 시에만 표시 */
  margin: 10px auto 5px; /* 상하 마진 축소 */
  text-align: center;
}

.qr-code {
  width: 100px; /* QR 코드 크기 축소 (기존 120px) */
  height: 100px;
  margin: 0 auto;
  display: block;
  background-color: white;
  padding: 6px; /* 패딩 축소 */
  border-radius: var(--border-radius-sm);
}

.qr-description {
  font-size: 0.75rem; /* 설명 텍스트 크기 축소 */
  margin-top: 5px; /* 상단 마진 축소 */
  color: #666;
}

/* QR 코드 표시 시 프로모션 섹션 스타일 조정 */
.qr-code-container:not([style*="display: none"]) + .promotion-section,
.qr-code-container[style*="display: block"] ~ .promotion-section {
  padding: 12px; /* 패딩 축소 */
}

/* 이미지 저장 모드일 때 프로모션 섹션 스타일 */
.promotion-section {
  transition: padding 0.3s ease;
}

/* javascript에서 QR 코드 표시 시 적용할 클래스 */
.compact-promotion-section {
  padding: 10px 12px !important;
}

/* ===== 모달 스타일 ===== */
.modal-display {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  padding: 20px;
}

.modal-display .result-container {
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 15px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  animation: fade-in 0.3s ease-out;
}

.modal-display .result-controls {
  position: fixed;
  bottom: 20px;
  left: 0;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 15px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1001;
}

.result-controls {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
  width: 100%;
}

/* ===== 이미지 모달 스타일 ===== */
.image-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  overflow-y: auto;
}

.image-modal-content {
  position: relative;
  margin: 20px auto;
  width: 90%;
  max-width: 500px;
  background-color: #f8f8f8;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  padding-top: 20px;
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  color: var(--text-color);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  z-index: 2001;
}

.image-container {
  width: 100%;
  text-align: center;
  padding: 0 10px;
  box-sizing: border-box;
}

.image-container img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
}

.save-instructions {
  background-color: #fff8e1;
  padding: 15px;
  text-align: center;
  margin-top: 15px;
  border-radius: 0 0 8px 8px;
}

.save-instructions p {
  margin: 5px 0;
  font-weight: bold;
  color: var(--text-color);
}

/* ===== 저장 관련 스타일 ===== */
.save-hint {
  position: absolute;
  bottom: 15px;
  right: 15px;
  background-color: rgba(49, 120, 115, 0.9);
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.hint-icon {
  margin-right: 8px;
  animation: pulse 1.5s infinite;
}

.saving-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 15px 25px;
  border-radius: 10px;
  font-size: 1.1rem;
  z-index: 2000;
}

.save-instruction {
  font-size: 0.9rem;
  color: #666;
  text-align: center;
  margin-top: 10px;
}

/* ===== 캡처 모드 스타일 ===== */
.capture-mode {
  background-color: #ffffff !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

.capture-mode .modal-display {
  background-color: #ffffff !important;
  position: relative !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

.capture-mode .result-container {
  border-radius: 15px !important;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1) !important;
  max-height: none !important;
}

.capture-mode .result-controls,
.capture-mode .save-hint {
  display: none !important;
}

/* ===== 푸터 스타일 ===== */
.page-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 15px;
  padding-bottom: calc(15px + env(safe-area-inset-bottom)); /* 하단 Safe Area 고려 */
  text-align: center;
  background-color: #f5f5f5;
  border-top: 1px solid var(--light-gray);
  width: 100%;
  z-index: 900; /* z-index 더 높게 설정 */
}

/* 푸터 높이만큼 하단 패딩 추가 */
.screen {
  padding-bottom: 50px;
}

.page-footer p {
  font-size: 0.8rem;
  color: #666;
  margin: 0;
}

.page-footer a {
  color: var(--primary-color);
  text-decoration: none;
}

.page-footer a:hover {
  text-decoration: underline;
}

/* ===== 애니메이션 ===== */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

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

/* ===== 반응형 스타일 ===== */
@media (max-width: 480px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.5rem; }
  .question-text { font-size: 1.2rem; }
  .answer-option, .age-option { font-size: 1rem; padding: 12px 20px; }
  .screen { padding: 20px 15px; }
  .result-controls { flex-direction: column; }
}

@media (min-width: 768px) {
  .container { padding: 0; }
  .screen {
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    min-height: calc(100vh - 40px);
  }
}