/* ============================================
   포스코퓨처엠 CBT - 통합 스타일시트
   ============================================ */

/* ===== 리셋 & 기본 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #00A9CE;
  --primary-dark: #007A94;
  --secondary: #003876;
  --accent: #FF6B35;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --bg: #ffffff;
  --text: #1f2937;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Malgun Gothic', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* 배경 워터마크 (POSCO 로고 느낌) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(0,169,206,0.03) 0%, transparent 50%),
                    radial-gradient(circle at 80% 70%, rgba(0,56,118,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== 공통 컨테이너 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* ===== 상단 바 (홈, 결과 페이지용) ===== */
.topbar {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: white;
  padding: 16px 0;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== 버튼 ===== */
.btn, .btn-sm, .btn-primary, .btn-outline, .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--border);
}

.btn:hover {
  background: var(--gray-100);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.btn-sm:hover {
  background: rgba(255,255,255,0.25);
}

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

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

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--border);
}

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

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  padding: 6px 10px;
  background: transparent;
  font-size: 1.2rem;
  border: none;
}

.btn-icon:hover {
  background: var(--gray-100);
}

/* ============================================
   홈 화면 (index.html)
   ============================================ */

.hero {
  text-align: center;
  padding: 40px 20px 30px;
}

.hero h2 {
  font-size: 2rem;
  color: var(--secondary);
  margin-bottom: 10px;
}

.hero p {
  color: var(--gray-600);
  font-size: 1.05rem;
}

/* 통계 카드 (홈 상단) */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
  border: 1px solid var(--border);
}

.stat-card .label {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

/* 섹션 타이틀 */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--secondary);
  margin: 30px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 회차 카드 그리드 */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.exam-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.exam-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.exam-card h3 {
  color: var(--secondary);
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.exam-card .meta {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.exam-card .badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: 20px;
  font-size: 0.75rem;
  margin-right: 4px;
}

.exam-card .badge.done {
  background: #dcfce7;
  color: #166534;
}

/* 북마크 모아보기 섹션 (Step 5에서 사용) */
.bookmark-section {
  background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 30px;
}

.bookmark-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.bookmark-item {
  background: white;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.15s ease;
}

.bookmark-item:hover {
  border-color: var(--warning);
  transform: translateY(-1px);
}

.bookmark-item .bm-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.bookmark-item .bm-text {
  font-size: 0.9rem;
  color: var(--gray-800);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  color: var(--gray-500);
  padding: 30px;
  font-size: 0.95rem;
}

/* ============================================
   시험 화면 (exam.html)
   ============================================ */

.exam-header {
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.exam-header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.exam-title {
  font-size: 1.1rem;
  color: var(--secondary);
  font-weight: 700;
  flex: 1;
  min-width: 200px;
}

.exam-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.timer {
  background: var(--secondary);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 1px;
}

.timer.warning {
  background: var(--warning);
  animation: pulse 1s infinite;
}

.timer.danger {
  background: var(--danger);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 진행률 바 */
.progress-bar {
  height: 4px;
  background: var(--gray-200);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
  transition: width 0.3s ease;
}

/* ===== 시험 메인 (OMR 제거, 전체 폭) ===== */
.exam-main-full {
  max-width: 1000px;
  margin: 20px auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

.exam-content-full {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* 상단 컨트롤 바 */
.exam-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exam-controls label {
  font-size: 0.9rem;
  color: var(--gray-600);
  font-weight: 500;
}

.exam-controls select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.answered-count {
  font-size: 0.9rem;
  color: var(--gray-600);
  font-weight: 600;
}

/* ===== 문제 카드 ===== */
.question-area {
  min-height: 300px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
  font-size: 1rem;
}

.question-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  transition: all 0.2s ease;
}

.question-card.bookmarked {
  border-left: 4px solid var(--warning);
  background: linear-gradient(90deg, #fffbeb 0%, white 30%);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.question-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.95rem;
  margin-right: 8px;
}

.subject-tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.question-actions {
  display: flex;
  gap: 4px;
}

/* 문제 텍스트 */
.question-text {
  font-size: 1.05rem;
  color: var(--gray-800);
  line-height: 1.7;
  margin-bottom: 16px;
  white-space: pre-wrap;
  word-break: keep-all;
}

/* ===== ⭐ passage 박스 (지문/보기/표 대응) ===== */
.passage {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 12px 0 20px;
  font-size: 0.98rem;
  line-height: 1.8;
  color: var(--gray-800);
}

.passage.type-list ul {
  list-style: none;
  padding: 0;
}

.passage.type-list li {
  padding: 4px 0;
  word-break: keep-all;
}

.passage.type-text {
  white-space: pre-wrap;
}

/* 표 형태 passage */
.passage.type-table {
  padding: 0;
  overflow-x: auto;
}

.passage table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.passage table th,
.passage table td {
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  text-align: left;
}

.passage table th {
  background: var(--gray-100);
  font-weight: 700;
  color: var(--gray-700);
}

/* 선택지 */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px;
  background: var(--gray-50);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.choice:hover {
  background: #e0f2fe;
  border-color: var(--primary);
}

.choice.selected {
  background: #dbeafe;
  border-color: var(--primary);
}

.choice.correct {
  background: #dcfce7;
  border-color: var(--success);
}

.choice.wrong {
  background: #fee2e2;
  border-color: var(--danger);
}

.choice-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  background: white;
  border: 1.5px solid var(--gray-400);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 12px;
  flex-shrink: 0;
  color: var(--gray-600);
}

.choice.selected .choice-no {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.choice.correct .choice-no {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.choice.wrong .choice-no {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* 해설 */
.explanation {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f0fdf4;
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 0.95rem;
  line-height: 1.7;
  display: none;
}

.explanation.show {
  display: block;
  animation: slideDown 0.25s ease;
}

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

.explanation .label {
  font-weight: 700;
  color: var(--success);
  margin-right: 6px;
}

/* 페이지 이동 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.page-info {
  font-weight: 600;
  color: var(--gray-600);
}

/* ============================================
   결과 화면 (result.html)
   ============================================ */

.result-summary {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: white;
  padding: 40px 30px;
  border-radius: var(--radius);
  text-align: center;
  margin: 20px 0;
  box-shadow: var(--shadow-lg);
}

.result-summary h2 {
  font-size: 2rem;
  margin-bottom: 16px;
}

.score-big {
  font-size: 3.5rem;
  font-weight: 700;
  margin: 12px 0;
}

.score-big span {
  font-size: 4.5rem;
  color: #ffeb3b;
}

.score-percent {
  font-size: 1.6rem;
  margin-bottom: 12px;
  opacity: 0.95;
}

.chart-section {
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin: 20px 0;
}

.chart-section h3 {
  color: var(--secondary);
  margin-bottom: 16px;
  font-size: 1.2rem;
}

/* 리뷰 탭 */
.review-section {
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin: 20px 0;
}

.review-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.review-tabs .tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  font-family: inherit;
}

.review-tabs .tab:hover {
  color: var(--primary);
}

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

.review-list .question-card {
  margin-bottom: 16px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 30px 0;
  flex-wrap: wrap;
}

/* ============================================
   로그인/계정 (Phase 2에서 사용 예정)
   ============================================ */

.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  color: white;
  font-size: 0.85rem;
}

.auth-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-modal-bg.show {
  display: flex;
}

.auth-modal {
  background: white;
  padding: 30px;
  border-radius: var(--radius);
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.auth-modal h3 {
  color: var(--secondary);
  margin-bottom: 20px;
  text-align: center;
}

.auth-modal input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}

.auth-modal input:focus {
  outline: none;
  border-color: var(--primary);
}

.auth-modal .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.auth-modal .actions button {
  flex: 1;
}

.auth-modal .switch-mode {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--gray-500);
}

.auth-modal .switch-mode a {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

/* ============================================
   반응형 (모바일)
   ============================================ */

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .hero h2 {
    font-size: 1.5rem;
  }

  .exam-header-inner {
    padding: 10px 12px;
  }

  .exam-title {
    font-size: 1rem;
    width: 100%;
  }

  .exam-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .exam-header-right .btn,
  .exam-header-right .btn-outline,
  .exam-header-right .btn-primary {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .timer {
    font-size: 0.9rem;
    padding: 6px 10px;
  }

  .exam-main-full {
    padding: 0 12px;
    margin: 12px auto;
  }

  .exam-content-full {
    padding: 14px;
  }

  .question-card {
    padding: 16px;
  }

  .question-text {
    font-size: 1rem;
  }

  .passage {
    padding: 12px 14px;
    font-size: 0.92rem;
  }

  .choice {
    padding: 10px 12px;
    font-size: 0.95rem;
  }

  .score-big span {
    font-size: 3rem;
  }

  .result-summary {
    padding: 30px 20px;
  }
}

/* 스크롤바 예쁘게 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}
