/* 기본 스타일 */
html, body {
    height: 100%;
}
body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    line-height: 1.6;
    /* overflow-x: hidden; /* 디버깅: 가로 스크롤 방지 - 제거 */
}

.main-container {
    min-height: calc(100vh - 140px); /* 60px 헤더 + 20px margin + 60px footer 예상 */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

img {
    max-width: 100%;
    height: auto;
    border: 1px solid black;
}

/* 코드 블록 스타일 추가 */
pre {
    white-space: pre-wrap;
    /* 자동 줄바꿈 허용 */
    word-wrap: break-word;
    /* 긴 단어 강제 줄바꿈 */
    overflow-x: auto;
    /* 필요한 경우 가로 스크롤 */
    background-color: #f4f4f4;
    /* 배경색 추가 (가독성) */
    padding: 15px;
    /* 내부 여백 추가 */
    border-radius: 5px;
    /* 모서리 둥글게 */
}

code {
    font-family: monospace;
    /* 고정폭 글꼴 */
}

/* 헤더 및 네비게이션 */
header {
    position: fixed;
    /* 상단 고정 */
    top: 0;
    left: 0;
    width: 100%;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: top 0.3s ease-in-out;
    /* 스크롤 애니메이션 */
    /* overflow-x: hidden; /* 디버깅: 내부 요소 넘침 방지 - 제거 */
}

header.nav-hidden {
    top: -60px;
    /* 헤더 높이 + 약간의 여유 */
}

#main-nav {
    height: 60px;
}

.nav-container {
    max-width: 1200px;
    /* 최대 너비 설정 */
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo a {
    font-size: 1.5em;
    font-weight: bold;
}

.nav-menu {
    display: flex;
}

.nav-menu li {
    margin-left: 20px;
}

.nav-menu a {
    padding: 5px 10px;
    transition: background-color 0.3s;
}

.nav-menu a:hover {
    background-color: #f4f4f4;
}

/* 모바일 메뉴 토글 버튼 */
.menu-toggle {
    display: none;
    /* 기본 숨김 */
    cursor: pointer;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #333;
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

/* 메인 컨텐츠 레이아웃 */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 60px auto 20px;
    /* 헤더 높이(60px) + 여백 20px */
    padding: 0 15px;
}

.main-content {
    flex: 3;
    /* 중앙 컨텐츠가 더 넓게 */
    margin: 0 20px;
}

.sidebar {
    flex: 1;
}

.left-sidebar {
    order: 1;
    /* 기본 순서 */
}

.main-content {
    order: 2;
}

.right-sidebar {
    order: 3;
}

.sidebar h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.main-content h1,
.main-content h2 {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.main-content section {
    margin-bottom: 30px;
}

.link-button {
    width: 100%;
    display: inline-block;
    padding: 14px 28px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    background: linear-gradient(45deg, #ff4e50, #f9d423);
    border: none;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.link-button:hover {
    background: linear-gradient(45deg, #43cea2, #185a9d);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

/* 테이블 스타일 */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* 은은한 그림자 효과 */
    border-radius: 8px; /* 둥근 테두리 */
    overflow: hidden; /* 테이블 내용이 border-radius를 벗어나지 않도록 */
    background-color: #fff;
  }
  
  th, td {
    border: 1px solid #ddd;
    padding: 1em;
    text-align: left;
  }
  
  th {
    background-color: #f5f5f5;
    font-weight: bold;
    color: #555;
  }
  
  tbody tr:nth-child(even) {
    background-color: #f9f9f9; /* 짝수 행 배경색 */
  }
  
  /* 목록 스타일 */
  ul {
    margin-bottom: 1.2em;
    padding-left: 20px;
  }
  
  li {
    margin-bottom: 0.6em;
  }
  
/* 푸터 */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background-color: #f8f8f8;
    border-top: 1px solid #eee;
}

/* 반응형 스타일 */
@media (max-width: 992px) {
    .main-container {
        flex-direction: column;
    }

    .left-sidebar {
        order: 1;
        /* 화면 작아질 때 순서 변경 */
        margin-bottom: 20px;
    }

    .main-content {
        order: 2;
        margin: 0 0 20px 0;
        /* 좌우 마진 제거 */
    }

    .right-sidebar {
        order: 3;
    }
}

@media (max-width: 768px) {
    .nav-container {
        width: 100%;
        /* 모바일에서 너비 100% 명시 */
        box-sizing: border-box;
        /* 패딩 포함 너비 계산 */
        /* max-width: 100%; */
        /* 필요시 이것도 시도 */
    }

    .menu-toggle {
        display: flex;
        /* 모바일에서 토글 버튼 보이기 */
    }

    .nav-menu {
        display: none;
        /* 기본 메뉴 숨기기 */
        position: fixed;
        top: 60px;
        /* ★★★ 수정: 헤더 높이(#main-nav height)와 일치 ★★★ */
        left: -250px;
        /* 왼쪽 밖으로 숨김 */
        width: 250px;
        height: calc(100vh - 60px);
        /* ★★★ 수정: 헤더 높이(#main-nav height)와 일치 ★★★ */
        background-color: white;
        flex-direction: column;
        padding-top: 20px;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease-in-out;
        z-index: 999;
        /* 헤더보다 아래 */
    }

    .nav-menu.active {
        display: flex;
        left: 0;
        /* 메뉴 활성화 시 왼쪽으로 슬라이드 */
    }

    .nav-menu li {
        margin: 15px 20px;
    }

    /* 토글 애니메이션 (X 모양) */
    .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

}

/* ★★★ 추가: 큰 화면에서 사이드바 고정 ★★★ */
@media (min-width: 993px) {
    .sidebar {
        position: sticky;
        top: 80px;
        /* 헤더 높이(60px) + main-container 마진 상단 여백(20px) */
        align-self: flex-start;
        /* 컨테이너 상단에 정렬 */
        height: calc(100vh - 100px);
        /* 화면 높이에서 상단 여백과 약간의 하단 여백 고려 */
        overflow-y: auto;
        /* 사이드바 내용이 길 경우 내부 스크롤 */
    }
}