/* ai_intro レイアウト - 左メニュー（全展開） */

/* 全体コンテナ */
.container-with-sidebar {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
}

/* 左サイドバーメニュー */
.sidebar-menu {
    width: 260px;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-right: 1px solid #ddd;
    z-index: 1000;
}

/* サイドバー内スクロールラッパー */
.sidebar-nav-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

/* サイドバータイトル */
.sidebar-title {
    display: block;
    font-size: 1rem;
    font-weight: bold;
    color: #333;
    text-decoration: none;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid #333;
}

.sidebar-title:hover {
    text-decoration: underline;
}

/* ナビゲーションリスト */
.sidebar-nav-unified {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* トップページリンク */
.sidebar-nav-unified .nav-top {
    margin-bottom: 0.75rem;
}

.sidebar-nav-unified .nav-top a {
    display: block;
    padding: 0.4rem 0.5rem;
    color: #333;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.8rem;
    border-left: 3px solid transparent;
}

.sidebar-nav-unified .nav-top a:hover {
    text-decoration: underline;
}

.sidebar-nav-unified .nav-top.current-page a {
    border-left-color: #333;
    background-color: #f5f5f5;
}

/* 章レベル */
.sidebar-nav-unified .nav-chapter {
    margin-bottom: 0.5rem;
}

/* 章タイトル（テキスト、リンクではない） */
.sidebar-nav-unified .chapter-title-text {
    display: block;
    padding: 0.3rem 0.5rem;
    font-weight: bold;
    font-size: 0.75rem;
    color: #333;
    background-color: #f0f0f0;
    border-left: 3px solid #999;
}

.sidebar-nav-unified .nav-chapter.current-chapter .chapter-title-text {
    border-left-color: #333;
    background-color: #e0e0e0;
}

/* 章内のページリスト（常に表示） */
.sidebar-nav-unified .chapter-pages {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 3px solid #ddd;
    margin-left: 0;
}

.sidebar-nav-unified .chapter-pages li {
    margin: 0;
}

.sidebar-nav-unified .chapter-pages a {
    display: block;
    padding: 0.25rem 0.5rem 0.25rem 1rem;
    color: #555;
    text-decoration: none;
    font-size: 0.7rem;
    line-height: 1.4;
    transition: background-color 0.15s ease;
}

.sidebar-nav-unified .chapter-pages a:hover {
    background-color: #f5f5f5;
    text-decoration: underline;
}

.sidebar-nav-unified .chapter-pages .current-page a {
    background-color: #e8f4fc;
    color: #000;
    font-weight: bold;
    border-left: 2px solid #0066cc;
    margin-left: -2px;
}

/* 外部リンク */
.sidebar-nav-unified .nav-external {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #ddd;
}

.sidebar-nav-unified .nav-external a {
    display: block;
    padding: 0.4rem 0.5rem;
    color: #666;
    text-decoration: none;
    font-size: 0.75rem;
}

.sidebar-nav-unified .nav-external a:hover {
    text-decoration: underline;
    color: #333;
}

/* メインコンテンツエリア */
.main-content {
    margin-left: 280px;
    padding: 20px 30px;
    flex: 1;
    min-width: 0;
    max-width: 900px;
}

/* 既存のヘッダーを調整 */
.main-content .site-header {
    max-width: none;
    margin: 0 0 1rem 0;
    padding: 1.5rem;
}

/* パンくずリストを非表示 */
.main-content .breadcrumb {
    display: none;
}

/* ハンバーガーメニュー（モバイル用） */
.menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1100;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: #333;
    margin: 5px 0;
    transition: all 0.3s ease;
}

.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* レスポンシブ */
@media (max-width: 900px) {
    .menu-toggle {
        display: block;
    }
    
    .sidebar-menu {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar-menu.active {
        transform: translateX(0);
    }
    
    .menu-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 60px 15px 30px;
    }
}

/* ===== サイドバー内検索ボックス ===== */
.sidebar-menu .search-box {
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #ddd;
    position: relative;
}

.sidebar-menu .search-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    background: #fff;
}

.sidebar-menu .search-input {
    flex: 1;
    border: none;
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    outline: none;
    min-width: 0;
}

.sidebar-menu .search-input::placeholder {
    color: #999;
}

.sidebar-menu .search-clear {
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    font-size: 0.9rem;
    line-height: 1;
}

.sidebar-menu .search-clear:hover {
    color: #333;
}

.sidebar-menu .search-controls {
    display: none;
    align-items: center;
    justify-content: flex-end;
    margin-top: 0.3rem;
    gap: 0.25rem;
}

.sidebar-menu .search-counter {
    font-size: 0.7rem;
    color: #666;
    margin-right: auto;
}

.sidebar-menu .search-prev,
.sidebar-menu .search-next {
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1;
}

.sidebar-menu .search-prev:hover,
.sidebar-menu .search-next:hover {
    background: #f0f0f0;
}

/* 全章検索結果ドロップダウン */
.sidebar-menu .search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    display: none;
}

.sidebar-menu .search-result-item {
    display: block;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #333;
    font-size: 0.8rem;
}

.sidebar-menu .search-result-item:last-child {
    border-bottom: none;
}

.sidebar-menu .search-result-item:hover {
    background-color: #f5f5f5;
}

.sidebar-menu .search-result-chapter {
    display: inline-block;
    background: #5a67d8;
    color: #fff;
    padding: 0.1rem 0.3rem;
    font-size: 0.65rem;
    border-radius: 2px;
    margin-right: 0.4rem;
}

.sidebar-menu .search-result-title {
    color: #333;
}

.sidebar-menu .search-no-results {
    padding: 0.75rem;
    text-align: center;
    color: #999;
    font-size: 0.8rem;
}

.sidebar-menu .search-snippet {
    display: block;
    font-size: 0.7rem;
    color: #666;
    margin-top: 0.2rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu .search-snippet mark {
    background-color: #ffeb3b;
    color: #000;
    padding: 0 1px;
}

/* ページ内検索ハイライト */
.search-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 0 1px;
}

.search-highlight-current {
    background-color: #ff9800;
    color: #fff;
}
