/**
 * 標準SIDE形式（2カラム・左サイドバーカード）
 * ラッパーは会計ユニットと同じ bm-sidebar-layout（PCで右端ホバーしてしまえる）。
 * 独自メニューが line-channel-* のままの場合の互換スタイルも残す。
 *
 * 利用手順:
 * 1. CSS は header.php が読む（個別 <link> は不要）
 * 2. .unit_main に style="--unit-color: #06C755;"（任意・未設定時は緑）
 * 3. HTML は CONFIG/parts_v2/standard_side_layout_start.php
 *    → standard_side_navigation.php → standard_side_layout_end.php を require
 * サイドバー幅は --bm-sidebar-width（既定 260px。sidebar_layout.css と共通）
 *
 * @see b_template_unit/index.php
 * @see b_template_unit/templates/STANDARD_SIDE_README.md
 */

/* ========================================
   2カラムレイアウト
   ======================================== */
.line-channel-layout {
    display: flex;
    gap: 0;
    margin-top: 20px;
    min-height: 0;
}

.line-channel-layout.line-channel-two-column,
.unit_main .line-channel-two-column {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    margin-top: 20px;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.unit_main .line-channel-two-column .line-channel-sidebar-wrap {
    flex: 0 0 var(--bm-sidebar-width, 260px) !important;
    width: var(--bm-sidebar-width, 260px) !important;
    min-width: var(--bm-sidebar-width, 260px) !important;
    max-width: var(--bm-sidebar-width, 260px) !important;
    background: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.unit_main .line-channel-sidebar-header {
    padding: 15px 20px !important;
    background: var(--unit-color, #06c755) !important;
    color: #fff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.unit_main .line-channel-sidebar-header h3 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #fff !important;
}

.unit_main .line-channel-sidebar-content {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 8px !important;
    background: #fff !important;
}

.unit_main .line-channel-two-column .line-channel-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.line-channel-sidebar-wrap {
    flex: 0 0 var(--bm-sidebar-width, 260px) !important;
    width: var(--bm-sidebar-width, 260px) !important;
    min-width: var(--bm-sidebar-width, 260px) !important;
    max-width: var(--bm-sidebar-width, 260px) !important;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: sticky;
    top: 20px;
    align-self: start;
    box-sizing: border-box;
}

.line-channel-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: var(--unit-color, #06c755);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.line-channel-sidebar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #fff !important;
    color: var(--unit-color, #06c755) !important;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    text-decoration: none !important;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}

.line-channel-sidebar-back:hover {
    background: #fff !important;
    color: var(--unit-color, #06c755) !important;
    opacity: 0.9;
}

.line-channel-sidebar-back i {
    font-size: 21px;
    color: inherit;
}

.line-channel-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    flex: 1;
    min-width: 0;
}

.line-channel-sidebar-header h3 i {
    margin-right: 8px;
}

.line-channel-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.line-channel-two-column .line-channel-sidebar-wrap .line-channel-sidebar {
    width: 100%;
    margin-right: 0;
    border: none;
    border-radius: 0;
    padding: 0;
    background: transparent;
}

.line-channel-sidebar {
    flex-shrink: 0;
    width: 220px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 0;
    margin-right: 24px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.line-channel-sidebar-wrap .line-channel-sidebar,
.bm-sidebar-wrap .line-channel-sidebar {
    width: 100%;
    margin-right: 0;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    position: static !important;
}

.line-channel-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.line-channel-sidebar-item {
    margin: 0;
}

.line-channel-sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin: 2px 0;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.line-channel-sidebar-link:hover {
    background: #f8f9fa;
    color: #0f172a;
}

.line-channel-sidebar-link.active {
    background: color-mix(in srgb, var(--unit-color, #06c755) 15%, transparent);
    color: var(--unit-color, #057c38);
    font-weight: 600;
}

.line-channel-sidebar-link.active i {
    color: var(--unit-color, #06c755);
}

.line-channel-sidebar-link i {
    width: 20px;
    text-align: center;
    color: var(--unit-color, #06c755);
    opacity: 0.9;
}

.line-channel-content {
    flex: 1;
    min-width: 0;
}

.line-channel-two-column .line-channel-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box;
}

/* ========================================
   モバイル: ドロワー（768px以下）
   bm-sidebar-layout と同型の開閉パターン
   ======================================== */
.line-channel-sidebar-toggle {
    display: none !important;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: var(--unit-color, #06c755);
    cursor: pointer;
    font-size: 26px;
    flex-shrink: 0;
    margin-bottom: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.line-channel-sidebar-toggle:hover {
    background: #f8fafc;
}

body.standard-side-drawer-open {
    overflow: hidden;
}


.line-channel-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 10100;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.line-channel-sidebar-overlay.is-open {
    opacity: 1;
}

.line-channel-sidebar-overlay:not(.is-open) {
    pointer-events: none;
}

@media (max-width: 768px) {
    .line-channel-layout,
    .line-channel-two-column {
        flex-direction: column !important;
        gap: 0 !important;
        margin-top: 12px;
    }

    /* ヘッダーh1の左: サイドバードロワー用ハンバーガー（右の3点リーダーと役割分担） */
    .line-channel-sidebar-toggle,
    .unit_main .line-channel-sidebar-toggle {
        display: inline-flex !important;
        position: fixed !important;
        top: 0;
        left: 0;
        z-index: 10120; /* ドロワー(10110)より前面で閉じる操作を可能に */
        width: 48px;
        height: 48px;
        margin: 0 !important;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        color: #fff;
        font-size: 22px;
    }
    body.standard-side-drawer-open .line-channel-sidebar-toggle {
        top: 8px;
        left: 8px;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        color: var(--unit-color, #333);
    }

    .line-channel-sidebar-wrap,
    .unit_main .line-channel-two-column .line-channel-sidebar-wrap {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 10110;
        width: min(var(--bm-sidebar-width, 260px), 88vw) !important;
        min-width: 0 !important;
        max-width: none !important;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.18);
        border-radius: 0 !important;
        align-self: stretch !important;
    }

    .line-channel-sidebar-wrap.is-open,
    .unit_main .line-channel-two-column .line-channel-sidebar-wrap.is-open {
        transform: translateX(0);
    }

    .line-channel-sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .line-channel-sidebar-overlay.is-open {
        pointer-events: auto;
    }

    .line-channel-content,
    .line-channel-two-column .line-channel-content {
        width: 100%;
    }

    /* ドロワー内は縦並びメニューを維持 */
    .line-channel-sidebar-list {
        display: block;
    }

    .line-channel-sidebar-item {
        flex: none;
        min-width: 0;
    }
}

/* 769px以上: サイドバー常時表示・モバイル用トグルは非表示 */
@media (min-width: 769px) {
    .line-channel-sidebar-toggle {
        display: none !important;
    }

    .line-channel-sidebar-overlay {
        display: none !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    body.standard-side-drawer-open {
        overflow: auto !important;
    }

    .line-channel-sidebar-wrap,
    .unit_main .line-channel-two-column .line-channel-sidebar-wrap {
        position: static !important;
        transform: none !important;
    }
}

/* 769px〜900px: サイドバーを上段に積む（簡易レスポンシブ） */
@media (min-width: 769px) and (max-width: 900px) {
    .line-channel-layout,
    .line-channel-two-column {
        flex-direction: column !important;
    }

    .line-channel-sidebar-wrap,
    .unit_main .line-channel-two-column .line-channel-sidebar-wrap {
        position: static !important;
        flex: none !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        margin-bottom: 16px;
        transform: none !important;
    }

    .line-channel-sidebar {
        width: 100%;
        position: static;
        margin-right: 0;
        margin-bottom: 0;
    }

    .line-channel-sidebar-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .line-channel-sidebar-item {
        flex: 1;
        min-width: 140px;
    }

    .line-channel-sidebar-link.active {
        border-left: none;
    }
}
