/* 매뉴얼 레이아웃 */
.manuals-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 70px);
    overflow: hidden;
}

.manuals-sidebar {
    width: 340px;
    min-width: 340px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.manuals-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.manuals-sidebar-header h3 {
    margin: 0;
    font-size: 17px;
}

.manuals-module-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.manuals-module-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
}

.manuals-module-item:hover {
    background: var(--hover-color);
}

.manuals-module-item.active {
    background: var(--accent);
    color: #fff;
}

.manuals-module-item .module-title {
    font-size: 17px;
    font-weight: 500;
}

.manuals-module-item .module-desc {
    font-size: 17px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.manuals-module-item .module-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.manuals-module-item .module-badge {
    font-size: 17px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--hover-color);
    margin-left: auto;
    white-space: nowrap;
}

.manuals-module-item.active .module-badge {
    background: rgba(255,255,255,0.2);
}

.manuals-category-label {
    font-size: 17px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.5;
    padding: 12px 12px 4px;
    letter-spacing: 0.5px;
}

/* 뷰어 */
.manuals-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.manuals-content {
    padding: 24px;
    max-width: 1100px;
}

.manuals-content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.manuals-content-header h2 {
    margin: 0;
    font-size: 22px;
}

.manuals-content-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.manuals-content-body {
    display: flex;
    gap: 24px;
}

/* 목차 */
.manuals-toc {
    width: 240px;
    min-width: 240px;
    position: sticky;
    top: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 16px;
    border-right: 1px solid var(--border-color);
}

.manuals-toc h4 {
    margin: 0 0 12px;
    font-size: 17px;
    opacity: 0.6;
}

.manuals-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.manuals-toc li {
    margin-bottom: 2px;
}

.manuals-toc li a {
    display: block;
    padding: 6px 10px;
    font-size: 17px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manuals-toc li a:hover {
    background: var(--hover-color);
}

.manuals-toc li a.active {
    background: var(--accent);
    color: #fff;
}

.manuals-toc li.toc-child {
    padding-left: 16px;
}

/* 다단계 목차 들여쓰기 (1~3단까지 번호 표시 + 4단 이상은 본문 헤딩) */
.manuals-toc li.toc-l1 {
    padding-left: 0;
}
.manuals-toc li.toc-l2 {
    padding-left: 16px;
}
.manuals-toc li.toc-l2 a {
    font-size: 16px;
    opacity: 0.92;
}
.manuals-toc li.toc-l3 {
    padding-left: 32px;
}
.manuals-toc li.toc-l3 a {
    font-size: 15px;
    opacity: 0.82;
}
/* 4단 이하: 목차에 거의 노출되지 않지만 보호 */
.manuals-toc li.toc-l4,
.manuals-toc li.toc-l5 {
    padding-left: 48px;
    font-size: 14px;
    opacity: 0.7;
}

/* 섹션 본문 */
.manuals-sections {
    flex: 1;
    min-width: 0;
}

.manual-section {
    margin-bottom: 32px;
    scroll-margin-top: 20px;
}

.manual-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.manual-section-header h2,
.manual-section-header h3,
.manual-section-header h4 {
    margin: 0;
}
/* 깊이별 섹션 헤더 폰트·간격 (depth-0=최상위 큰 제목) */
.manual-section.depth-0 {
    margin-top: 24px;
}
.manual-section.depth-0 .manual-section-header h2 {
    font-size: 24px;
}
.manual-section.depth-1 {
    margin-top: 16px;
    margin-left: 8px;
}
.manual-section.depth-1 .manual-section-header h3 {
    font-size: 19px;
}
.manual-section.depth-2 {
    margin-top: 12px;
    margin-left: 16px;
}
.manual-section.depth-2 .manual-section-header h4 {
    font-size: 17px;
    font-weight: 600;
}
/* 4단 이하: 본문 H4와 동급 */
.manual-section.depth-3,
.manual-section.depth-4 {
    margin-top: 10px;
    margin-left: 24px;
}
.manual-section.depth-3 .manual-section-header h4,
.manual-section.depth-4 .manual-section-header h4 {
    font-size: 16px;
    font-weight: 600;
    opacity: 0.9;
}

.manual-section-type {
    font-size: 17px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--hover-color);
    opacity: 0.7;
}

.manual-section-content {
    line-height: 1.7;
    font-size: 17px;
}

.manual-section-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.manual-section-content h1,
.manual-section-content h2,
.manual-section-content h3 {
    margin-top: 20px;
    margin-bottom: 8px;
}

.manual-section-content ol,
.manual-section-content ul {
    padding-left: 24px;
    margin: 8px 0;
}

.manual-section-content li {
    margin-bottom: 4px;
}

/* ============================================================
   매뉴얼 본문 표 표준 스타일 (백엔드 시드 콘텐츠가 인라인 width:NN% 를
   다양하게 지정하더라도 콘텐츠가 깨지지 않도록 보정)
   - 첫 컬럼 세로 가운데 정렬 + 줄바꿈 차단(짧은 단어가 한 글자씩 깨지는 현상 방지)
   - 첫 컬럼 최소 폭 보장
   - 헤더 가운데 정렬 + 굵은 글씨
   ============================================================ */
.manual-section-content table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    margin: 8px 0;
}

.manual-section-content table th {
    text-align: center !important;
    font-weight: 700;
    background: var(--hover-color);
    padding: 10px 8px !important;
    vertical-align: middle;
    white-space: nowrap;
}

.manual-section-content table td {
    padding: 10px 8px !important;
    vertical-align: middle;
    line-height: 1.5;
}

/* 첫 컬럼: 항목명 — 좁은 비율(width:18~25%)로 잡혀 있어도 한 단어가 세로로 깨지지 않도록 */
.manual-section-content table td:first-child {
    text-align: center !important;
    font-weight: 600;
    white-space: nowrap;
    min-width: 110px;
    word-break: keep-all;
}

/* 두 번째 이후 컬럼: 자연스러운 줄바꿈(긴 설명용) */
.manual-section-content table td:not(:first-child) {
    text-align: left;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* 모바일: 가로 스크롤로 보존 */
@media (max-width: 768px) {
    .manual-section-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .manual-section-content table td:first-child {
        min-width: 90px;
    }
}

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

.manual-section-actions button {
    font-size: 17px;
    padding: 2px 8px;
    border: none;
    background: var(--hover-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-color);
}

.manual-section-actions button:hover {
    background: var(--accent);
    color: #fff;
}

/* 메타 정보 */
.manuals-meta {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 17px;
    opacity: 0.5;
}

/* 모바일 */
.manuals-mobile-select {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.manuals-mobile-select select {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0 10px;
    font-size: 17px;
}

/* 모바일 컨테이너 내부에서는 search-bar 자체 padding/border 제거 → select와 좌우 정렬 통일 */
.manuals-mobile-select .manuals-search-bar {
    padding: 0;
    border-bottom: none;
}

@media (max-width: 1024px) {
    .manuals-sidebar {
        display: none;
    }
    .manuals-mobile-select {
        display: flex !important;
    }
    .manuals-toc {
        display: none;
    }
    .manuals-content {
        padding: 16px;
    }
    .manuals-content-header {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .manuals-layout {
        height: auto;
        flex-direction: column;
    }
    .manuals-content-header h2 {
        font-size: 19px;
    }
}

/* ==================== 매뉴얼 본문 통합 검색 (Ctrl+F) ==================== */
.manuals-search-bar {
    display: flex;
    gap: 6px;
    align-items: stretch;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}
.manuals-search-bar input[type="text"] {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0 10px;
    font-size: 17px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 4px;
}
.manuals-search-bar button {
    flex-shrink: 0;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0 16px;
    line-height: 1;
    white-space: nowrap;
}

.manuals-search-panel {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-color);
    max-height: 60vh;
    overflow: hidden;
}

.manuals-search-summary {
    padding: 10px 12px;
    font-size: 17px;
    background: var(--hover-color);
    border-bottom: 1px solid var(--border-color);
}

.manuals-search-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}
.manuals-search-nav .manuals-search-position {
    flex: 1;
    text-align: center;
    font-size: 17px;
    opacity: 0.8;
}

.manuals-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.manuals-search-empty {
    padding: 16px 12px;
    text-align: center;
    opacity: 0.6;
    font-size: 17px;
}

.manuals-search-group {
    margin-bottom: 8px;
}
.manuals-search-group-title {
    font-size: 17px;
    font-weight: 600;
    padding: 8px 8px 4px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}
.manuals-search-group-count {
    font-size: 17px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--hover-color);
    opacity: 0.8;
}

.manuals-search-result-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.15s;
}
.manuals-search-result-item:hover {
    background: var(--hover-color);
}
.manuals-search-result-title {
    font-size: 17px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.manuals-search-match-count {
    font-size: 17px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
}
.manuals-search-result-snippet {
    font-size: 17px;
    opacity: 0.75;
    margin-top: 4px;
    line-height: 1.5;
    word-break: break-all;
}
.manuals-search-result-snippet mark {
    background: var(--accent);
    color: #fff;
    padding: 0 2px;
    border-radius: 2px;
}

/* 본문 매칭 하이라이트 */
.manual-section-content mark.manuals-hl {
    background: rgba(255, 213, 0, 0.55);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05);
}
.manual-section-content mark.manuals-hl.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 2px var(--accent);
    scroll-margin-top: 80px;
}

@media (max-width: 1024px) {
    .manuals-search-panel {
        max-height: 50vh;
    }
}

/* 인쇄 */
@media print {
    .manuals-sidebar,
    .manuals-mobile-select,
    .manuals-content-actions,
    .manual-section-actions,
    .manuals-search-bar,
    .manuals-search-panel {
        display: none !important;
    }
    .manual-section-content mark.manuals-hl,
    .manual-section-content mark.manuals-hl.active {
        background: transparent !important;
        color: inherit !important;
        box-shadow: none !important;
    }
    .manuals-toc {
        display: none;
    }
    .manuals-viewer {
        overflow: visible;
    }
    .manuals-content {
        max-width: 100%;
    }
}
