/* ========================================
   LG Owner's Manual - Common CSS
   공통 스타일 (변수, 리셋, 헤더, 유틸리티)
   ======================================== */

/* ========================================
   Font Face Declarations
   ======================================== */

/* LG Smart UI Mobile Fonts */
@font-face {
    font-family: 'LG Smart UI Mobile';
    src: url('fonts/LG_Smart_UI_Mobile-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'LG Smart UI Mobile';
    src: url('fonts/LG_Smart_UI_Mobile-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'LG Smart UI Mobile';
    src: url('fonts/LG_Smart_UI_Mobile-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

/* UPSYS Icon Fonts - 특수 아이콘/심볼 */
@font-face {
    font-family: 'UPSYS Common';
    src: url('fonts/upsys_common-webfont.woff2') format('woff2'),
         url('fonts/upsys_common-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS Circled Number';
    src: url('fonts/upsys_circlednumber-webfont.woff2') format('woff2'),
         url('fonts/upsys_circlednumber-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS Boxed Number';
    src: url('fonts/upsys-boxednumber-webfont.woff2') format('woff2'),
         url('fonts/upsys-boxednumber-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* 예전 템플릿 호환용 별칭 */
@font-face {
    font-family: 'upsys_boxednumberregular';
    src: url('fonts/upsys-boxednumber-webfont.woff2') format('woff2'),
         url('fonts/upsys-boxednumber-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS 2013 Basic';
    src: url('fonts/upsys_font_2013_basic-webfont.woff2') format('woff2'),
         url('fonts/upsys_font_2013_basic-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS 2017 Basic';
    src: url('fonts/UPSYS_Font_2017_Basic.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS VS Common1';
    src: url('fonts/Upsys_vs_common1-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS VS Common2';
    src: url('fonts/Upsys_vs_common2-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'UPSYS XML';
    src: url('fonts/Upsys_xml-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* 예전 템플릿 호환용 별칭 */
@font-face {
    font-family: 'Upsys_xml-Regular';
    src: url('fonts/Upsys_xml-Regular.ttf') format('truetype'),
         url('fonts/Upsys_xml-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}


/* CSS Variables - Light Mode (Default) */
:root {
    --color-primary: #333333;
    --color-secondary: #BBBBBB;
    --color-accent: #CCCCCC;
    --color-warning: #F5A623;
    --color-danger: #D0021B;
    --color-info: #BBBBBB;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-border: #E5E5E5;
    --color-bg: #FFFFFF;
    --color-bg-light: #F8F8F8;
    --color-header-bg: #FFFFFF;
    --color-link: #0070c9;

    /* Search highlight colors */
    --color-highlight-bg: rgba(255, 235, 59, 0.4);
    --color-highlight-bg-anim: rgba(255, 193, 7, 0.6);
    --color-search-highlight: #FFEB3B;

    /* Table colors */
    --color-table-header: #CCCCCC;
    --color-table-header-alt: #AAAAAA;

    --sidebar-width: 320px;
    --header-height: 60px;
    --breadcrumb-height: 50px;
    --max-width: 1600px;

    --font-family: 'LG Smart UI Mobile', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-family-heading: 'LG Smart UI Mobile', sans-serif;
    --font-family-icon: 'UPSYS Common', 'UPSYS 2017 Basic', 'UPSYS VS Common1', 'UPSYS VS Common2', 'LG Incl', sans-serif;
    --font-size-base: 15px;
    --font-size-sm: 13px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-xxl: 28px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}


/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
    color-scheme: light only;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

ul, ol {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input {
    font-family: inherit;
}

/* ========================================
   Header
   ======================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--color-header-bg);
    z-index: 1000;
    box-shadow: var(--shadow-md);
    overflow: visible;
    border-bottom: 1px solid var(--color-border);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.menu-btn .icon-hamburger {
    width: 24px;
    height: 24px;
}

.menu-btn:hover {
    opacity: 0.8;
}

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

.header-logo {
    width: 80px;
    height: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--color-bg);
    border-radius: 4px;
    overflow: visible;
}

.search-box input {
    width: 400px;
    height: 40px;
    padding: 0 45px 0 15px;
    border: none;
    font-size: var(--font-size-base);
    outline: none;
    background-color: var(--color-bg);
    color: var(--color-text);
}

.search-box input::placeholder {
    color: var(--color-text-light);
}

.search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.search-btn:hover {
    color: var(--color-primary);
}

/* Sliding Search Box (for content page) */
.content-page .search-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: transparent;
}

.content-page .search-box .search-btn {
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    flex-shrink: 0;
    border-radius: 4px;
}

.content-page .search-box .search-btn img {
    width: 20px;
    height: 20px;
}

/* Collapsed state - white icon, no background */
.content-page .search-box.collapsed {
    background: transparent;
}

.content-page .search-box.collapsed input {
    position: absolute;
    right: 40px;
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
    background: transparent;
}

.content-page .search-box.collapsed .search-btn {
    background: transparent;
}

.content-page .search-box.collapsed .search-btn img {
    filter: none;
}

/* Expanded state - white background slides from right */
.content-page .search-box.expanded {
    background: transparent;
}

.content-page .search-box.expanded input {
    position: absolute;
    right: 0;
    width: 580px;
    height: 40px;
    padding: 0 45px 0 15px;
    opacity: 1;
    pointer-events: auto;
    background-color: #fff;
    color: #000;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.content-page .search-box.expanded .search-btn {
    position: absolute;
    right: 5px;
    background: transparent;
}

.content-page .search-box.expanded .search-btn img {
    filter: none;
}

/* Search results position for content page - Desktop (770px+) */
@media only screen and (min-width: 736px) {
    .content-page .search-box.expanded .search-results {
        position: absolute;
        right: 0;
        left: auto;
        width: 580px;
        top: 100%;
        margin-top: 15px;
    }
}

/* Mobile: Search box drops below header (770px and below) */
@media only screen and (max-width: 1068px) {
    .content-page .search-box.collapsed {
        position: relative;
    }

    .content-page .search-box.expanded {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        width: 100%;
        padding: 10px 15px;
        background: #fff !important;
        border-bottom: 1px solid var(--color-border);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: 999;
        overflow: visible;
        clip-path: inset(0 0 100% 0);
        animation: slideDown 0.3s ease forwards;
    }

    @keyframes slideDown {
        from {
            clip-path: inset(0 0 100% 0);
        }
        to {
            clip-path: inset(0 0 0 0);
        }
    }

    /* Dark overlay */
    .search-overlay {
        display: none;
        position: fixed;
        top: calc(var(--header-height) + 64px);
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .search-overlay.active {
        display: block;
    }

    .content-page .search-box.expanded input {
        position: relative;
        right: auto;
        width: 100% !important;
        height: 44px;
        padding: 0 45px 0 15px;
        background-color: #fff;
        color: #000;
        transition: none !important;
        opacity: 1 !important;
    }

    .content-page .search-box.expanded .search-btn {
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
    }

    .content-page .search-box .search-results,
    body > .search-results {
        position: fixed;
        top: calc(var(--header-height) + 64px);
        left: 0;
        right: 0;
        width: 100%;
        max-height: calc(100vh - var(--header-height) - 64px);
        border-radius: 0;
        z-index: 1000;
        background: var(--color-bg);
        border: 1px solid var(--color-border);
        box-shadow: var(--shadow-lg);
    }
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 350px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.search-results.active {
    display: block;
}

.search-results ul {
    padding: 0;
}

.search-results li {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    border-bottom: 1px solid var(--color-border);
}

.search-results li:last-child {
    border-bottom: none;
}

/* 짝수 항목 배경색 다르게 */
.search-results li:nth-child(even) {
    background-color: var(--color-bg-light);
}

.search-results li:hover {
    background-color: var(--color-border);
}

.search-results .result-chapter {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    background-color: var(--color-secondary);
    padding: 2px 8px;
    border-radius: 3px;
    margin-bottom: 6px;
}

.search-results .result-title {
    font-weight: 500;
    color: var(--color-text);
    font-size: var(--font-size-sm);
    margin-bottom: 4px;
}

.search-results .result-snippet {
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-results .highlight {
    background-color: var(--color-search-highlight);
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 500;
}

.search-results .no-results {
    padding: 20px;
    text-align: center;
    color: var(--color-text-light);
}

.search-results .result-count {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--color-text-light);
    background-color: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border);
}

/* Language Selector - Custom Dropdown */
.language-selector {
    position: relative;
}

.language-selector select {
    display: none;
}

.lang-selected {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    font-size: 0;
    color: transparent;
    overflow: hidden;
    transition: background-color var(--transition-fast);
}

.lang-selected:hover {
    background-color: var(--color-bg-light);
}

.lang-selected::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    background-image: url("images/icon-globe.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background-color: #fff;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    min-width: 150px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: max-height 0.3s ease, opacity 0.2s ease, transform 0.3s ease;
    pointer-events: none;
}

.lang-dropdown.open {
    max-height: 300px;
    opacity: 1;
    transform: translateY(0);
    overflow-y: auto;
    pointer-events: auto;
}

.lang-option {
    padding: 10px 15px;
    color: #000;
    font-size: var(--font-size-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.lang-option:hover {
    background-color: var(--color-secondary);
    color: #fff;
}

.lang-option.active {
    background-color: var(--color-secondary);
    color: #fff;
    font-weight: 600;
}

/* ========================================
   Page Container (1600px centered)
   ======================================== */
.page-container {
    max-width: var(--max-width);
    margin: 0 auto;
    position: relative;
}

/* Footer */
.main-footer {
    padding: 30px 40px;
    text-align: center;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

/* ========================================
   Mobile Sidebar Overlay
   ======================================== */
.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s;
    z-index: 99;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-light);
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================================
   Main Layout
   ======================================== */
.main-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-height);
    max-width: var(--max-width);
    margin: 0 auto;
    position: relative;
}

.main-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.main-inner .content-area {
    flex: 1;
}

.main-inner .main-footer {
    flex-shrink: 0;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: max(0px, calc((100vw - var(--max-width)) / 2));
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--color-bg);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    z-index: 100;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s linear;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

/* When viewport is smaller than max-width, sidebar sticks to left */
@media only screen and (max-width: 1068px) {
    .sidebar {
        left: 0;
    }
}

/* Sidebar hidden state (desktop toggle) */
.sidebar.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.content-area.sidebar-hidden {
    margin-left: 0;
}

.content-area.sidebar-hidden .breadcrumb-wrapper {
    left: 0;
}

@media only screen and (min-width: 1069px) {
    .content-area.sidebar-hidden .breadcrumb-wrapper {
        left: calc((100vw - var(--max-width)) / 2);
    }
}


.sidebar-nav {
    padding: 0;
}

/* TOC List */
.toc-list {
    padding: 0;
}

.toc-item {
    border-bottom: 1px solid var(--color-border);
}

.toc-item:last-child {
    border-bottom: none;
}

.toc-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    user-select: none;
}

.toc-header:hover {
    background-color: var(--color-bg-light);
}

.toc-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 16px;
    color: var(--color-text-light);
    flex-shrink: 0;
}

.toc-title {
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--color-text);
    flex: 1;
}

.toc-header {
    transition: background-color 0.3s ease, border-left-color 0.3s ease;
}

.toc-item.active > .toc-header {
    background-color: var(--color-bg-light);
    border-left: 3px solid var(--color-secondary);
}

.toc-item.active > .toc-header .toc-title {
    font-weight: 600;
    color: var(--color-text);
}

.toc-title {
    transition: color 0.3s ease, font-weight 0.3s ease;
}

/* Sub items */
.toc-subitems {
    background-color: var(--color-bg);
    border-top: 1px solid var(--color-border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.toc-item.expanded > .toc-subitems {
    max-height: 2000px;
    transition: max-height 0.5s ease;
}

/* 초기 로드 시 트랜지션 없이 즉시 펼침 */
.sidebar.no-transition,
.sidebar.no-transition .toc-subitems {
    transition: none !important;
}
.content-area.no-transition,
.content-area.no-transition .breadcrumb-wrapper {
    transition: none !important;
}

.toc-subitem {
    padding: 10px 20px 10px 52px;
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--color-border);
}

.toc-subitem:last-child {
    border-bottom: 1px solid var(--color-border);
}

.toc-subitem:hover {
    background-color: var(--color-bg-light);
    color: var(--color-text);
}

.toc-subitem.active {
    color: var(--color-bg);
    font-weight: 500;
    background-color: var(--color-secondary);
    border-left: 3px solid var(--color-accent);
}

/* ========================================
   Content Area Container
   ======================================== */
.content-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    padding-top: 90px;
    padding-bottom: 100px;
    min-height: 0;
    position: relative;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Breadcrumb
   ======================================== */
.breadcrumb-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 40px;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-bg);
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    z-index: 100;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background-color: var(--color-secondary);
    transition: width 0.1s ease-out;
}

.breadcrumb {
    display: flex;
    align-items: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.breadcrumb.ready {
    opacity: 1;
}

.breadcrumb a {
    color: var(--color-text-light);
}

.breadcrumb a:hover {
    color: var(--color-text);
    text-decoration: none;
}

.breadcrumb .separator {
    margin: 0 10px;
    color: #999;
}

.breadcrumb .home-icon {
    display: flex;
    align-items: center;
}

.breadcrumb .home-icon svg {
    vertical-align: middle;
}

.breadcrumb .current {
    color: var(--color-text);
    font-weight: 700;
}

/* ========================================
   Page Navigation (btn_prev2 / btn_next2)
   ======================================== */
#nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    bottom: 0;
    left: 0;
    width: 100%;
    margin-top: 40px;
    padding: 0 40px;
    z-index: 5;
}

.btn_prev2, .btn_next2 {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    transition: opacity 0.3s;
    min-width: 200px;
}

.btn_prev2 {
    flex-direction: row;
    justify-content: flex-start;
    min-width: 200px;
}

.btn_next2 {
    flex-direction: row;
    justify-content: flex-end;
    min-width: 200px;
}

.btn_prev2 img {
    width: 28px;
    height: auto;
    margin-right: 10px;
}

.btn_next2 img {
    width: 28px;
    height: auto;
    margin-left: 10px;
}

.btn_prev2 div, .btn_next2 div {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.btn_prev2 div {
    text-align: left;
}

.btn_next2 div {
    text-align: right;
}

.left__before, .right__after {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 3px;
}

.left__title, .right__title {
    font-size: 12px;
    color: #666;
}

#nav:has(.btn_prev2):not(:has(.btn_next2)) {
    justify-content: flex-start;
}

#nav:has(.btn_next2):not(:has(.btn_prev2)) {
    justify-content: flex-end;
}

.btn_prev2:disabled, .btn_next2:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* 1600px 이상일 때 중앙 정렬 기준 */
@media only screen and (min-width: 1069px) {
    .breadcrumb-wrapper {
        left: calc(max(0px, (100vw - var(--max-width)) / 2) + var(--sidebar-width));
        right: max(0px, calc((100vw - var(--max-width)) / 2));
    }
}

/* Top Button */
.top-btn {
    position: fixed;
    right: 30px;
    bottom: 50px;
    width: 48px;
    height: 48px;
    background-color: var(--color-bg-light);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-light);
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 50;
}

.top-btn.visible {
    display: flex;
}

.top-btn:hover {
    background-color: var(--color-secondary);
    color: #fff;
    border-color: var(--color-secondary);
}

/* ========================================
   Responsive Design - Common
   ======================================== */
@media only screen and (max-width: 1068px) {
    .top-btn {
        right: 15px;
    }
}

@media only screen and (max-width: 1068px) {
    :root {
        --sidebar-width: 280px;
    }

    .search-box input {
        width: 300px;
    }

    .breadcrumb-wrapper {
        padding: 15px 30px;
    }
}

@media only screen and (max-width: 1068px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
        top: calc(var(--header-height) + var(--breadcrumb-height, 50px));
        height: calc(100vh - var(--header-height) - var(--breadcrumb-height, 50px));
    }

    .content-area {
        margin-left: 0;
    }

    .search-box input {
        width: 200px;
    }

    .header-logo {
        width: 80px;
    }

    .breadcrumb-wrapper {
        padding: 12px 20px;
        left: 0;
    }

}

@media only screen and (max-width: 735px) {
    html, body {
        max-width: 100vw;
    }

    .content-area {
        max-width: 100vw;
        padding-top: 40px;
        padding-bottom: 0;
    }

    .sidebar {
        overflow-y: hidden;
    }

    .main-footer {
        padding: 20px 15px;
    }

    .breadcrumb-wrapper {
        padding: 10px 15px;
    }

    .header-inner {
        padding: 0 10px;
    }

    .header-left {
        gap: 8px;
    }

    .header-right {
        gap: 10px;
    }

    .search-box input {
        width: 120px;
        height: 34px;
        font-size: 12px;
        padding: 0 35px 0 10px;
    }

    .header-logo {
        width: 70px;
    }

    .lang-selected {
        width: 32px;
        height: 32px;
    }
}

@media only screen and (max-width: 735px) {
    .search-box input {
        width: 100px;
        height: 32px;
        font-size: 11px;
    }
}

@media (max-width: 560px) {
    #nav {
        display: block;
        padding: 0 20px;
    }

    .btn_prev2, .btn_next2 {
        width: 200px;
    }

    .btn_next2 {
        float: right;
    }

    #nav > * {
        margin: 10px 0;
    }
}

/* Print Styles */
@media print {
    .main-header,
    .sidebar,
    .page-nav,
    .top-btn {
        display: none !important;
    }

    .content-area {
        margin-left: 0;
    }
}

/* ========================================
   RTL (Right-to-Left) Support
   아랍어, 히브리어 등 RTL 언어 지원
   ======================================== */

/* Sidebar - RTL: 오른쪽에서 나오도록 */
[dir="rtl"] .sidebar {
    left: auto;
    right: max(0px, calc((100vw - var(--max-width)) / 2));
    border-right: none;
    border-left: 1px solid var(--color-border);
}

@media only screen and (max-width: 1068px) {
    [dir="rtl"] .sidebar {
        right: 0;
        left: auto;
    }
}

[dir="rtl"] .sidebar.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Mobile sidebar - RTL */
@media only screen and (max-width: 1068px) {
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    [dir="rtl"] .sidebar.active {
        transform: translateX(0);
        top: calc(var(--header-height) + var(--breadcrumb-height));
        height: calc(100vh - var(--header-height) - var(--breadcrumb-height));
    }
}

/* Content Area - RTL */
[dir="rtl"] .content-area {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

@media only screen and (max-width: 1068px) {
    [dir="rtl"] .content-area {
        margin-right: 0;
    }
}

/* Breadcrumb - RTL */
[dir="rtl"] .breadcrumb-wrapper {
    left: 0;
    right: var(--sidebar-width);
}

@media only screen and (min-width: 1069px) {
    [dir="rtl"] .breadcrumb-wrapper {
        right: calc(max(0px, (100vw - var(--max-width)) / 2) + var(--sidebar-width));
        left: max(0px, calc((100vw - var(--max-width)) / 2));
    }
}

@media only screen and (max-width: 1068px) {
    [dir="rtl"] .breadcrumb-wrapper {
        right: 0;
    }
}

/* Progress Bar - RTL: 오른쪽에서 왼쪽으로 */
[dir="rtl"] .progress-bar {
    left: auto;
    right: 0;
}

/* TOC - RTL: 챕터명/부제목 라인을 오른쪽으로 */
[dir="rtl"] .toc-toggle {
    margin-right: 0;
    margin-left: 12px;
}

[dir="rtl"] .toc-item.active > .toc-header {
    border-left: none;
    border-right: 3px solid var(--color-secondary);
}

[dir="rtl"] .toc-subitem {
    padding: 10px 52px 10px 20px;
}

[dir="rtl"] .toc-subitem.active {
    border-left: none;
    border-right: 3px solid var(--color-accent);
}

/* Navigation - RTL: 방향 반전 */
[dir="rtl"] .btn_prev2 {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn_next2 {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn_prev2 img {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .btn_next2 img {
    margin-left: 0;
    margin-right: 10px;
}

[dir="rtl"] .btn_prev2 div {
    text-align: right;
}

[dir="rtl"] .btn_next2 div {
    text-align: left;
}

/* Search Box - RTL: 왼쪽에서 오른쪽으로 슬라이딩 */
[dir="rtl"] .search-btn {
    right: auto;
    left: 12px;
}

[dir="rtl"] .search-box input {
    padding: 0 15px 0 45px;
}

/* Content page search - RTL */
[dir="rtl"] .content-page .search-box {
    justify-content: flex-start;
}

[dir="rtl"] .content-page .search-box.collapsed input {
    right: auto;
    left: 40px;
}

[dir="rtl"] .content-page .search-box.expanded input {
    right: auto;
    left: 0;
}

[dir="rtl"] .content-page .search-box.expanded .search-btn {
    right: auto;
    left: 5px;
}

/* Search results - RTL */
@media only screen and (min-width: 736px) {
    [dir="rtl"] .content-page .search-box.expanded .search-results {
        right: auto;
        left: 0;
    }
}

/* Top Button - RTL */
[dir="rtl"] .top-btn {
    right: auto;
    left: 30px;
}

@media only screen and (max-width: 1068px) {
    [dir="rtl"] .top-btn {
        left: 15px;
    }
}

/* Language Selector - RTL */
[dir="rtl"] .lang-selected {
    padding: 0;
}

[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

/* Sidebar hidden state - RTL */
[dir="rtl"] .content-area.sidebar-hidden {
    margin-right: 0;
}

[dir="rtl"] .content-area.sidebar-hidden .breadcrumb-wrapper {
    right: 0;
}

@media only screen and (min-width: 1069px) {
    [dir="rtl"] .content-area.sidebar-hidden .breadcrumb-wrapper {
        right: calc((100vw - var(--max-width)) / 2);
    }
}

/* ========================================
   Page Transition Effects
   ======================================== */
