/* ============================================================
   Link Biz - 見積書 印刷用CSS
   @media print / プレビュー共用
   ============================================================ */

/* ── プレビューモーダル内の見た目 ─────────────────────── */
.qp-preview-wrap {
    background  : #e5e7eb;
    padding     : 1.5rem;
    display     : flex;
    flex-direction : column;
    align-items : center;
    gap         : 1.5rem;
    overflow-y  : auto;
    max-height  : 80vh;
}

/* A4ページ（プレビュー時は縮小表示） */
.qp-page {
    width           : 210mm;
    height          : 297mm;
    background      : #fff;
    box-shadow      : 0 2px 12px rgba(0,0,0,.18);
    display         : flex;
    flex-direction  : column;
    box-sizing      : border-box;
    padding         : 10mm;
    font-family     : 'Noto Sans JP', 'Hiragino Sans', 'Meiryo', sans-serif;
    font-size       : 9pt;
    line-height     : 1.5;
    color           : #111;
    position        : relative;
    /* プレビュー時は画面に収めるため縮小 */
    transform-origin: top center;
}

/* ── ページヘッダー ───────────────────────────────────── */
.qp-doc-title {
    text-align  : center;
    font-size   : 16pt;
    font-weight : 700;
    letter-spacing: .15em;
    border-bottom : 2px solid #111;
    padding-bottom: 2mm;
    margin-bottom : 4mm;
}

/* 送付先・自社情報を2カラムで並べる */
.qp-info-row {
    display               : grid;
    grid-template-columns : 1fr 1fr;
    gap                   : 4mm;
    margin-bottom         : 3mm;
}

/* 宛先ブロック */
.qp-to-block {
    font-size : 9pt;
}
.qp-to-company {
    font-size   : 11pt;
    font-weight : 700;
    border-bottom : 1.5px solid #111;
    padding-bottom: 1mm;
    margin-bottom : 1.5mm;
}
.qp-to-dept, .qp-to-contact {
    font-size : 9pt;
    color     : #333;
}
.qp-honorific {
    font-size : 8pt;
    margin-left: 1mm;
}

/* 自社・見積情報ブロック */
.qp-meta-block {
    font-size  : 8pt;
    text-align : right;
    color      : #333;
    line-height: 1.8;
}
.qp-meta-block .qp-meta-company {
    font-size   : 9pt;
    font-weight : 700;
    color       : #111;
}
.qp-meta-block .qp-quote-number {
    font-size   : 9pt;
    font-weight : 700;
    font-family : monospace;
    color       : #111;
    margin-top  : 2mm;
}

/* 件名・日付帯 */
.qp-subject-bar {
    background    : #f3f4f6;
    border        : 1px solid #d1d5db;
    border-radius : 1mm;
    padding       : 2mm 3mm;
    margin-bottom : 3mm;
}
.qp-subject-title {
    font-size   : 11pt;
    font-weight : 700;
    margin-bottom: 1mm;
}
.qp-subject-dates {
    display   : flex;
    gap       : 8mm;
    font-size : 8pt;
    color     : #555;
}

/* 続きページのコンパクトヘッダー */
.qp-cont-header {
    display         : flex;
    justify-content : space-between;
    align-items     : flex-end;
    border-bottom   : 1px solid #d1d5db;
    padding-bottom  : 2mm;
    margin-bottom   : 3mm;
    font-size       : 8pt;
    color           : #555;
}
.qp-cont-title { font-size: 9pt; font-weight: 700; color: #111; }

/* ── 明細テーブル ────────────────────────────────────── */
.qp-body {
    flex       : 1;
    display    : flex;
    flex-direction: column;
}

.qp-items {
    width           : 100%;
    border-collapse : collapse;
    font-size       : 8.5pt;
    table-layout    : fixed;
}

.qp-items colgroup col.col-no     { width: 8mm;  }
.qp-items colgroup col.col-name   { width: auto; }
.qp-items colgroup col.col-desc   { width: 38mm; }
.qp-items colgroup col.col-qty    { width: 14mm; }
.qp-items colgroup col.col-unit   { width: 10mm; }
.qp-items colgroup col.col-price  { width: 22mm; }
.qp-items colgroup col.col-amount { width: 22mm; }

.qp-items thead tr th {
    background    : #1e3a5f;
    color         : #fff;
    font-size     : 8pt;
    font-weight   : 700;
    padding       : 1.5mm 2mm;
    text-align    : center;
    border        : 1px solid #1e3a5f;
    white-space   : nowrap;
}
.qp-items thead tr th.right { text-align: right; }

.qp-items tbody tr td {
    border   : 1px solid #d1d5db;
    padding  : 1.5mm 2mm;
    height   : 7mm;
    overflow : hidden;
    vertical-align: middle;
}
.qp-items tbody tr:nth-child(even) td { background: #f9fafb; }
.qp-items tbody tr.qp-row-empty td    { background: #fff; color: transparent; }

.qp-items td.right   { text-align: right; }
.qp-items td.center  { text-align: center; }
.qp-items td.bold    { font-weight: 700; }
.qp-items td.col-name-cell {
    overflow      : hidden;
    text-overflow : ellipsis;
    white-space   : nowrap;
    font-weight   : 500;
}
.qp-items td.col-desc-cell {
    font-size  : 7.5pt;
    color      : #555;
    overflow   : hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── フッター ────────────────────────────────────────── */
.qp-footer {
    margin-top : 3mm;
    flex-shrink: 0;
}

.qp-footer-inner {
    display               : grid;
    grid-template-columns : 1fr auto;
    gap                   : 4mm;
    align-items           : end;
}

/* 備考欄 */
.qp-notes-block {
    border     : 1px solid #d1d5db;
    border-radius: 1mm;
    padding    : 2mm 3mm;
    font-size  : 8pt;
    color      : #333;
    min-height : 18mm;
}
.qp-notes-label {
    font-size   : 7.5pt;
    font-weight : 700;
    color       : #555;
    margin-bottom: 1mm;
}

/* 金額サマリー */
.qp-summary-table {
    border-collapse : collapse;
    font-size       : 8.5pt;
    min-width       : 55mm;
}
.qp-summary-table tr td {
    border   : 1px solid #d1d5db;
    padding  : 1.5mm 2.5mm;
}
.qp-summary-table tr td:first-child {
    background  : #f3f4f6;
    font-weight : 600;
    white-space : nowrap;
}
.qp-summary-table tr td:last-child { text-align: right; }
.qp-summary-table tr.qp-total td {
    background  : #1e3a5f;
    color       : #fff;
    font-weight : 700;
    font-size   : 9.5pt;
}

/* ページ番号 */
.qp-page-num {
    text-align  : right;
    font-size   : 7.5pt;
    color       : #999;
    margin-top  : 2mm;
}

/* ── 印刷時（@media print） ──────────────────────────── */
@media print {
    body > *:not(#qp-print-root) { display: none !important; }

    #qp-print-root {
        display : block !important;
        position: fixed;
        inset   : 0;
        z-index : 99999;
    }

    @page {
        size   : A4 portrait;
        margin : 0;  /* padding は .qp-page 側で管理 */
    }

    .qp-page {
        transform    : none !important;
        box-shadow   : none !important;
        page-break-after: always;
        break-after  : page;
        width        : 210mm;
        height       : 297mm;
    }
    .qp-page:last-child {
        page-break-after: avoid;
        break-after  : avoid;
    }

    /* プレビューUI要素は非表示 */
    .qp-preview-toolbar, .modal-header, .modal-footer { display: none !important; }
}

/* ── 会社ロゴ ────────────────────────────────────────── */
.qp-logo-wrap {
    text-align    : right;
    margin-bottom : 2mm;
}
.qp-logo-img {
    max-height  : 14mm;
    max-width   : 45mm;
    object-fit  : contain;
    display     : inline-block;
}

/* ── 押印欄 ──────────────────────────────────────────── */
.qp-stamp-row {
    display         : flex;
    justify-content : flex-end;   /* 右寄せ */
    gap             : 0;
    margin-bottom   : 2mm;
}

.qp-stamp-cell {
    display        : flex;
    flex-direction : column;
    align-items    : center;
    width          : 18mm;
    border         : 1px solid #aaa;
    border-right   : none;
}
.qp-stamp-cell:last-child { border-right: 1px solid #aaa; }

.qp-stamp-role {
    font-size     : 7.5pt;
    font-weight   : 700;
    text-align    : center;
    padding       : 1mm 0;
    width         : 100%;
    border-bottom : 1px solid #aaa;
    background    : #f3f4f6;
}

.qp-stamp-circle {
    width         : 13mm;
    height        : 13mm;
    border        : 1px solid #ccc;
    border-radius : 50%;
    margin        : 1.5mm auto;
    /* 実際の押印スペース */
}
