/* ============================================================================
   WMS Print CSS — A4 portrait, mẫu in thống nhất cho mọi loại phiếu
   File: wwwroot/css/wms-print.css
   ============================================================================ */

/* ==== Tokens (đồng bộ với --wms-*) ==== */
.print-page {
    --print-ink: #1a1a1a;
    --print-muted: #555;
    --print-border: #888;
    --print-border-light: #ddd;
    --print-accent: #1f3b73;
    --print-danger: #b91c1c;
    --print-success: #166534;
}

/* ==== Reset / wrapper ==== */
.print-page,
.print-page * {
    box-sizing: border-box;
}
.print-page {
    color: var(--print-ink);
    font-family: "Times New Roman", "DejaVu Serif", serif;
    font-size: 12pt;
    line-height: 1.4;
    background: #f4f4f4;
    margin: 0;
    padding: 1.5rem 0;
    min-height: 100vh;
}

.print-toolbar {
    max-width: 21cm;
    margin: 0 auto 1rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--print-border-light);
    border-radius: 6px;
}
.print-toolbar .left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.print-toolbar button,
.print-toolbar a.btn {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--print-border);
    background: #fff;
    cursor: pointer;
    border-radius: 4px;
    font-size: 11pt;
    text-decoration: none;
    color: var(--print-ink);
}
.print-toolbar button.primary {
    background: var(--print-accent);
    color: #fff;
    border-color: var(--print-accent);
}
.print-toolbar button.primary:hover { opacity: 0.9; }

/* ==== Sheet A4 ==== */
.print-sheet {
    width: 21cm;
    min-height: 29.7cm;
    margin: 0 auto;
    padding: 1.5cm 1.6cm;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

/* ==== Header công ty ==== */
.print-header {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid var(--print-ink);
    padding-bottom: 0.6rem;
    margin-bottom: 0.6rem;
}
.print-header .logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    flex-shrink: 0;
}
.print-header .logo-placeholder {
    width: 80px;
    height: 80px;
    border: 1px dashed var(--print-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--print-muted);
    font-size: 9pt;
    flex-shrink: 0;
}
.print-header .info {
    flex: 1;
    font-size: 10.5pt;
    line-height: 1.35;
}
.print-header .info .ten-cty {
    font-weight: bold;
    font-size: 13pt;
    text-transform: uppercase;
    color: var(--print-accent);
}
.print-header .info .row {
    color: var(--print-muted);
}

/* ==== Title (TÊN PHIẾU) ==== */
.print-title {
    text-align: center;
    margin: 1rem 0 0.4rem;
}
.print-title h1 {
    font-size: 22pt;
    font-weight: bold;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.print-title .subtitle {
    font-size: 10pt;
    color: var(--print-muted);
    margin-top: 0.2rem;
}
.print-title .ma-phieu {
    text-align: center;
    margin-bottom: 0.6rem;
    font-size: 11pt;
}
.print-title .ma-phieu strong {
    font-size: 12pt;
    color: var(--print-accent);
}

/* ==== Meta block (ngày, NCC, kho...) ==== */
.print-meta {
    width: 100%;
    margin-bottom: 0.8rem;
    font-size: 11pt;
}
.print-meta td {
    padding: 0.18rem 0.4rem 0.18rem 0;
    vertical-align: top;
}
.print-meta td.label {
    width: 28%;
    color: var(--print-muted);
}
.print-meta td.value {
    width: 22%;
}
.print-meta strong { font-weight: 600; }

/* ==== Bảng chi tiết ==== */
.print-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.6rem 0;
    font-size: 10.5pt;
}
.print-table th,
.print-table td {
    border: 1px solid var(--print-ink);
    padding: 0.35rem 0.45rem;
    vertical-align: top;
}
.print-table thead th {
    background: #eef2f7;
    font-weight: bold;
    text-align: center !important;
    vertical-align: middle;
}
.print-table .text-right { text-align: right; }
.print-table .text-center { text-align: center; }
.print-table tfoot td {
    font-weight: bold;
    background: #f7f7f7;
}
.print-table .stt { width: 3%; text-align: center; }
.print-table .ma { width: 10%; }
.print-table .ten-hang { width: auto; }
.print-table .dvt { width: 7%; text-align: center; }
.print-table .so-luong { width: 9%; text-align: right; }
.print-table .don-gia { width: 11%; text-align: right; }
.print-table .thanh-tien { width: 13%; text-align: right; }
.print-table .vat { width: 7%; text-align: center; }

/* ==== Tổng tiền box ==== */
.print-totals {
    margin-top: 0.4rem;
    display: flex;
    justify-content: flex-end;
}
.print-totals table {
    border-collapse: collapse;
    min-width: 50%;
    font-size: 11pt;
}
.print-totals td {
    padding: 0.2rem 0.5rem;
}
.print-totals td.label {
    text-align: right;
    color: var(--print-muted);
}
.print-totals td.value {
    text-align: right;
    min-width: 5cm;
}
.print-totals tr.grand td {
    border-top: 1.5px solid var(--print-ink);
    padding-top: 0.4rem;
    font-weight: bold;
    font-size: 12pt;
}
.print-totals tr.grand td.value {
    color: var(--print-accent);
}

/* ==== Bằng chữ ==== */
.print-bang-chu {
    font-style: italic;
    margin-top: 0.4rem;
    font-size: 11pt;
}
.print-bang-chu strong { font-style: normal; font-weight: 600; }

/* ==== Ghi chú / Lý do ==== */
.print-notes {
    margin-top: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-left: 3px solid var(--print-border);
    background: #fafafa;
    font-size: 11pt;
}
.print-notes .label {
    color: var(--print-muted);
    font-weight: 600;
    margin-right: 0.3rem;
}

/* ==== Chữ ký ==== */
.print-signatures {
    margin-top: 1.6rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    text-align: center;
    font-size: 11pt;
    page-break-inside: avoid;
}
.print-signatures .sig {
    padding: 0 0.3rem;
}
.print-signatures .sig .role {
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}
.print-signatures .sig .hint {
    font-style: italic;
    color: var(--print-muted);
    font-size: 9.5pt;
    margin-bottom: 3.5cm;   /* khoảng trống ký */
}
.print-signatures .sig .name {
    border-top: 1px dotted var(--print-border);
    padding-top: 0.2rem;
    font-weight: 600;
    min-height: 1.4em;
}
.print-signatures .sig .date {
    font-size: 9.5pt;
    color: var(--print-muted);
}

/* ==== Watermark "ĐÃ DUYỆT" / "BẢN NHÁP" ==== */
.print-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 90pt;
    font-weight: bold;
    color: rgba(0,0,0,0.06);
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
    letter-spacing: 8px;
    user-select: none;
}
.print-watermark.draft {
    color: rgba(180, 70, 70, 0.08);
}
.print-watermark.cancelled {
    color: rgba(180, 30, 30, 0.12);
}

/* ==== Trạng thái pill (ở header in) ==== */
.print-status {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 9.5pt;
    font-weight: 600;
    margin-left: 0.5rem;
    vertical-align: middle;
}
.print-status.success { color: var(--print-success); }
.print-status.danger { color: var(--print-danger); }
.print-status.muted { color: var(--print-muted); }
.print-status.accent { color: var(--print-accent); }

/* ==== @media print ==== */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }
    html, body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .print-page {
        background: #fff !important;
        padding: 0 !important;
    }
    .print-toolbar {
        display: none !important;
    }
    .print-sheet {
        width: 100% !important;
        min-height: auto !important;
        margin: 0 !important;
        box-shadow: none !important;
        padding: 1cm 1.2cm !important;
    }
    /* Tránh ngắt trang giữa bảng/chữ ký */
    .print-table thead { display: table-header-group; }
    .print-table tr { page-break-inside: avoid; }
    .print-signatures { page-break-inside: avoid; }
}
