:root {
    --primary-color: #33BB66;
    --primary-light: #5dd488;
    --primary-dark: #28a052;
    --secondary-color: #424242;
    --accent-color: #ff7e5f;
    --text-color: #2d3748;
    --text-light: #718096;
    --bg-color: #f8fafc;
    --nav-bg: #ffffff;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --border-color: #e2e8f0;
    --code-bg: #2d2d2d;
    --code-color: #f8f8f8;
    --code-comment: #a0aec0;
    --section-spacing: 3rem;
    --border-radius: 10px;
    --transition-speed: 0.3s;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 인쇄 방지 */
@media print {
    body {
        display: none;
    }
}

/* styles.css - 언어 선택 스타일 수정 */
.language-selector {
    position: relative;
    margin-left: 1rem;
}

.language-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
}

.language-toggle .fa-globe {
    font-size: 0.9rem;
}

.language-toggle .fa-caret-down {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    margin-top: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    display: none;
    z-index: 1000;
}

.language-dropdown.show {
    display: block;
}

.language-option {
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--text-color);
    font-size: 0.9rem;
}

.language-option:first-child {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.language-option:last-child {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.language-option:hover {
    background-color: rgba(51, 187, 102, 0.1);
    color: var(--primary-color);
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .language-toggle {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .language-toggle .fa-globe {
        font-size: 0.9rem;
    }
}

td code, h2 code, h3 code, h4 code, p code, li code, span code, strong code, em code {
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    padding: 1px 4px;
    font-family: 'SFMono-Regular', 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
    font-size: 0.92em;
    color: #ec5858;
    font-weight: 600;
    border-radius: 4px;
    line-height: 1.3;
    vertical-align: middle;
    display: inline-block;
    position: relative;
    top: 0.2px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Inter', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--bg-color);
    font-size: 16px;
    -webkit-touch-callout: none; /* iOS Safari */
    overflow-y: scroll;
    height: 100%;
}

/* 코드 블록은 선택 가능하게 유지 */
pre, pre code, pre * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 네비게이션 스타일 */
#navbar {
    width: 360px;
    height: 100vh;
    background-color: var(--nav-bg);
    position: fixed; /* 변경: sticky → fixed */
    top: 0;
    left: 0;
    border-right: 1px solid var(--border-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.03);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.nav-header {
    position: sticky; /* 추가: 로고 영역 고정 */
    top: 0;
    z-index: 11;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--nav-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* 로고 영역이 축소되지 않도록 */
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    height: auto;
    width: 140px;
    max-width: 180px;
    margin-right: 10px;
    margin-bottom: 2px;
}

.nav-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-list-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#nav-list {
    list-style: none;
    overflow-y: auto;
    padding: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Webkit 브라우저용 스크롤바 스타일 */
#nav-list::-webkit-scrollbar {
    width: 6px;
}

#nav-list::-webkit-scrollbar-track {
    background: transparent;
}

#nav-list::-webkit-scrollbar-thumb {
    background-color: var(--primary-light);
    border-radius: 20px;
}

#nav-list li {
    margin-bottom: 0.75rem;
}

#nav-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all var(--transition-speed) ease;
}

#nav-list a:hover, 
#nav-list a.active {
    background-color: rgba(51, 187, 102, 0.08);
    color: var(--primary-color);
    transform: translateX(4px);
}

/* 상위 챕터 활성화 스타일 */
#nav-list a.active-parent {
    background-color: rgba(51, 187, 102, 0.05);
    color: var(--primary-dark);
    font-weight: 600;
}

#nav-list .sub-menu {
    margin: 0.5rem 0 1rem 1.5rem;
    list-style: none;
    display: none;
}

#nav-list .sub-menu.show {
    display: block;
}

#nav-list .sub-menu li {
    margin-bottom: 0.4rem;
}

#nav-list .sub-menu a {
    padding: 0.5rem 0.75rem;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--text-light);
    border-left: 2px solid var(--border-color);
    border-radius: 0;
}

#nav-list .sub-menu a:hover,
#nav-list .sub-menu a.active {
    border-left: 2px solid var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
}

.toggle-button {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
}

/* 메인 콘텐츠 스타일 */
main {
    flex: 1;
    padding: 3rem 2rem;
    max-width: 1100px;
    margin: 0 auto;
    margin-left: 28%; /* 네비게이션 바 너비와 동일하게 설정 */
}

.section-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 2.5rem;
    margin-bottom: var(--section-spacing);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.section-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

h1 {
    font-size: 2.75rem;
    margin-bottom: 2.5rem;
    color: var(--primary-color);
    line-height: 1.3;
    font-weight: 700;
}

h2 {
    font-size: 2rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--primary-light);
    scroll-margin-top: 30px; /* 스크롤 마진 증가 */
    line-height: 1.4;
    font-weight: 600;
    color: var(--text-color);
}

.section-card h2:first-child {
    margin-top: inherit;
    padding-top: inherit;
}

h3 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1.2rem;
    color: var(--primary-dark);
    scroll-margin-top: 30px; /* 스크롤 마진 증가 */
    font-weight: 600;
    position: relative;
    padding-left: 1.25rem;
    line-height: 1.5;
    display: flex;
    align-items: center;
}

h3::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.25rem;
    bottom: 0.25rem;
    width: 6px;
    height: 80%;
    background: linear-gradient(to bottom, var(--primary-color), var(--primary-light));
    border-radius: 3px;
}

h3:last-of-type {
    margin-bottom: 1.2rem;
}

h4 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-dark);
    font-weight: 600;
    line-height: 1.4;
}

.section-card > *:last-child {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
}

p {
    margin-bottom: 1.25rem;
    color: var(--text-color);
}

ul, ol {
    margin-bottom: 1.5rem;
    padding-left: 1.75rem;
}

ul li, ol li {
    margin-bottom: 0.5rem;
}

pre {
    margin: 1.5rem 0;
    padding: 1.25rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    background-color: var(--code-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative; /* 복사 버튼 위치 기준점 */
    -webkit-touch-callout: none; /* iOS Safari */
}

/* 복사 버튼 스타일 */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.4rem 0.8rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    font-family: 'Inter', sans-serif;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

pre:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.copy-button.copied {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background-color: var(--code-bg);
    color: var(--code-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    letter-spacing: -0.5px;
}

pre code {
    padding: 0;
    background-color: transparent;
    line-height: 1.6;
}

code .token.operator,
pre code .token.operator {
    background: transparent;
    color: inherit;
}

code .comment {
    color: var(--code-comment);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn-link {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: var(--border-radius);
    text-decoration: none;
    margin: 0.75rem 0;
    transition: all var(--transition-speed) ease;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(51, 187, 102, 0.2);
}

.btn-link:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    box-shadow: 0 6px 15px rgba(51, 187, 102, 0.3);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* 로딩 스피너 */
.loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(51, 187, 102, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.75rem auto;
}

.loading .loading-text {
    color: var(--text-light);
    font-size: 0.95rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 에러 UI */
.error-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-color);
}

.error-title {
    font-weight: 700;
    color: #e53e3e;
    margin-bottom: 0.5rem;
}

.error-desc {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.retry-button {
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
}

.retry-button:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.section-card {
    overflow: visible; /* 테이블 스크롤을 위해 visible로 변경 */
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
    position: relative; /* 스크롤바 위치 제어를 위해 추가 */
    z-index: 1; /* 스크롤바가 다른 요소 위에 표시되도록 */
}

/* 테이블 기본 스타일 */
table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    background: var(--card-bg);
    margin: 0;
    border: none;
}

/* 테이블 헤더 */
thead {
    background-color: rgba(51, 187, 102, 0.1);
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    font-weight: 600;
    color: var(--primary-dark);
    white-space: nowrap;
    background: inherit;
    border-bottom: 2px solid var(--border-color);
}

/* 테이블 셀 */
th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    min-width: 120px;
}

/* 행 호버 효과 - 중복 제거 */
tbody tr:hover {
    background-color: rgba(51, 187, 102, 0.02);
}

/* 마지막 행 테두리 제거 */
tr:last-child td {
    border-bottom: none;
}

/* 모바일 최적화 */
@media screen and (max-width: 768px) {
    .table-wrapper {
        margin: 1rem 0;
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.75rem;
    }
}

/* 스크롤바 스타일 */
.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* 강조 표시 */
em, strong {
    color: var(--secondary-color);
    font-weight: 600;
}

/* 인용구 */
blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--primary-color);
    background-color: rgba(51, 187, 102, 0.05);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    font-style: italic;
    color: var(--text-light);
}

/* 구분선 */
hr {
    margin: 2rem 0;
    border: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

/* 챕터 토글 버튼 스타일 */
.chapter-toggle {
    cursor: pointer;
    margin-left: 0.5rem;
    display: inline-block;
    width: auto;
    height: auto;
    text-align: center;
    line-height: 1;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: bold;
    transition: all var(--transition-speed) ease;
    background-color: transparent;
    padding: 0.2rem;
}

.chapter-toggle.open:after {
    content: "▼";
    font-size: 0.7rem;
    position: relative;
    top: -1px;
}

.chapter-toggle.closed:after {
    content: "+";
}

.chapter-title {
    flex: 1;
}

/* 반응형 디자인 */
@media (max-width: 1100px) {
    .section-card {
        padding: 2rem;
    }
    
    main {
        padding: 2rem 1.5rem;
        width: 100%;
    }
    
    h1 {
        font-size: 2.25rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.3rem;
    }
    
    #navbar {
        width: 320px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
        overflow-x: hidden; /* 가로 스크롤 방지 */
        width: 100%;
    }
    
    #navbar {
        width: 100%;
        height: auto;
        min-height: auto;
        position: fixed; /* sticky에서 fixed로 변경 */
        top: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        padding: 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        -webkit-overflow-scrolling: touch;
        z-index: 1000; /* z-index 추가 */
    }
    
    .nav-header {
        margin-bottom: 0;
        padding: 1rem;
        background-color: var(--nav-bg); /* 배경색 추가 */
    }
    
    .logo {
        width: 120px;
    }
    
    .nav-list-container {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        border-top: 1px solid transparent;
        position: relative;
    }
    
    .nav-list-container.show {
        max-height: 60vh;
        border-top: 1px solid var(--border-color);
        overscroll-behavior: none; /* 스크롤 체이닝 방지 */
        -webkit-overflow-scrolling: touch;
    }
    
    #nav-list {
        position: relative;
        height: auto;
        max-height: 60vh;
        padding: 1rem;
        overscroll-behavior: none;
        scroll-behavior: auto; /* 모바일에서는 즉시 스크롤 */
    }
    
    .toggle-button {
        display: block;
    }
    
    main {
        padding: 1.5rem 1rem;
        margin-left: 0;
        margin-top: 60px; /* 네비게이션 바 높이만큼 여백 추가 */
        width: 100%;
        overflow-x: hidden; /* 가로 스크롤 방지 */
    }
    
    .section-card {
        width: 100%; /* 너비 제한 */
        max-width: 100%; /* 최대 너비 제한 */
        margin-left: 0;
        margin-right: 0;
        box-sizing: border-box; /* 박스 사이징 추가 */
        padding: 1.5rem;
        margin-bottom: 2rem;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }
    
    pre {
        padding: 1rem;
    }

    body {
        overflow-x: hidden; /* 가로 스크롤 방지 */
        width: 100%;
    }

    html {
        scroll-behavior: auto; /* 모바일에서는 즉시 스크롤 */
    }

    .nav-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .content {
        margin-top: 60px; /* 네비게이션 바 높이만큼 여백 추가 */
    }
}

/* 비밀번호 모달 스타일 */
.modal {
    display: flex;
    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;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    max-width: 450px;
    width: 90%;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: none;
    padding-bottom: 0.5rem;
}

.password-input-container {
    display: flex;
    margin: 1.5rem 0;
    width: 100%;
}

/* 모바일 대응 */
@media screen and (max-width: 480px) {
    .modal-content {
        padding: 2rem 1.5rem;
        width: 95%;
    }

    .password-input-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* 더 구체적인 선택자로 우선순위 높임 */
    .modal-content .password-input-container input {
        width: 100%;
        border-radius: var(--border-radius);
    }

    .modal-content .password-input-container button {
        width: 100%;
        border-radius: var(--border-radius);
    }
}

.password-input-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    font-size: 1rem;
    outline: none;
}

.password-input-container input:focus {
    border-color: var(--primary-color);
}

.password-input-container button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
}

.password-input-container button:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.error-message {
    color: #e53e3e;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    min-height: 20px;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease;
}

/* 콘텐츠 보호 확장 */
.protected-content {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease;
}

.content-visible {
    opacity: 1;
    visibility: visible;
}

/* 인쇄 방지 추가 보완 */
@media print {
    .container, main, #content, .section-card {
        display: none !important;
    }
    body::after {
        content: "문서 인쇄가 제한되어 있습니다.";
        display: block;
        text-align: center;
        font-size: 2rem;
        margin-top: 30%;
    }
}

/* 스크롤 관련 설정 */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 30px; /* 전체 스크롤 패딩 추가 */
} 