/* ============================================================
   common.css - 문제은행 공통 스타일 (모바일 우선 반응형)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&family=Noto+Serif+KR:wght@400;600&display=swap');

/* ── CSS 변수 ── */
:root {
  --primary:       #2563EB;
  --primary-dark:  #1D4ED8;
  --primary-light: #EFF6FF;
  --secondary:     #7C3AED;
  --success:       #059669;
  --success-light: #ECFDF5;
  --danger:        #DC2626;
  --danger-light:  #FEF2F2;
  --warning:       #D97706;
  --warning-light: #FFFBEB;
  --info:          #0284C7;
  --info-light:    #F0F9FF;

  --bg:            #F8FAFC;
  --bg-card:       #FFFFFF;
  --bg-sidebar:    #1E293B;

  --text-primary:  #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;
  --text-inverse:  #F8FAFC;

  --border:        #E2E8F0;
  --border-focus:  #2563EB;

  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);

  --font-sans:  'Noto Sans KR', sans-serif;
  --font-serif: 'Noto Serif KR', serif;

  --header-h:   60px;
  --sidebar-w:  260px;
  --max-w:      480px;   /* 모바일 최대 너비 */
}

/* ── 리셋 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ── 레이아웃 ── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  padding: 0 16px;
}

/* ── 헤더 ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.app-header .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .logo-icon { font-size: 1.4rem; }
.app-header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── 바텀 내비 (모바일) ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  height: 64px;
  box-shadow: 0 -4px 12px rgba(0,0,0,.06);
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 500;
  transition: color .2s;
  padding: 8px 0;
}
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }

/* ── 카드 ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-header {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 버튼 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  transition: all .18s;
  line-height: 1;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn-ghost {
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); color: var(--primary); }
.btn-full { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── 뱃지 ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-muted   { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── 알림 토스트 ── */
#toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}
.toast {
  background: var(--bg-sidebar);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .25s ease;
  pointer-events: all;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 로딩 스피너 ── */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.8);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 빈 상태 ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 6px; }

/* ── 섹션 타이틀 ── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 구분선 ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── 유틸 ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); font-size: .85rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-primary-color { color: var(--primary); }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8  { gap: 8px; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }

/* ── 페이지 콘텐츠 영역 ── */
.page-content {
  flex: 1;
  padding: 20px 16px 80px;  /* 바텀 내비 여백 */
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-overlay.center { align-items: center; }
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-width: var(--max-w);
  animation: slideUp .25s ease;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-overlay.center .modal-box {
  border-radius: var(--radius-lg);
  margin: 16px;
  padding: 28px 24px;
  animation: zoomIn .2s ease;
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 0 auto 20px;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(60px); } to { transform: translateY(0); } }
@keyframes zoomIn  { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

/* ── 데스크탑 ── */
@media (min-width: 768px) {
  :root { --max-w: 600px; }
  .page-content { padding-bottom: 40px; }
  .bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}
