/* 3ペインレイアウトを適用 */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0;
}

/* ヘッダー */
.header {
    position: fixed; /* 画面上部に固定 */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; /* 他の要素より前面に */
    background-color: #f8f9fa;
    padding: 5px 15px; /* コンパクトに */
    height: 50px; /* 高さを調整 */
    display: flex;
    justify-content: space-between; /* 左と右端を揃える */
    align-items: center;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); /* 影をつけて固定感を強調 */
}

/* h1: メインタイトル */
h1 {
    font-size: 32px; /* 大きくする */
    font-weight: bold;
    margin-bottom: 20px; /* 下の余白を増やす */
    color: #222; /* やや濃い色で視認性アップ */
    border-bottom: 3px solid #007bff; /* 下線を入れる */
    padding-bottom: 5px;
}

/* h2: セクションタイトル */
h2 {
    font-size: 26px;
    font-weight: bold;
    margin-top: 30px; /* 上の余白を増やす */
    margin-bottom: 15px;
    color: #333;
    border-left: 5px solid #007bff; /* 左にアクセント */
    padding-left: 10px;
}

/* h3: サブタイトル */
h3 {
    font-size: 22px;
    font-weight: bold;
    margin-top: 25px;
    margin-bottom: 10px;
    color: #444;
    border-left: 3px solid #007bff;
    padding-left: 8px;
}


/* ロゴを左端に配置 */
.logo {
    height: 120px; /* ロゴの高さを小さめに */
    width: auto; /* 幅はアスペクト比を維持 */
}

/* 検索バーのスタイル */
.search-bar {
    width: 300px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    text-align: center;
}

/* 検索トリガー */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: #666;
    font-size: 18px;
}

#searchTrigger {
    padding-left: 35px; /* アイコンのスペース */
}

/* 検索統計 */
.search-stats {
    padding: 10px 20px;
    color: #666;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

/* 検索バーを中央配置するための修正 */
.search-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

/* PC版では目次ボタンを非表示 */
.toc-button {
    display: none;
}


/* 検索オーバーレイ */
.search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
}

/* 検索ポップアップのスタイル */
.search-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    max-width: 90%;
    height: 600px;
    max-height: 90vh;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    border-radius: 10px;
    overflow: hidden;
    box-sizing: border-box;
}

/* 検索ポップアップの内部コンテナ */
.search-popup-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

/* 検索入力エリア */
.search-input-area {
    flex: 0 0 auto;
    margin-bottom: 20px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

/* 検索バー */
.popup-search-bar {
    width: 100%;
    padding: 15px 20px 15px 55px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.popup-search-bar:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    outline: none;
}

/* 検索結果エリア */
.popup-search-results {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 20px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

/* 検索結果アイテム */
.search-result-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    margin: 0 -20px;
    padding: 15px 20px;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-title {
    font-size: 16px;
    color: #007bff;
    margin-bottom: 8px;
}

.search-result-context {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* 検索統計 */
.search-stats {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

/* スクロールバーのスタイル */
.popup-search-results::-webkit-scrollbar {
    width: 8px;
}

.popup-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.popup-search-results::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.popup-search-results::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 検索結果リスト */
.search-results-list {
    padding: 10px 0;
}

/* 検索結果アイテム */
.search-result-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.search-result-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.search-result-item a {
    text-decoration: none;
    color: inherit;
    display: block;
    padding: 20px;
}

.search-result-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 検索結果のタイトル */
.search-result-title {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    margin-bottom: 10px;
}

/* 検索結果の本文 */
.search-result-context {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    position: relative;
}

/* 検索結果のハイライト */
.search-highlight {
    background-color: #ffd700;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    color: #000;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.3);
    display: inline-block;
    margin: 0 2px;
}

/* 検索ハイライト */
.search-highlight {
    background-color: #fff3cd;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: bold;
}

/* 結果なしメッセージ */
.no-results {
    padding: 30px;
    text-align: center;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px;
}

/* 検索結果が見つからない場合 */
.search-no-results {
    text-align: center;
    color: #666;
    padding: 20px;
    font-size: 14px;
}

/* 閉じるボタン */
.close-popup {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    background: none;
    border: none;
    padding: 5px;
}

.close-popup:hover {
    color: #333;
}

/* メインコンテナ（3ペインの親要素） */
.main-container {
    display: flex;
    flex: 1;
    margin-top: 50px; /* ヘッダーの高さ分マージンを追加 */
    overflow: hidden; /* はみ出しを防ぐ */
}

/* 左ナビゲーション */
.nav {
    width: 300px;
    min-width: 300px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    overflow-y: auto; /* 縦方向のスクロールを有効化 */
    height: calc(100vh - 50px); /* ヘッダーの高さを引いた分 */
}

/* 中央コンテンツエリア */
.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto; /* 縦方向のスクロールを有効化 */
    height: calc(100vh - 50px); /* ヘッダーの高さを引いた分 */
    max-width: calc(100vw - 600px); /* 左右のナビゲーションの幅を引いた分 */
}

/* 右ナビゲーション（目次） */
#TOC {
    width: 300px;
    min-width: 300px;
    background-color: #f8f9fa;
    border-left: 1px solid #dee2e6;
    overflow-y: auto; /* 縦方向のスクロールを有効化 */
    height: calc(100vh - 50px); /* ヘッダーの高さを引いた分 */
    padding: 20px;
}

/* コードブロックのスタイル調整 */
pre {
    max-width: 100%;
    overflow-x: auto; /* 横方向のスクロールを有効化 */
    white-space: pre-wrap; /* 長い行を折り返す */
    word-wrap: break-word; /* 単語の途中でも折り返す */
}

/* テーブルのスタイル調整 */
table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

/* ナビゲーションの中のリンク */
.nav-content {
    padding: 10px;
}

.nav-links a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #ddd;
}

.nav-links a:hover {
    background: #f1f1f1;
}

/* Prism.js のコードブロックスタイルを調整 */
pre[class*="language-"] {
    padding: 12px;
    border-radius: 5px;
    overflow-x: auto;
    line-height: 1.7;
}

/* Prism.js のコードブロックの背景色を変更 */
pre[class*="language-"] {
    background: #f5f5f5; /* 明るいグレー */
}

/* Prism.js のキーワード（関数、変数） */
.token.keyword {
    color: #0056b3; /* ブルー */
    font-weight: bold;
}

.token.function {
    color: #d73a49; /* 赤 */
    font-weight: bold;
}

.token.string {
    color: #008000; /* 緑 */
}

.token.comment {
    color: #888;
    font-style: italic;
}

/* インラインコードのスタイル */
code {
    color: #0056b3; /* 青系で強調 */
    font-family: Menlo, Consolas, Monaco, "Courier New", Courier, monospace;
    font-size: 15px; /* ひと回り大きく */
    font-weight: bold; /* インラインコードも強調 */
    border-radius: 3px;
    border: none; /* 背景色をなくす */
}

/* メソッド名のスタイル */
.method {
    color: #d73a49; /* 赤系で目立たせる */
    font-weight: bold;
}

/* テーブルのスタイル */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 16px;
    text-align: left;
    background-color: #fff;
    border: 1px solid #ddd;
}

/* ヘッダーのスタイル */
th {
    background-color: #f8f9fa;
    font-weight: bold;
    border: 1px solid #ddd;
    padding: 12px;
}

/* セルのスタイル */
td {
    border: 1px solid #ddd;
    padding: 10px;
}

/* 交互の行の背景色を変更 */
tr:nth-child(even) {
    background-color: #f2f2f2;
}

/* テーブル全体をスクロール可能にする */
.table-container {
    overflow-x: auto;
    margin: 10px 0;
}

/* ローディング表示 */
.loading {
    padding: 30px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid #007bff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* エラー表示 */
.error {
    padding: 20px;
    text-align: center;
    color: #dc3545;
    background-color: #f8d7da;
    border-radius: 8px;
    margin: 20px;
}

/* ⚠ 注意メッセージ (警告) */
.notice {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #fff3cd;
    color: #856404;
    border-left: 6px solid #ffcc00;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
}

.notice::before {
    content: "⚠"; /* 警告アイコン */
    font-size: 20px;
    font-weight: bold;
    color: #856404;
}

/* 💡 補足メッセージ (ノート) */
.note {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #e7f5ff;
    color: #055160;
    border-left: 6px solid #0c5460;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
}

.note::before {
    content: "💡"; /* 補足情報アイコン */
    font-size: 20px;
    font-weight: bold;
    color: #055160;
}


/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .nav, #TOC {
        width: 200px;
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    /* `.content` を明示的にブロック表示にする */
    .content {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px;
        box-sizing: border-box;
        height: calc(100vh - 50px);
        overflow-y: auto !important;
        text-align: left; /* 左詰め */
        white-space: normal !important; /* テキストの折り返し */
    }

    /* メインコンテナの設定 */
    .main-container {
        display: block !important;
        width: 100% !important;
        height: 100vh;
        overflow: hidden;
    }

    /* ナビゲーションと目次を非表示 */
    .nav{
        display: none;
        width: 100%;
        height: calc(100vh - 50px);
        background-color: #f8f9fa;
        padding: 20px;
        overflow-y: auto;
        position: relative;
    }

    /* 目次のデフォルト状態を隠す */
    #TOC {
        display: none !important;
    }    

    /* `show-nav` クラスが追加された時に `nav` を表示し、 `.content` を非表示にする */
    .show-nav .content {
        display: none !important;
    }

    .show-nav .nav {
        display: block !important;
    }

    /* HTMLとBODYのスクロール許可 */
    html, body {
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: auto !important;
    }

    /* ヘッダーをフレックスにしてロゴと検索を横並び */
    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 5px 10px;
    }

    /* ロゴの調整 */
    .logo {
        height: 100px;
        width: auto;
    }

    .search-container {
        display: flex;
        align-items: center;
        width: auto;
        flex-grow: 1;
    }

    .search-bar {
        flex-grow: 1;
        max-width: 150px;
    }

    /* ナビゲーションボタンのスタイル */
    .nav-button {
        display: block;
        position: fixed;
        top: 10px;
        right: 10px;
        background-color: #007bff;
        color: white;
        border: none;
        padding: 8px 12px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 16px;
        font-weight: bold;
        z-index: 1001;
        white-space: nowrap;
    }
}

