/* Thanh nút cố định cuối màn — responsive mobile / desktop */
.fixed-bottom-actions {
    position: fixed !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    z-index: 1050;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 12px;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    background: #fff;
    box-shadow: 0 -2px 10px rgba(18, 38, 63, 0.1);
    box-sizing: border-box;
    max-width: 100vw;
}

.fixed-bottom-actions--end {
    justify-content: flex-end;
}

/* Căn theo vùng nội dung khi có sidebar (layout vertical) */
@media (min-width: 992px) {
    .vertical .fixed-bottom-actions,
    .vertical.hover .fixed-bottom-actions,
    .narrow.open .fixed-bottom-actions {
        left: 16rem;
    }

    .vertical.collapsed .fixed-bottom-actions,
    .vertical.narrow .fixed-bottom-actions,
    .vertical.narrow.hover .fixed-bottom-actions {
        left: 5rem;
    }

    .vertical.collapsed.narrow.open .fixed-bottom-actions {
        left: 16rem;
    }
}

@media (max-width: 991.98px) {
    .fixed-bottom-actions {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        margin-left: 0 !important;
    }
}

.fixed-bottom-actions .btn {
    flex: 0 0 auto;
    max-width: 100%;
    white-space: nowrap;
}

.fixed-bottom-actions .btn svg {
    flex-shrink: 0;
}

/* Mobile: nút full width, không bị co / chồng chữ */
@media (max-width: 576px) {
    .fixed-bottom-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    }

    .fixed-bottom-actions--end {
        justify-content: stretch;
    }

    .fixed-bottom-actions .btn {
        width: 100%;
        min-height: 44px;
        white-space: normal;
        text-align: center;
        justify-content: center;
    }

    .fixed-bottom-actions #LyDoTuChoiForm,
    .fixed-bottom-actions .form-group {
        width: 100%;
        flex: 1 1 100%;
        margin-bottom: 0;
    }

    #pdf-viewer {
        height: calc(100vh - 220px) !important;
    }
}

/* Tablet: cho phép xuống dòng nhưng giữ nút đủ rộng */
@media (min-width: 577px) and (max-width: 991.98px) {
    .fixed-bottom-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .fixed-bottom-actions--end {
        justify-content: flex-end;
    }

    .fixed-bottom-actions .btn {
        flex: 0 1 auto;
        min-width: min(100%, 12rem);
    }
}

/* Tránh overflow:hidden trên main-content làm thanh nút không bám viewport */
.vertical .main-content:has(.fixed-bottom-actions),
.vertical.hover .main-content:has(.fixed-bottom-actions),
.vertical.narrow .main-content:has(.fixed-bottom-actions),
.narrow.open .main-content:has(.fixed-bottom-actions) {
    overflow-x: hidden;
    overflow-y: auto;
}

.main-content:has(.fixed-bottom-actions) {
    padding-bottom: 5.5rem;
}

@media (max-width: 576px) {
    .main-content:has(.fixed-bottom-actions) {
        padding-bottom: 8rem;
    }
}

/* Tab ẩn: không hiển thị thanh nút của tab khác */
.tab-pane:not(.active) .fixed-bottom-actions {
    display: none !important;
}
