/*
 * necosuke-lms カスタムレイアウト
 * body.nklms-body が存在するページのみに適用。
 * テーマの HTML 構造を迂回したカスタムテンプレート用。
 */

/* ================================================================
   ボディリセット（テーマ由来の余白を除去）
   ================================================================ */
body.nklms-body {
    margin: 0 !important;
    padding: 0 !important;
    background: #f1f5f9 !important;
    overflow-x: hidden;
}

/* ================================================================
   ルートラッパ
   ================================================================ */
#nklms-wrap {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ================================================================
   ヘッダー（sticky）
   ================================================================ */
.nklms-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #1e293b;
    color: #f1f5f9;
    padding: 0 1.25rem;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}

.nklms-header__back {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color .15s;
}
.nklms-header__back:hover {
    color: #f1f5f9;
    text-decoration: none;
}

.nklms-header__title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
    font-weight: 600;
    color: #f8fafc;
}

/* モバイルでは「コーストップ名」ラベルを省略し矢印だけに */
.nklms-header__back-label {
    display: inline;
}

/* メニュートグル（PCでは非表示） */
.nklms-sidebar-toggle {
    display: none;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 6px;
    color: #e2e8f0;
    padding: 0.3rem 0.65rem;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s;
}
.nklms-sidebar-toggle:hover {
    background: rgba(255, 255, 255, .2);
}

/* ================================================================
   パンくず
   ================================================================ */
.nklms-breadcrumb {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.45rem 1.5rem;
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.nklms-breadcrumb a {
    color: #3b82f6;
    text-decoration: none;
}
.nklms-breadcrumb a:hover {
    text-decoration: underline;
}
.nklms-breadcrumb__sep {
    opacity: 0.45;
    user-select: none;
}

/* ================================================================
   2カラムレイアウト
   ================================================================ */
.nklms-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    align-items: start;    /* sticky が機能するために必須 */
    flex: 1;
}

/* ================================================================
   メインコンテンツ
   ================================================================ */
.nklms-main {
    background: #fff;
    padding: 2rem 2.5rem;
    min-width: 0;
    min-height: calc(100vh - 52px);
    border-right: 1px solid #e2e8f0;
}

.nklms-page-h1 {
    margin: 0 0 1.5rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #e2e8f0;
    font-size: 1.55rem;
    line-height: 1.35;
    color: #1e293b;
}

/* ================================================================
   サイドバー（sticky）
   ================================================================ */
.nklms-sidebar {
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    position: sticky;
    top: 52px;                        /* ヘッダー高さ */
    height: calc(100vh - 52px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.nklms-sidebar::-webkit-scrollbar {
    width: 4px;
}
.nklms-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.nklms-sidebar__head {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #475569;
    text-transform: uppercase;
    padding: 0 0.25rem 0.6rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.nklms-sidebar__head a {
    color: inherit;
    text-decoration: none;
}
.nklms-sidebar__head a:hover {
    color: #1e293b;
    text-decoration: underline;
}

/* サイドバー内の nkcourse-menu をコンパクトに */
.nklms-sidebar .nkcourse-menu {
    font-size: 0.85rem;
}
.nklms-sidebar .nkcourse-cat-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.6rem 0.25rem 0.3rem;
    display: block;
}
.nklms-sidebar .nkcourse-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}
.nklms-sidebar .nkcourse-cat > ul {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}
.nklms-sidebar .nkcourse-video > a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    border-radius: 5px;
    color: #334155;
    text-decoration: none;
    transition: background .12s, color .12s;
    line-height: 1.35;
}
.nklms-sidebar .nkcourse-video > a:hover {
    background: #e2e8f0;
    color: #1e293b;
    text-decoration: none;
}

/* 現在閲覧中 */
.nklms-sidebar .nkcourse-video.is-current > a {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}
.nklms-sidebar .nkcourse-video.is-current > a::before {
    content: '▶';
    font-size: 0.65em;
    color: #2563eb;
    flex-shrink: 0;
}

/* ステータスアイコン */
.nklms-sidebar .nkcourse-status {
    font-size: 0.75em;
    flex-shrink: 0;
    width: 1em;
    text-align: center;
}

/* ================================================================
   モバイル（≤ 899px）
   ================================================================ */
@media (max-width: 899px) {

    .nklms-header__back-label {
        display: none;   /* 矢印だけ表示 */
    }

    .nklms-sidebar-toggle {
        display: flex;
    }

    .nklms-layout {
        grid-template-columns: 1fr;
    }

    .nklms-main {
        padding: 1.25rem 1rem;
        min-height: auto;
        border-right: none;
    }

    .nklms-sidebar {
        display: none;               /* トグルで開閉 */
        position: static;
        height: auto;
        border-left: none;
        border-top: 1px solid #e2e8f0;
        max-height: 60vh;
        overflow-y: auto;
    }
    .nklms-sidebar.is-open {
        display: block;
    }

}
