@media print {
    .no-print {
        display: none !important;
    }

    .print-area {
        display: block !important;
    }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
}

.dashboard-main-view {
    display: grid;
    grid-template-columns: 1fr 320px;
    height: 100vh;
}

.custom-scroll::-webkit-scrollbar {
    width: 4px;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 10px;
}

.sidebar-gradient {
    background: linear-gradient(180deg, #064e3b 0%, #022c22 100%);
}

/* Chế độ xem trên Web (Live Edit) */
#edit-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background: white;
    margin: 0 auto;
    width: 210mm;
    min-height: 297mm;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* CHẾ ĐỘ IN CHUẨN (FIX FINAL: XÓA SẠCH PADDING ĐỂ KHÔNG BỊ LỀ DÀY) */
@media print {

    /* 1. Để margin auto để trình duyệt tự quyết định theo khổ giấy (Khắc phục lỗi đè lề) */
    @page {
        size: auto;
        margin: auto;
    }

    body {
        visibility: hidden;
        overflow: hidden;
    }

    /* 2. Căn chỉnh khung Modal tràn trang */
    #edit-modal {
        visibility: visible;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0 !important;
        display: block !important;
        overflow: visible !important;
        background: white !important;
    }

    .modal-content {
        box-shadow: none !important;
        margin: 0 !important;
        width: 100% !important;
        border: none !important;
    }

    /* 3. QUAN TRỌNG: Xóa sạch padding của khung soạn thảo khi in */
    /* Giúp nội dung sát ra mép, tận dụng lề Default của máy in mà không bị cộng dồn */
    #live-editor {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Xóa luôn padding của mẫu văn bản con bên trong nếu có */
    #live-editor>div {
        padding: 0 !important;
        margin: 0 !important;
    }

    .no-print {
        display: none !important;
    }

    .print-only {
        display: inline-block !important;
    }

    .print-only.hidden {
        display: inline-block !important;
    }

    input,
    select {
        border: none !important;
        background: transparent !important;
    }

    select {
        -webkit-appearance: none;
        -moz-appearance: none;
        text-indent: 1px;
        text-overflow: '';
    }
}

/* CSS CHO CÁC Ô NHẬP LIỆU TRONG VĂN BẢN */
#live-editor input[type="text"] {
    transition: all 0.2s;
}

.print-only {
    display: none;
}

#edit-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    overflow-y: auto;
}

.modal-content {
    background: white;
    margin: 20px auto;
    width: 210mm;
    min-height: 297mm;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.toolbar {
    position: sticky;
    top: 0;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    z-index: 20;
}

.toolbar button {
    background: white;
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.toolbar button:hover {
    background: #f1f5f9;
}

/* ADMINISTRATIVE STANDARDS (NĐ 30/2020) */
.admin-doc {
    font-family: 'Times New Roman', Times, serif !important;
    color: black;
    line-height: 1.5;
    font-size: 15px;
    /* Tăng từ 13px lên 15px cho rõ nét */
}

.admin-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.admin-header-left {
    text-align: center;
    width: 45%;
}

.admin-header-right {
    text-align: center;
    width: 55%;
}

.admin-title {
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 20px;
    /* Tăng lên 20px cho tiêu đề chính */
    margin: 25px 0;
}

.admin-body {
    text-align: left;
}

.admin-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    text-align: center;
    margin-top: 40px;
}

.admin-signature-space {
    height: 100px;
}

.doc-locked {
    background-color: #f8fafc !important;
    cursor: not-allowed;
    user-select: none;
    pointer-events: none;
    /* Khóa toàn bộ tương tác chuột vào vùng này */
}

#live-editor {
    background: white;
}

@media print {
    @page {
        size: A4;
        margin: 15mm 20mm 15mm 15mm;
        /* Giảm lề trái, tăng lề phải để dịch sang trái */
    }

    #edit-modal {
        position: absolute;
        inset: 0;
        background: white;
        padding: 0;
    }

    .modal-content {
        box-shadow: none;
        width: 100%;
        margin: 0;
    }

    .no-print {
        display: none !important;
    }
}