/* ============================================
 * common.css - 전 페이지 공통 스타일
 * ============================================
 * 이 파일을 고치면 영향받는 곳:
 *   → quiz.html, admin.html, mistakes.html, history.html, index.html (전 페이지)
 *   → css/quiz.css, css/admin.css, css/mistakes.css, css/history.css, css/index.css
 *     (CSS 변수 --header-bg, --action-color 등을 참조)
 *
 * 이 파일이 의존하는 곳:
 *   ← 없음 (최상위 공통 스타일)
 *
 * 포함 항목:
 *   폰트, CSS 변수, 글로벌 리셋, 헤더/네비게이션, 타이틀 행,
 *   설정 모달, 로그인 모달, 댓글 시스템, 나이트 모드(공통),
 *   반응형(공통 헤더)
 * ============================================ */

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

:root {
    --header-bg: #1B2A4A;
    --action-color: #2D5FA0;
    --sub-action-color: #4A90D9;
    --card-bg: #E8F0FE;
    --page-bg: #F7F5F0;
    --text-color: #3C3C3C;
}

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

body {
    font-family: 'Gowun Dodum', 'Noto Sans KR', -apple-system, sans-serif;
    background: var(--page-bg);
    min-height: 100vh;
    color: var(--text-color);
}

/* ===== 헤더 ===== */
.header {
    background: var(--header-bg);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-title {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    margin-right: auto;
}
.header-nav { display: flex; gap: 8px; align-items: center; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: auto; }
.header-nav::-webkit-scrollbar { display: none; }
.nav-scroll-wrapper { position: relative; flex: 1; min-width: 0; display: flex; justify-content: flex-end; }
.nav-scroll-hint { position: absolute; top: 0; bottom: 0; width: 28px; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 0.2s; color: rgba(255,255,255,0.6); font-size: 14px; }
.nav-scroll-hint.left { left: 0; background: linear-gradient(to right, var(--header-bg, #1B2A4A) 40%, transparent); }
.nav-scroll-hint.right { right: 0; background: linear-gradient(to left, var(--header-bg, #1B2A4A) 40%, transparent); }
.nav-scroll-hint.visible { opacity: 1; }
.nav-btn {
    flex-shrink: 0;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }
.nav-greeting {
    color: var(--sub-action-color, #4A90D9);
    font-size: 13px;
    white-space: nowrap;
    padding: 0 4px;
    display: flex;
    align-items: center;
}

/* ===== 타이틀 행 / 도트 피규어 ===== */
.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.dot-figure {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}
.dot-figure img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ===== 댓글 시스템 ===== */
.cmt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 5px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    font-family: inherit;
}
.cmt-toggle:hover { border-color: #999; color: #555; }
.cmt-toggle .cmt-icon { font-size: 14px; }
.cmt-count { font-weight: 600; color: var(--action-color); }

.cmt-area {
    display: none;
    margin-top: 10px;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #eee;
}
.cmt-area.open { display: block; }

.cmt-thread {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.cmt-msg {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
}
.cmt-msg.user-msg {
    background: var(--card-bg, #E8F0FE);
    border-left: 3px solid var(--action-color);
}
.cmt-msg.ai-msg {
    background: #f0f9f0;
    border-left: 3px solid #2D7D46;
}
.cmt-msg-header {
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}
.cmt-msg-author { font-weight: 600; color: #555; }

.cmt-write {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.cmt-write textarea {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    outline: none;
}
.cmt-write textarea:focus { border-color: var(--action-color); }
.cmt-write button {
    padding: 8px 16px;
    background: var(--action-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    align-self: flex-end;
}
.cmt-write button:hover { opacity: 0.85; }

.cmt-loading {
    text-align: center;
    padding: 10px;
    color: #888;
    font-size: 12px;
}

/* ===== 설정 모달 ===== */
.settings-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    justify-content: center;
    align-items: center;
}
.settings-overlay.active { display: flex; }
.settings-modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}
.settings-header {
    background: var(--header-bg, #1B2A4A);
    color: #fff;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.settings-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.7;
}
.settings-close:hover { opacity: 1; }
.settings-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 20px 8px;
}
.palette-list {
    padding: 0 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.palette-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}
.palette-card:hover { border-color: #b0b0b0; background: #fafafa; }
.palette-card.selected { border-color: var(--action-color, #2D5FA0); background: var(--card-bg, #E8F0FE); }
.palette-colors { display: flex; gap: 3px; flex-shrink: 0; }
.palette-swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }
.palette-info { flex: 1; min-width: 0; }
.palette-name { font-size: 14px; font-weight: 600; color: #333; }
.palette-desc { font-size: 11px; color: #888; margin-top: 2px; }
.palette-check {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid #d0d0d0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: transparent; flex-shrink: 0;
    transition: all 0.15s;
}
.palette-card.selected .palette-check { border-color: var(--action-color, #2D5FA0); background: var(--action-color, #2D5FA0); color: #fff; }
.quiz-mode-list {
    padding: 0 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.quiz-mode-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8f8f8;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.quiz-mode-card:hover { border-color: #bbb; background: #f0f0f0; }
.quiz-mode-card.selected { border-color: var(--action-color, #2D5FA0); background: #f0f6ff; }
.quiz-mode-info { flex: 1; }
.quiz-mode-name { font-size: 14px; font-weight: 600; color: #333; }
.quiz-mode-desc { font-size: 12px; color: #888; margin-top: 2px; }
.quiz-mode-check {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid #ccc;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: transparent; flex-shrink: 0;
}
.quiz-mode-card.selected .quiz-mode-check { border-color: var(--action-color, #2D5FA0); background: var(--action-color, #2D5FA0); color: #fff; }

/* ===== 로그인 모달 ===== */
.login-overlay { display:none; position:fixed; top:0;left:0;right:0;bottom:0; background:rgba(0,0,0,0.55); z-index:200; justify-content:center; align-items:center; }
.login-overlay.active { display:flex; }
.login-wrapper { position:relative; width:90%; max-width:400px; }
.login-modal { background:var(--header-bg,#1B2A4A); border-radius:16px; padding:40px 32px 32px; box-shadow:0 24px 64px rgba(0,0,0,0.4); color:#fff; }
.login-modal h2 { font-size:20px; color:#fff; margin-bottom:8px; text-align:center; font-weight:700; }
.login-modal .lm-sub { text-align:center; color:rgba(255,255,255,0.55); font-size:13px; margin-bottom:28px; }
.login-modal .lm-notice { background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.15); border-radius:10px; padding:14px 16px; margin-bottom:20px; font-size:12.5px; line-height:1.7; color:rgba(255,255,255,0.75); }
.login-modal .lm-notice strong { color:#FCA5A5; }
.login-modal .lm-input { width:100%; padding:14px 16px; border:2px solid rgba(255,255,255,0.2); border-radius:10px; font-size:15px; font-family:inherit; outline:none; background:rgba(255,255,255,0.95); color:#1a1a1a; }
.login-modal .lm-input:focus { border-color:var(--action-color,#2563EB); }
.login-modal .lm-input::placeholder { color:#9ca3af; }
.login-modal .lm-hint { font-size:12px; color:rgba(255,255,255,0.45); margin-top:6px; margin-bottom:16px; }
.login-modal .lm-btn { width:100%; padding:13px; background:var(--action-color,#2563EB); color:#fff; border:none; border-radius:10px; font-size:15px; font-weight:600; cursor:pointer; font-family:inherit; margin-top:8px; }
.login-modal .lm-btn:hover { opacity:0.9; }
.login-modal .lm-btn:disabled { opacity:0.5; cursor:not-allowed; }
.login-modal .lm-error { color:#FCA5A5; font-size:13px; margin-top:10px; text-align:center; display:none; }
.login-modal .lm-close { position:absolute; top:12px; right:16px; background:none; border:none; font-size:22px; color:rgba(255,255,255,0.4); cursor:pointer; z-index:1; }
.login-modal .lm-close:hover { color:rgba(255,255,255,0.8); }
.login-modal .lm-link { text-align:center; margin-top:20px; padding-top:16px; border-top:1px solid rgba(255,255,255,0.1); font-size:13px; }
.login-modal .lm-link .label { color:rgba(255,255,255,0.5); }
.login-modal .lm-link .action { color:var(--sub-action-color,#4A90D9); cursor:pointer; font-weight:600; }
.login-modal .lm-link .action:hover { text-decoration:underline; }
.login-modal .lm-agree { display:flex; align-items:flex-start; gap:8px; margin:16px 0 4px; cursor:pointer; font-size:12.5px; line-height:1.5; color:rgba(255,255,255,0.7); }
.login-modal .lm-agree input[type="checkbox"] { margin-top:3px; flex-shrink:0; accent-color:var(--action-color,#2563EB); }

/* ===== 나이트 모드 (공통) ===== */
body.night-mode { background: var(--page-bg); color: var(--text-color); }
body.night-mode .cmt-area { background: #181818; border-color: #333; }
body.night-mode .cmt-thread { background: #222; border-color: #333; }
body.night-mode .cmt-toggle { background: #1E1E1E; border-color: #444; color: #aaa; }
body.night-mode .cmt-write textarea { background: #2A2A2A; border-color: #444; color: #E0E0E0; }
body.night-mode .settings-modal { background: #1E1E1E; }
body.night-mode .palette-card { background: #2A2A2A; border-color: #444; }
body.night-mode .palette-card:hover { background: #333; border-color: #666; }
body.night-mode .palette-card.selected { background: #2A2A3A; }
body.night-mode .palette-name { color: #E0E0E0; }
body.night-mode .palette-desc { color: #999; }
body.night-mode .settings-section-title { color: #999; }
body.night-mode .quiz-mode-card { background: #2A2A2A; border-color: #444; }
body.night-mode .quiz-mode-card:hover { background: #333; border-color: #666; }
body.night-mode .quiz-mode-card.selected { background: #2A2A3A; }
body.night-mode .quiz-mode-name { color: #E0E0E0; }
body.night-mode .quiz-mode-desc { color: #999; }

/* ===== 반응형 (공통 헤더) ===== */
@media (max-width: 600px) {
    .header { flex-wrap: wrap; height: auto; padding: 10px 12px 0; }
    .header-title { font-size: 15px; width: 100%; margin-bottom: 8px; }
    .nav-scroll-wrapper { flex: none; width: 100%; margin-bottom: 10px; }
    .nav-btn { padding: 6px 12px; font-size: 13px; }
}
