﻿/* 1. Container trang PDF */
.pdf-page {
    position: relative;
    display: block;
    width: fit-content;
    margin: 0 auto 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* 2. Wrapper (QUAN TRỌNG NHẤT) 
   - Chứa cả ảnh và nút xóa 
   - Chịu trách nhiệm căn giữa tâm tại điểm click
*/
.signature-wrapper {
    position: absolute;
    z-index: 100; /* Nổi lên trên PDF */
    display: inline-block;
    /* --- CĂN GIỮA TÂM (Logic Center) --- */
    transform: translate(-50%, -50%);
    /* Viền trong suốt mặc định (để giữ chỗ, tránh nhảy layout khi hover) */
    border: 1px dashed transparent;
    /*transition: all 0.2s ease;*/
    transition: background-color 0.2s, border-color 0.2s;
    cursor: pointer;

    /* --- 2 DÒNG QUAN TRỌNG ĐỂ CHỐNG CO MÉO --- */
    width: max-content; /* Bắt buộc wrapper rộng bằng nội dung bên trong */
    white-space: nowrap; /* Ngăn không cho nội dung bị xuống dòng/gấp nếp */
}

    /* 3. Hiệu ứng khi di chuột vào Wrapper */
    .signature-wrapper:hover {
        border: 1px dashed #0d6efd; /* Hiện viền xanh */
        background-color: rgba(13, 110, 253, 0.05); /* Nền xanh rất nhạt */
        z-index: 101; /* Đảm bảo nổi nhất khi hover */
    }

    /* 4. Ảnh chữ ký (Bên trong wrapper) */
    .signature-wrapper img {
        display: block; /* Loại bỏ khoảng trắng thừa dưới ảnh (do inline mặc định) */
        pointer-events: none; /* Để click chuột xuyên qua ảnh vào wrapper */

        /* Bắt buộc ảnh giữ nguyên size, bất chấp kích thước thẻ cha */
        max-width: none !important;
        height: auto !important;
    }

/* 5. Nút Xóa (Style Badge Đỏ Trắng) */
.btn-remove-sign {
    display: none; /* Ẩn mặc định */
    position: absolute;
    /* Treo nút lơ lửng ở góc trên-phải */
    top: -10px;
    right: -10px;
    /* Kích thước */
    width: 24px;
    height: 24px;
    /* Màu sắc */
    background-color: #fff;
    color: #dc3545;
    border: 1px solid #dc3545; /* Thêm viền đỏ mỏng cho sắc nét */
    border-radius: 50%;
    /* Căn chữ X */
    text-align: center;
    line-height: 22px; /* Canh giữa dọc */
    font-family: Arial, sans-serif;
    font-weight: bold;
    font-size: 16px;
    /* Hiệu ứng */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 200;
}

/* Hiện nút xóa khi hover vào Wrapper */
.signature-wrapper:hover .btn-remove-sign {
    display: block;
}

/* Hiệu ứng khi di chuột vào nút Xóa */
.btn-remove-sign:hover {
    background-color: #dc3545; /* Đảo màu: Nền đỏ */
    color: #fff; /* Chữ trắng */
    transform: scale(1.1); /* Phóng to nhẹ */
}

/* 6. Canvas vẽ (trong Modal) */
canvas#sign-pad {
    touch-action: none; /* Chặn cuộn trang trên mobile */
    width: 100%;
    height: 100%;
    display: block;
}


/* Nút Resize (Tay nắm kéo) */
/*.resize-handle {
    width: 12px;
    height: 12px;
    background-color: #0d6efd;*/ /* Màu xanh */
    /*position: absolute;
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;*/ /* Con trỏ chuột hình mũi tên chéo */
    /*z-index: 20;
    display: none;*/ /* Ẩn mặc định */
    /*border: 1px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}*/

.resize-handle {
    width: 20px;
    height: 20px;
    bottom: -10px;
    right: -10px;
    background-color: #0d6efd; /* Màu xanh */
    position: absolute;
    cursor: nwse-resize;
    z-index: 20;
    display: none;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border-radius: 3px; /* Bo góc nhẹ nhìn cho mềm mại */
}

/* Hover vào wrapper thì hiện nút resize */
.signature-wrapper:hover .resize-handle {
    display: block;
}


.signature-wrapper.is-active {
    border: 1px dashed #0d6efd;
    background-color: rgba(13, 110, 253, 0.05);
    z-index: 999; /* Đảm bảo luôn nổi lên trên cùng khi đang thao tác */
}

    /* Giữ cho các nút chức năng luôn hiện khi đang kéo (không bị ẩn mất) */
    .signature-wrapper.is-active .resize-handle,
    .signature-wrapper.is-active .btn-remove-sign {
        display: block;
    }


#pdf-render-area {
    overflow: auto;
    height: 76vh;
    border: 1px solid #ddd;
    position: relative;
    background-color: #7c7c7c; /* Màu nền xám nhẹ để dễ nhìn trang giấy */
    /* --- DÙNG FLEXBOX ĐỂ CĂN GIỮA --- */
    display: flex;
    justify-content: center; /* Căn giữa chiều ngang */
    align-items: flex-start; /* Căn đỉnh (để khi zoom to không bị mất phần đầu) */
}

#pdf-zoom-wrapper {
    /* Quan trọng: Khi zoom, nó sẽ phóng to từ tâm phía trên */
    transform-origin: top center;
    transition: transform 0.2s ease-out;
    /* Đệm thêm một chút margin để không bị dính sát lề khi zoom to */
    margin: 20px 0;
    /*box-shadow: 0 0 10px rgba(0,0,0,0.1);*/
}