/* =============================================================================
   Giao diện kiểu app trên điện thoại / máy tính bảng (≤991.98px, cùng mốc navbar-expand-lg).
   Header: logo + nút Tìm kiếm; thanh tab dưới; bottom sheet Tìm kiếm / Thêm.
   Theo mẫu CIAT (css/ciat-theme.css + js/ciat-mobile.js). JS: Assets/js/sotay-mobile.js
   ========================================================================== */
:root {
    --st-tab-h: 62px;
}

.st-appbar__btn,
.st-tabbar,
.st-sheet {
    display: none;
}

/* Nút cài ứng dụng (PWA) - js/pwa-install.js chèn vào footer khi trình duyệt cho phép cài */
.vs-pwa-install-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
    cursor: pointer;
    background: var(--primary, #1B6B2A);
    border: 0;
    border-radius: 999px;
}

.vs-pwa-install-btn[hidden] {
    display: none !important;
}

.vs-pwa-install-btn:hover {
    background: var(--primary-dark, #0D4A1A);
}

@media (max-width: 991.98px) {
    body.st-app {
        padding-bottom: calc(var(--st-tab-h) + env(safe-area-inset-bottom, 0px));
    }

    /* Ẩn nút ☰ và menu thả xuống: thay bằng thanh tab + sheet */
    body.st-app .site-header #navMainToggler,
    body.st-app .site-header #navMain {
        display: none !important;
    }

    body.st-app .site-header .navbar {
        padding: 0.35rem 0;
    }

    body.st-app .site-header .navbar > .container-fluid {
        flex-wrap: nowrap !important;
    }

    body.st-app .site-header .navbar-brand {
        flex: 1 1 auto;
        min-width: 0;
        margin-right: 4px;
    }

    body.st-app .site-header .brand-icon {
        width: 38px;
        height: 38px;
        flex: 0 0 auto;
    }

    body.st-app .site-header .brand-icon .bi {
        font-size: 26px !important;
        margin: 0 !important;
    }

    body.st-app .site-header .brand-text {
        min-width: 0;
        overflow: hidden;
    }

    body.st-app .site-header .brand-text span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .st-appbar__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 42px;
        height: 42px;
        margin-right: -6px;
        padding: 0;
        font-size: 20px;
        color: #fff;
        background: transparent;
        border: 0;
        border-radius: 12px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .st-appbar__btn:active,
    .st-appbar__btn[aria-expanded="true"] {
        background: rgba(255, 255, 255, 0.16);
    }

    /* ----- Thanh tab dưới ----- */
    body.st-app .st-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        height: calc(var(--st-tab-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-top: 1px solid var(--border, #D4E0D4);
        box-shadow: 0 -4px 16px rgba(13, 74, 26, 0.08);
    }

    .st-tabbar > a,
    .st-tabbar > button {
        position: relative;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-width: 0;
        padding: 0;
        font-family: var(--font, 'Be Vietnam Pro', sans-serif);
        font-size: 11.5px;
        font-weight: 600;
        line-height: 1.2;
        color: #5f6b66;
        text-decoration: none !important;
        background: transparent;
        border: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .st-tabbar > * .bi {
        font-size: 21px;
        line-height: 1;
    }

    .st-tabbar > * span {
        max-width: 100%;
        padding: 0 2px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .st-tabbar > .is-active,
    .st-tabbar > [aria-expanded="true"] {
        color: var(--primary, #1B6B2A);
    }

    .st-tabbar > .is-active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 28%;
        right: 28%;
        height: 3px;
        background: var(--primary, #1B6B2A);
        border-radius: 0 0 3px 3px;
    }

    .st-tabbar > .is-loading .bi::before {
        content: "\f130"; /* bi-arrow-repeat */
    }

    .st-tabbar > .is-loading .bi {
        animation: st-xoay 0.8s linear infinite;
    }

    @keyframes st-xoay {
        to { transform: rotate(360deg); }
    }

    /* Bàn phím ảo mở: ẩn thanh tab */
    body.st-app.st-kb-mo .st-tabbar {
        display: none;
    }

    body.st-app.st-kb-mo {
        padding-bottom: 0;
    }

    /* Trang Chat: form cao 100dvh → chừa chỗ cho thanh tab */
    body.st-app.page-chat {
        padding-bottom: 0;
    }

    body.st-app.page-chat #form_admin {
        height: calc(100dvh - var(--st-tab-h) - env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - var(--st-tab-h) - env(safe-area-inset-bottom, 0px));
        min-height: 0;
    }

    body.st-app.page-chat.st-kb-mo #form_admin {
        height: 100dvh;
        max-height: 100dvh;
    }

    body.st-sheet-mo {
        overflow: hidden;
    }

    /* Footer: chỉ hiện ở trang chủ (các trang khác đã có thanh tab) */
    body.st-app:not(.st-trang-chu) .site-footer {
        display: none !important;
    }

    /* ----- Bottom sheet ----- */
    .st-sheet {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1045;
    }

    .st-sheet[hidden] {
        display: none;
    }

    .st-sheet__nen {
        position: absolute;
        inset: 0;
        background: rgba(6, 30, 12, 0.45);
        opacity: 0;
        transition: opacity 0.2s;
    }

    .st-sheet__khung {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
        max-height: 86vh;
        max-width: 720px;
        margin: 0 auto;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
        transform: translateY(100%);
        transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    .st-sheet.is-mo .st-sheet__nen {
        opacity: 1;
    }

    .st-sheet.is-mo .st-sheet__khung {
        transform: translateY(0);
    }

    .st-sheet__dau {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px 12px 8px 18px;
        touch-action: none;
    }

    .st-sheet__keo {
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        background: #d3dcd7;
        border-radius: 2px;
    }

    .st-sheet__dau h2 {
        margin: 0;
        font-family: var(--font, 'Be Vietnam Pro', sans-serif);
        font-size: 18px;
        font-weight: 700;
        color: var(--primary-dark, #0D4A1A);
    }

    .st-sheet__dong {
        width: 40px;
        height: 40px;
        font-size: 16px;
        color: #3b4a42;
        background: #f1f5f3;
        border: 0;
        border-radius: 50%;
    }

    .st-sheet__than {
        padding: 4px 14px 20px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        font-family: var(--font, 'Be Vietnam Pro', sans-serif);
    }

    .st-sheet__h {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 16px 4px 8px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #6b7a72;
    }

    .st-sheet__luoi {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .st-sheet__o {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 7px;
        min-height: 80px;
        padding: 8px 4px;
        font-size: 12.5px;
        font-weight: 600;
        line-height: 1.25;
        text-align: center;
        color: var(--text-main, #1A2E1A) !important;
        text-decoration: none !important;
        background: var(--success-bg, #E8F5E9);
        border: 0;
        border-radius: 14px;
    }

    .st-sheet__o .bi {
        font-size: 22px;
        color: var(--primary, #1B6B2A);
    }

    .st-sheet__ds {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border: 1px solid var(--border, #D4E0D4);
        border-radius: 14px;
    }

    .st-sheet__ds a {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 46px;
        padding: 8px 14px;
        font-size: 14.5px;
        line-height: 1.35;
        color: var(--text-main, #1A2E1A) !important;
        text-decoration: none !important;
        border-top: 1px solid #eef2ef;
    }

    .st-sheet__ds a:first-child {
        border-top: 0;
    }

    .st-sheet__ds a .bi {
        width: 18px;
        margin: 0 !important;
        color: var(--primary, #1B6B2A);
    }

    .st-sheet__ds a.text-danger,
    .st-sheet__ds a.text-danger .bi {
        color: #c62828 !important;
    }

    /* Tìm kiếm */
    .st-search {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 6px 6px 14px;
        background: #fff;
        border: 1.5px solid #cfdad3;
        border-radius: 999px;
    }

    .st-search:focus-within {
        border-color: var(--primary, #1B6B2A);
        box-shadow: 0 0 0 3px rgba(27, 107, 42, 0.15);
    }

    .st-search > .bi {
        color: #8a9a91;
    }

    .st-search input {
        flex: 1;
        min-width: 0;
        height: 40px;
        padding: 0;
        font-size: 16px;
        color: var(--text-main, #1A2E1A);
        background: transparent;
        border: 0;
        outline: 0;
    }

    .st-search input.is-loi {
        animation: st-lac 0.3s 2;
    }

    @keyframes st-lac {
        25% { transform: translateX(-4px); }
        75% { transform: translateX(4px); }
    }

    .st-search button {
        height: 40px;
        padding: 0 18px;
        font-size: 14.5px;
        font-weight: 700;
        color: #fff;
        background: var(--primary, #1B6B2A);
        border: 0;
        border-radius: 999px;
    }

    .st-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .st-chips button {
        padding: 8px 14px;
        font-size: 13.5px;
        font-weight: 600;
        color: var(--primary-dark, #0D4A1A);
        background: var(--success-bg, #E8F5E9);
        border: 0;
        border-radius: 999px;
    }
}

/* ---------- Flipbook PDF trong nội dung (App_Code/FlipbookHelper.vb, plugin CKEditor flipbook) ---------- */
.news-flipbook-embed {
    margin: 18px 0 22px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid var(--border, #D4E0D4);
    border-radius: 14px;
    box-shadow: var(--shadow, 0 2px 8px rgba(27,107,42,0.10));
}

.news-flipbook-embed iframe,
iframe.hmu-flipbook {
    display: block;
    width: 100% !important;
    height: 620px;
    max-width: 100%;
    border: 0 !important;
    border-radius: 0 !important;
}

.news-flipbook-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin: 0 !important;
    padding: 10px 14px;
    background: #fff;
}

.news-flipbook-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 14px !important;
    font-weight: 700;
    color: var(--primary, #1B6B2A) !important;
    text-decoration: none !important;
    background: var(--success-bg, #E8F5E9);
    border-radius: 999px;
}

.news-flipbook-actions a:hover {
    color: #fff !important;
    background: var(--primary, #1B6B2A);
}

@media (max-width: 767px) {
    .news-flipbook-embed iframe,
    iframe.hmu-flipbook {
        height: 460px;
    }

    .news-flipbook-actions {
        justify-content: center;
    }
}
