/* UI kit — tối ưu màn cảm ứng + điện thoại, dùng chung admin / website / cổng. Chỉ đọc token --ui-*.
   Hai khối: (pointer: coarse) = vùng chạm đủ lớn (Apple 44pt, Material 48dp); max-width 575.98px = lớp phủ dạng bottom sheet.
   Ô chọn có bottom sheet riêng ở pickers.css (ui-pickers.js · openSheet); menu thả xuống ở ui-bootstrap.js. */

@media (pointer: coarse) {
    /* Chạm đúp liên tiếp (nút +/-, trang kế...) không được phóng to trang và không chờ phân biệt cử chỉ */
    a, button, input, select, textarea, label, summary, [role="button"], [role="tab"], .ui-btn { touch-action: manipulation; }

    /* Nền mờ toàn màn hình (backdrop-filter) làm khung hình đầu của sheet/modal tốn hàng trăm ms trên GPU di động: dùng nền tối phẳng */
    .ui-picker-backdrop, .modal-backdrop, .offcanvas-backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; }

    /* Ô nhập/chọn, nút: cao 40px (nhỏ 36, lớn 44) — vừa tay mà không to quá so với điện thoại thật; vùng chạm nhỏ hơn được nới bằng ::after; Tom Select và .ui-input cùng đọc các token này */
    :root { --ui-control-h: 40px; --ui-control-h-sm: 36px; --ui-control-h-lg: 44px; }
    .ui-btn { --btn-h: 40px; }
    .ui-btn--sm { --btn-h: 36px; }
    .ui-btn--lg { --btn-h: 44px; }
    .ui-btn--xl { --btn-h: 48px; }
    .ui-btn--link { min-height: 2.5rem; }

    /* Nút phụ trong/ngay cạnh ô nhập, huy hiệu, gợi ý, đóng: nới vùng chạm bằng vùng ẩn, không làm to hình */
    .ui-input-btn { width: 2rem; height: 2rem; }
    .ui-color-swatch { width: 2rem; height: 2rem; }
    .ui-badge-remove, .ui-hint, .ui-copy, .carousel-indicators [data-bs-target] { position: relative; }
    .ui-badge-remove::after, .ui-hint::after, .ui-copy::after { content: ""; position: absolute; inset: -.55rem; }
    .carousel-indicators [data-bs-target]::after { content: ""; position: absolute; inset: -.9rem -.5rem; }
    .btn-close { width: 2.25rem; height: 2.25rem; padding: 0; background-size: .9rem; }
    .ui-range { height: 1.75rem; }

    /* Selector khớp độ đặc hiệu của khay phân trang ở pill.css (ul.pagination .page-item .page-link) */
    .ui-pagination ul.pagination .page-item .page-link, .ui-pagination ul.pagination:not(.pagination-sm) .page-item .page-link { min-width: 2.25rem; height: 2.5rem; }
    .breadcrumb-item a, .ui-tag, .icon-link { display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem; }
    .breadcrumb-item a { min-width: 2.25rem; }
    .dropdown-item { min-height: 2.5rem; }
    .nav-link, .ui-tab { min-height: 2.5rem; }
    .accordion-button { min-height: 2.75rem; }
    .list-group-item-action { min-height: 2.75rem; }
}

@media (max-width: 575.98px) and (pointer: coarse) {
    /* Hộp thoại: bottom sheet từ đáy màn hình thay vì thẻ nổi giữa (xác nhận xoá, xem nhanh, form trong modal) */
    .modal-dialog:not(.modal-fullscreen) { width: 100%; max-width: none; min-height: 100%; margin: 0; align-items: flex-end; }
    .modal-dialog-centered { min-height: 100%; }
    .ui-modal .modal-content, .admin-dialog .modal-content, .admin-view-modal .modal-content {
        max-height: 92dvh; border-radius: 20px 20px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom);
    }
    .ui-modal .modal-content::before, .admin-dialog .modal-content::before, .admin-view-modal .modal-content::before {
        content: ""; flex: none; display: block; width: 2.5rem; height: .3125rem; margin: .5rem auto 0; border-radius: 999px; background: var(--ui-line-strong);
    }
    .ui-modal.fade .modal-dialog, .admin-dialog.fade .modal-dialog, .admin-view-modal.fade .modal-dialog { translate: 0 100%; scale: 1; opacity: 1; transform: none; transition: translate .32s cubic-bezier(.22, 1, .36, 1); }
    .ui-modal.show .modal-dialog, .admin-dialog.show .modal-dialog, .admin-view-modal.show .modal-dialog { translate: 0 0; }

    /* Menu thả xuống: action sheet (class is-sheet-menu do ui-bootstrap.js gắn khi mở) */
    .dropdown-menu.is-sheet-menu.show {
        position: fixed !important; inset: auto 0 0 0 !important; z-index: 99999; transform: none !important;
        display: block; width: 100%; max-width: none; min-width: 0; max-height: 75dvh; margin: 0 !important; overflow-y: auto; overscroll-behavior: contain;
        padding: .5rem .5rem calc(.75rem + env(safe-area-inset-bottom)); border: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgb(15 23 42 / .2);
        background: var(--ui-surface); animation: ui-sheet-rise .3s cubic-bezier(.22, 1, .36, 1);
    }
    .dropdown-menu.is-sheet-menu.show::before { content: ""; display: block; width: 2.5rem; height: .3125rem; margin: 0 auto .5rem; border-radius: 999px; background: var(--ui-line-strong); }
    .dropdown-menu.is-sheet-menu .dropdown-item { min-height: 3rem; padding: .7rem .85rem; font-size: 1rem; border-radius: var(--ui-radius); }
    .dropdown-menu.is-sheet-menu .dropdown-header { padding: .5rem .85rem .25rem; }

    .ui-pagination ul.pagination .page-item .page-link { padding: 0 .35rem; }

    /* Ma trận (bảng công): cột tên ghim trái gọn lại để thấy nhiều ô hơn, phần còn lại cuộn ngang */
    .ui-matrix-name { min-width: 8.5rem; padding: .55rem .6rem !important; }

    /* Toast: dải ngang đầu/đáy màn hình, không tràn mép, tránh thanh home */
    .ui-toast { width: calc(100vw - 1.5rem); }
}

@keyframes ui-sheet-rise { from { translate: 0 100%; } to { translate: 0 0; } }

/* Phân trang nhiều trang trên màn hẹp (không phụ thuộc loại con trỏ): cuộn ngang trong khay thay vì tràn khỏi màn hình */
@media (max-width: 575.98px) {
    .ui-pagination ul.pagination { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .ui-pagination ul.pagination::-webkit-scrollbar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .dropdown-menu.is-sheet-menu.show { animation: none; }
    .ui-modal.fade .modal-dialog, .admin-dialog.fade .modal-dialog, .admin-view-modal.fade .modal-dialog { transition: none; }
}
