/* 
  [public/style.css]
  웹 및 PWA 환경에 최적화된 앱 스타일시트입니다.
  기존 데스크톱 버전의 미려한 파스텔 톤 테마를 유지하되, PWA 설치 유도 배너 스타일을 추가하였습니다.
*/

/* 1. 디자인 시스템 토큰 (CSS 변수) 정의 */
:root {
  --font-main: 'Nanum Gothic', sans-serif;
  --font-handwriting: "Gungsuh", "GungsuhChe", "궁서", "궁서체", serif;

  --bg-app: #f4f6fc;
  --bg-card: #ffffff;
  --text-main: #2b3a4a;
  --text-muted: #7d8c9d;
  
  --color-primary: #5c7cfa;
  --color-primary-hover: #4263eb;
  
  --color-secondary: #e8ebf0;
  --color-secondary-hover: #dbe1e8;
  
  --color-accent: #ff6b6b;
  --color-accent-hover: #fa5252;

  --color-success: #20c997;
  --color-error: #ff8787;
  
  --shadow-soft: 0 10px 30px rgba(92, 124, 250, 0.08);
  --shadow-strong: 0 15px 40px rgba(0, 0, 0, 0.1);
  --radius-lg: 20px;
  --radius-md: 12px;
}

/* 2. 기본 리셋 및 글로벌 스타일 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 20px;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 25px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(92, 124, 250, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(92, 124, 250, 0.12);
}

/* PWA 전용 상단 설치 배너 스타일 */
.install-banner {
  background-color: var(--color-primary);
  color: white;
  padding: 12px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: var(--shadow-soft);
  animation: slideDown 0.3s ease-out;
  width: 100%;
  max-width: 1200px;
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.btn-install {
  background-color: white;
  color: var(--color-primary);
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background-color 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-install:hover {
  background-color: #f1f3f5;
}

.close-banner-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding-left: 15px;
  display: flex;
  align-items: center;
}

/* 3. 헤더 영역 스타일 */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-card);
  padding: 15px 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-emoji {
  font-size: 2rem;
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.student-profile {
  display: flex;
  align-items: center;
  gap: 15px;
  background-color: var(--bg-app);
  padding: 8px 18px;
  border-radius: 50px;
}

.character-avatar {
  font-size: 1.8rem;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.grade-badge {
  font-size: 0.75rem;
  font-weight: 800;
  background-color: var(--color-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  width: max-content;
}

.progress-bar-container {
  width: 100px;
  height: 6px;
  background-color: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--color-success);
  width: 10%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.xp-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: bold;
}

/* 4. 메인 영역 2단 칼럼 */
.app-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.panel-header {
  border-bottom: 2px solid var(--bg-app);
  padding-bottom: 15px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.level-select {
  padding: 8px 16px;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--color-primary);
  background-color: white;
  cursor: pointer;
  outline: none;
  transition: background-color 0.2s;
}

.level-select:hover {
  background-color: #edf2ff;
}

.practice-box {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}

.guide-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.original-text-box {
  background-color: #f8faff;
  border: 2px dashed #b8c6ff;
  border-radius: var(--radius-md);
  padding: 25px 20px;
  font-family: var(--font-handwriting);
  font-size: 2.2rem;
  text-align: center;
  color: #3b5bdb;
  line-height: 1.4;
  user-select: none;
}

.instructions {
  background-color: #fff9db;
  border-radius: var(--radius-md);
  padding: 15px;
  border-left: 5px solid #ffd43b;
}

.instructions h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: #f59f00;
}

.instructions ul {
  padding-left: 18px;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #665400;
}

/* 카메라 촬영 패널 */
.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background-color: #1a202c;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}

.webcam-view {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

.camera-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 3px dashed rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  width: 85%;
  height: 70%;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 15px;
  box-sizing: border-box;
}

.overlay-text {
  color: white;
  background-color: rgba(0, 0, 0, 0.6);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  margin-bottom: 15px;
}

.btn {
  flex: 1;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

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

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

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

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

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

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

.btn-accent:hover {
  background-color: var(--color-accent-hover);
}

.file-upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--bg-app);
  padding-top: 15px;
}

.divider-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-input {
  display: none;
}

.file-input-label {
  padding: 8px 16px;
  background-color: #f1f3f5;
  border: 1px solid #dee2e6;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: #495057;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.file-input-label:hover {
  background-color: #e9ecef;
}

/* 5. 결과 분석창 모달 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

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

.modal-content {
  width: 90%;
  max-width: 550px;
  background-color: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-strong);
  animation: modalOpen 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalOpen {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--bg-app);
  padding-bottom: 12px;
  margin-bottom: 15px;
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--color-primary);
}

.close-btn {
  font-size: 1.8rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
}

.close-btn:hover {
  color: var(--text-main);
}

/* 서클 게이지 스타일 */
.score-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 25px;
  gap: 10px;
}

.circle-gauge {
  position: relative;
  width: 150px;
  height: 150px;
}

.circle-gauge circle {
  fill: none;
  stroke-width: 10px;
}

.circle-gauge circle.bg {
  stroke: var(--bg-app);
}

.circle-gauge circle.fg {
  stroke: var(--color-success);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-dasharray: 408;
  stroke-dashoffset: 408; 
  transition: stroke-dashoffset 1s ease-out;
}

.score-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.score-unit {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: bold;
}

.score-eval {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-primary);
}

/* 텍스트 대조 피드백 */
.feedback-section {
  background-color: var(--bg-app);
  border-radius: var(--radius-md);
  padding: 15px;
  margin-bottom: 20px;
}

.feedback-section h3 {
  font-size: 0.95rem;
  margin-bottom: 3px;
}

.feedback-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.comparison-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compare-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.row-label {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--text-muted);
}

.compare-text {
  background-color: white;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: bold;
  border: 1px solid rgba(0,0,0,0.05);
}

.highlight-wrong {
  color: var(--color-accent);
  background-color: #ffe3e3;
  padding: 0 2px;
  border-radius: 4px;
  border-bottom: 2px solid var(--color-accent);
  font-weight: 800;
}

.highlight-correct {
  color: var(--color-success);
}

/* 6. 하단 성장 기록지 대시보드 */
.app-dashboard h2 {
  font-size: 1.1rem;
  margin-bottom: 15px;
  color: var(--text-main);
}

.history-list-wrapper {
  max-height: 250px;
  overflow-y: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.history-table th, .history-table td {
  padding: 12px 15px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--bg-app);
}

.history-table th {
  background-color: var(--bg-app);
  color: var(--text-muted);
  font-weight: bold;
}

.history-table tr:hover {
  background-color: #fafbfc;
}

.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 30px !important;
}

.table-score-badge {
  background-color: var(--color-primary);
  color: white;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.8rem;
  display: inline-block;
}

.table-score-badge.high {
  background-color: var(--color-success);
}

.table-score-badge.low {
  background-color: var(--color-accent);
}

.hidden {
  display: none !important;
}
