/*
 * cursor.css — con trỏ chuột dùng ảnh riêng.
 * Đặt tất cả file ảnh .png cùng thư mục với cursor.css (ví dụ /assets/cursor/)
 *   mouse.png   = mũi tên (con trỏ thường)   — đầu mũi tên ở điểm (4, 2)
 *   mouse1.png  = bàn tay (nút / liên kết)   — đầu ngón trỏ ở điểm (9, 2)
 *   text.png    = chữ I (ô nhập chữ)         — tâm ở điểm (10, 12); text@2x.png là bản 2x cho màn hình retina
 *   wait.png, grab.png, grabbing.png, resize-h.png, resize-v.png, notallowed.png (mỗi cái có thêm bản @2x) — hotspot (13, 13)
 * Số sau mỗi url(...) là "hotspot": điểm ảnh thực sự bấm trúng. Lệch thì chỉnh 2 số này.
 */

/* Con trỏ thường: đặt ở html, các phần tử khác tự kế thừa */
html {
    cursor: url('mouse.png') 4 2, auto;
}

/* Ô chọn: trình duyệt mặc định dùng mũi tên gốc, đổi sang mũi tên của bạn cho đồng bộ */
select,
.form-select {
    cursor: url('mouse.png') 4 2, default !important;
}

/* Nút, liên kết, thứ bấm được: hiện bàn tay (!important để thắng cursor:pointer của Bootstrap/Velzon) */
a[href],
button:not(:disabled),
.btn:not(:disabled):not(.disabled),
[role="button"],
summary,
label[for],
input[type="button"]:not(:disabled),
input[type="submit"]:not(:disabled),
input[type="reset"]:not(:disabled),
input[type="checkbox"],
input[type="radio"],
.form-check-input,
.form-check-label,
[onclick],
[data-bs-toggle],
.page-link,
.dropdown-item,
.nav-link,
.waves-effect,
.cursor-pointer,
.leaflet-marker-icon,
.leaflet-control a {
    cursor: url('mouse1.png') 9 2, pointer !important;
}

/* Ô nhập chữ (input, textarea, vùng soạn thảo): hiện chữ I cùng phong cách để thấy rõ chỗ gõ */
input:not([type]),
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"],
input[type="week"],
textarea,
[contenteditable=""],
[contenteditable="true"] {
    cursor: url('text.png') 10 12, text !important;
}

/* Màn hình retina: dùng bản 2x cho nét căng (trình duyệt không hỗ trợ image-set sẽ giữ khai báo ở trên) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    input:not([type]),
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    textarea,
    [contenteditable=""],
    [contenteditable="true"] {
        cursor: -webkit-image-set(url('text.png') 1x, url('text@2x.png') 2x) 10 12, text !important;
    }
}

/* ====== Các trạng thái con trỏ còn lại ======
 * Mỗi rule có 2 dòng cursor: dòng đầu là ảnh 1x (dự phòng), dòng sau là image-set để màn hình retina dùng ảnh @2x.
 * Muốn bật bằng JS: thêm/bớt class (ví dụ document.body.classList.add('cursor-wait')) — đặt style.cursor = 'wait' trực tiếp
 * cũng được, các rule [style*="cursor: ..."] bên dưới sẽ tự đổi sang ảnh của bạn.
 */

/* Đang tải */
.cursor-wait,
.cursor-wait *,
body.loading,
body.loading *,
[aria-busy="true"],
[style*="cursor: wait"],
[style*="cursor:wait"],
[style*="cursor: progress"],
[style*="cursor:progress"] {
    cursor: url('wait.png') 13 13, wait !important;
    cursor: -webkit-image-set(url('wait.png') 1x, url('wait@2x.png') 2x) 13 13, wait !important;
}

/* Bàn tay mở (có thể kéo) — Leaflet, Swiper, sắp xếp kéo thả... */
.cursor-grab,
.leaflet-grab,
.leaflet-container.leaflet-grab,
[style*="cursor: grab"],
[style*="cursor:grab"] {
    cursor: url('grab.png') 13 13, grab !important;
    cursor: -webkit-image-set(url('grab.png') 1x, url('grab@2x.png') 2x) 13 13, grab !important;
}

/* Nắm tay (đang kéo) — đặt SAU rule grab để thắng khi cả hai cùng khớp */
.cursor-grabbing,
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-interactive,
.sortable-chosen,
.sortable-drag,
[style*="cursor: grabbing"],
[style*="cursor:grabbing"],
[style*="cursor: move"],
[style*="cursor:move"] {
    cursor: url('grabbing.png') 13 13, grabbing !important;
    cursor: -webkit-image-set(url('grabbing.png') 1x, url('grabbing@2x.png') 2x) 13 13, grabbing !important;
}

/* Kéo giãn ngang (cột bảng, thanh chia đôi) */
.cursor-col-resize,
.gutter-horizontal,
.ui-resizable-e,
.ui-resizable-w,
[style*="cursor: col-resize"],
[style*="cursor:col-resize"],
[style*="cursor: ew-resize"],
[style*="cursor:ew-resize"],
[style*="cursor: e-resize"],
[style*="cursor: w-resize"] {
    cursor: url('resize-h.png') 13 13, col-resize !important;
    cursor: -webkit-image-set(url('resize-h.png') 1x, url('resize-h@2x.png') 2x) 13 13, col-resize !important;
}

/* Kéo giãn dọc */
.cursor-row-resize,
.gutter-vertical,
.ui-resizable-n,
.ui-resizable-s,
[style*="cursor: row-resize"],
[style*="cursor:row-resize"],
[style*="cursor: ns-resize"],
[style*="cursor:ns-resize"],
[style*="cursor: n-resize"],
[style*="cursor: s-resize"] {
    cursor: url('resize-v.png') 13 13, row-resize !important;
    cursor: -webkit-image-set(url('resize-v.png') 1x, url('resize-v@2x.png') 2x) 13 13, row-resize !important;
}

/* Không được phép: nút / ô nhập bị khóa.
 * Bootstrap đặt pointer-events:none cho nút bị khóa nên con trỏ không bao giờ hiện; bật lại ở đây.
 * (Không áp cho a.btn.disabled để liên kết bị khóa vẫn không bấm được.) Đặt cuối file để thắng các rule ô nhập ở trên. */
button:disabled,
.btn:disabled,
input:disabled,
textarea:disabled,
select:disabled,
fieldset:disabled *,
.cursor-not-allowed,
[style*="cursor: not-allowed"],
[style*="cursor:not-allowed"],
[style*="cursor: no-drop"] {
    pointer-events: auto;
    cursor: url('notallowed.png') 13 13, not-allowed !important;
    cursor: -webkit-image-set(url('notallowed.png') 1x, url('notallowed@2x.png') 2x) 13 13, not-allowed !important;
}