/**
 * หน้าใน (inner shell) — layout เมนูซ้าย/ขวา
 * ใช้กับ body.nh-legacy-inner-shell-page เท่านั้น (ไม่กระทบหน้าแรก)
 */

/* หน้าใน — layout พื้นฐาน (ความกว้างเมนูซ้ายกำหนดเฉพาะ ≥1024; มือถือไม่แตะ) */
body.nh-legacy-inner-shell-page .nh-legacy-inner-shell > .container > .nh-legacy-inner-left-col {
    display: block;
    float: left;
    box-sizing: border-box;
}

body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .nh-legacy-inner-center {
    padding: 0;
    box-sizing: border-box;
    float: left;
}

/* ไอคอนขีด hamburger บนปุ่ม Toggle ซ้าย/ขวา (รวม Desktop ≥1200) */
body.nh-legacy-inner-shell-page .nh-legacy-edge-tab .nh-legacy-edge-tab__icon,
body.nh-legacy-inner-shell-page .nh-legacy-edge-tab .nh-legacy-hamburger__icon {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
}

body.nh-legacy-inner-shell-page .nh-legacy-edge-tab .nh-legacy-hamburger__icon span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
}

/* Overlay — หน้าใน (Desktop ≥1200 ไม่ได้รับ base จาก legacy-home-bridge) */
body.nh-legacy-inner-shell-page .nh-legacy-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 1200;
}

body.nh-legacy-inner-shell-page.legacy-left-open .nh-legacy-overlay,
body.nh-legacy-inner-shell-page.legacy-right-open .nh-legacy-overlay {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1200px) {
    body.nh-legacy-inner-shell-page .nh-legacy-overlay {
        display: block !important;
    }
}

/* หน้าฟอร์ม — ไม่มีเมนูซ้าย เนื้อหาเต็มความกว้าง */
body.nh-legacy-inner-shell-page.has-form-page .nh-legacy-inner-shell .nh-legacy-inner-center--full,
body.nh-legacy-inner-shell-page.has-form-page .nh-legacy-inner-shell #nongharn-inner-center {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    display: block !important;
    box-sizing: border-box;
}

body.nh-legacy-inner-shell-page.has-form-page .ToggleLeft,
body.nh-legacy-inner-shell-page.has-form-page .nh-legacy-toggle-left {
    display: none !important;
}

/* เมนูขวา — drawer (รวมเมื่อ mount ไปที่ body) */
body.nh-legacy-inner-shell-page > #legacySidebarRight.nh-legacy-right-col,
body.nh-legacy-inner-shell-page .nh-legacy-inner-shell #legacySidebarRight.nh-legacy-right-col {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: auto !important;
    float: none !important;
    width: 280px !important;
    max-width: calc(100vw - 24px) !important;
    height: auto !important;
    padding: 8px !important;
    margin: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff !important;
    z-index: 1202 !important;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
    transition: transform 0.24s ease;
    transform: translate3d(105%, 0, 0) !important;
    visibility: visible !important;
    display: block !important;
}

body.nh-legacy-inner-shell-page.legacy-right-open > #legacySidebarRight.nh-legacy-right-col,
body.nh-legacy-inner-shell-page.legacy-right-open .nh-legacy-inner-shell #legacySidebarRight.nh-legacy-right-col {
    transform: translate3d(0, 0, 0) !important;
}

/* แท็บเล็ต + มือถือ: ปุ่ม Toggle ขวา */
@media (max-width: 1199px) {
    body.nh-legacy-inner-shell-page .ToggleRight,
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-right {
        display: inline-flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1203;
        width: auto;
        min-width: 36px;
        height: auto;
        padding: 14px 10px;
        border: 0;
        border-radius: 10px 0 0 10px;
        background: #ba5878;
        color: #fff;
        box-shadow: -3px 0 14px rgba(0, 0, 0, 0.22);
        cursor: pointer;
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    body.nh-legacy-inner-shell-page .ToggleRight[aria-expanded="true"],
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-right[aria-expanded="true"] {
        background: #8e3f5a;
    }

    body.nh-legacy-inner-shell-page.legacy-right-open .nh-legacy-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* แท็บเล็ตแคบ (<1024): เมนูซ้าย Toggle + เนื้อหาเต็มจอ */
@media (min-width: 768px) and (max-width: 1023px) {
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .nh-legacy-inner-center--with-left {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
    }

    body.nh-legacy-inner-shell-page .ToggleLeft,
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-left {
        display: inline-flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1203;
        width: auto;
        min-width: 36px;
        height: auto;
        padding: 14px 10px;
        border: 0;
        border-radius: 0 10px 10px 0;
        background: #ba5878;
        color: #fff;
        box-shadow: 3px 0 14px rgba(0, 0, 0, 0.22);
        cursor: pointer;
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    body.nh-legacy-inner-shell-page .ToggleLeft[aria-expanded="true"],
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-left[aria-expanded="true"] {
        background: #8e3f5a;
    }

    /* Toggle drawer ซ้าย — ความกว้างเท่ามือถือ (280px จาก legacy-home-bridge) */
    body.nh-legacy-inner-shell-page > #legacySidebarLeft,
    body.nh-legacy-inner-shell-page > #legacySidebarLeft.col-xs-3,
    body.nh-legacy-inner-shell-page > #legacySidebarLeft.nh-legacy-left-col,
    body.nh-legacy-inner-shell-page > #legacySidebarLeft.nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: auto !important;
        float: none !important;
        box-sizing: border-box !important;
        width: 280px !important;
        max-width: calc(100vw - 24px) !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 8px !important;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: #fff !important;
        z-index: 1202 !important;
        box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
        transition: transform 0.24s ease;
        transform: translate3d(-105%, 0, 0) !important;
        visibility: visible !important;
        display: block !important;
    }

    body.nh-legacy-inner-shell-page.legacy-left-open > #legacySidebarLeft,
    body.nh-legacy-inner-shell-page.legacy-left-open > #legacySidebarLeft.nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page.legacy-left-open .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        transform: translate3d(0, 0, 0) !important;
    }

    body.nh-legacy-inner-shell-page.legacy-left-open .nh-legacy-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* แท็บเล็ตกว้าง (1024–1199): เมนูซ้าย inline */
@media (min-width: 1024px) and (max-width: 1199px) {
    body.nh-legacy-inner-shell-page .ToggleLeft,
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-left {
        display: none !important;
    }

    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell > .container > .nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        display: block !important;
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        float: left !important;
        width: 20.7% !important;
        max-width: 20.7% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
        visibility: visible !important;
    }

    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .nh-legacy-inner-center--with-left {
        width: 79.3% !important;
        max-width: 79.3% !important;
        float: left !important;
    }

    /* เปิด drawer ขวา — เมนูซ้าย inline ไม่ลอยทับ overlay (override legacy-home-bridge) */
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell > .container > .nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell #legacySidebarLeft,
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-left-col,
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        float: left !important;
        z-index: auto !important;
        width: 20.7% !important;
        max-width: 20.7% !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
        visibility: visible !important;
        display: block !important;
    }
}

/* มือถือ — ไม่แก้ (คงพฤติกรรมเดิม) */
@media (max-width: 767px) {
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    body.nh-legacy-inner-shell-page #nongharn-inner-center,
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .container > #nongharn-inner-center,
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .container > .nh-legacy-inner-center {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        display: block !important;
        box-sizing: border-box;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        float: none !important;
        width: min(88vw, 340px) !important;
        max-width: min(88vw, 340px) !important;
        margin: 0 !important;
        padding: 10px !important;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: #fff !important;
        z-index: 1202 !important;
        box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
        transition: transform 0.24s ease;
        transform: translate3d(-105%, 0, 0) !important;
        visibility: visible !important;
        display: block !important;
    }

    body.nh-legacy-inner-shell-page.legacy-left-open > #legacySidebarLeft.nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page.legacy-left-open .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        transform: translate3d(0, 0, 0) !important;
    }

    body.nh-legacy-inner-shell-page.legacy-left-open .nh-legacy-overlay,
    body.nh-legacy-inner-shell-page.legacy-right-open .nh-legacy-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Desktop (≥1200): เมนูซ้าย inline */
@media (min-width: 1200px) {
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell > .container > .nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        display: block !important;
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        float: left !important;
        width: 20.7% !important;
        max-width: 20.7% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
        visibility: visible !important;
    }

    body.nh-legacy-inner-shell-page .nh-legacy-inner-shell .nh-legacy-inner-center--with-left {
        width: 79.3% !important;
        max-width: 79.3% !important;
        float: left !important;
    }

    body.nh-legacy-inner-shell-page .ToggleLeft,
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-left {
        display: none !important;
    }

    body.nh-legacy-inner-shell-page .ToggleRight,
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-right {
        display: inline-flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1203;
        width: auto;
        min-width: 36px;
        height: auto;
        padding: 14px 10px;
        border: 0;
        border-radius: 10px 0 0 10px;
        background: #ba5878;
        color: #fff;
        box-shadow: -3px 0 14px rgba(0, 0, 0, 0.22);
        cursor: pointer;
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    body.nh-legacy-inner-shell-page .ToggleRight[aria-expanded="true"],
    body.nh-legacy-inner-shell-page .nh-legacy-toggle-right[aria-expanded="true"] {
        background: #8e3f5a;
    }

    /* เปิด drawer ขวา — เมนูซ้าย inline ไม่ลอยทับ overlay */
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell > .container > .nh-legacy-inner-left-col,
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell #legacySidebarLeft,
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-left-col,
    body.nh-legacy-inner-shell-page.legacy-right-open:not(.legacy-left-open) .nh-legacy-inner-shell #legacySidebarLeft.nh-legacy-inner-left-col {
        position: relative !important;
        z-index: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
    }

    body.nh-legacy-inner-shell-page.legacy-right-open {
        overflow: hidden !important;
    }
}
