/**
 * 印刷用共通スタイル
 * invoice-print.css
 */

/* ===== 印刷専用スタイル ===== */
@media print {
    /* ===== 基本リセット ===== */
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    @page {
        size: A4;
        margin: 20mm 15mm;
        padding: 0;
    }
    
    body {
        font-family: 'MS Gothic', 'MS Mincho', '游明朝', 'YuMincho', serif;
        font-size: 12pt;
        line-height: 1.4;
        color: black !important;
        background: white !important;
    }
    
    /* ===== 不要要素の非表示 ===== */
    .invoice-modal-header,
    .invoice-modal-footer,
    .preview-modal-header,
    .preview-modal-footer,
    .preview-controls,
    .modal-actions,
    .preview-actions,
    .invoice-tab-nav,
    .btn,
    button,
    .payment-management-panel,
    .loading-spinner,
    .document-loading,
    nav,
    header,
    footer,
    .no-print {
        display: none !important;
    }
    
    /* ===== モーダルの印刷調整 ===== */
    .invoice-modal,
    .preview-modal {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .invoice-modal-content,
    .preview-modal-content {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .invoice-modal-body,
    .preview-modal-body {
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* ===== 帳票ドキュメントエリア ===== */
    .document-preview,
    .invoice-preview-container,
    .estimate-preview-container {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        transform: none !important;
        overflow: visible !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* ===== 帳票ヘッダー ===== */
    .invoice-document-header {
        text-align: center;
        margin-bottom: 30pt;
        border-bottom: 2pt solid black;
        padding-bottom: 15pt;
    }
    
    .document-title {
        font-size: 24pt;
        font-weight: bold;
        margin-bottom: 10pt;
    }
    
    .document-number {
        font-size: 14pt;
        font-weight: bold;
        font-family: 'Courier New', monospace;
    }
    
    .document-date {
        font-size: 12pt;
        margin-top: 5pt;
    }
    
    /* ===== 宛先情報 ===== */
    .invoice-client-info {
        margin-bottom: 25pt;
        padding: 10pt;
        border: 1pt solid black;
        background: #f8f9fa !important;
    }
    
    .client-name {
        font-size: 16pt;
        font-weight: bold;
        margin-bottom: 5pt;
    }
    
    .client-department,
    .client-person {
        font-size: 12pt;
        margin-bottom: 3pt;
    }
    
    /* ===== 発行者情報 ===== */
    .invoice-issuer-info {
        position: absolute;
        top: 0;
        right: 0;
        width: 40%;
        text-align: right;
        border: 1pt solid black;
        padding: 10pt;
        background: #f0f9ff !important;
    }
    
    .issuer-name {
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 5pt;
    }
    
    .issuer-address {
        font-size: 10pt;
        line-height: 1.3;
        margin-bottom: 5pt;
    }
    
    .issuer-reg-number {
        font-size: 9pt;
        color: #666 !important;
    }
    
    /* ===== 案件情報 ===== */
    .invoice-project-info {
        margin: 25pt 0;
        padding: 10pt;
        border: 1pt solid black;
        background: #fffbf0 !important;
    }
    
    .project-title {
        font-size: 14pt;
        font-weight: bold;
        text-align: center;
    }
    
    /* ===== 明細テーブル ===== */
    .invoice-items-table {
        width: 100%;
        border-collapse: collapse;
        margin: 20pt 0;
        font-size: 11pt;
    }
    
    .invoice-items-table th,
    .invoice-items-table td {
        border: 1pt solid black;
        padding: 8pt 6pt;
        text-align: left;
        vertical-align: top;
    }
    
    .invoice-items-table th {
        background: #e9ecef !important;
        font-weight: bold;
        text-align: center;
    }
    
    .item-description {
        width: 35%;
    }
    
    .item-detail {
        font-size: 9pt;
        color: #666 !important;
        margin-top: 3pt;
    }
    
    .item-unit {
        width: 10%;
        text-align: center;
    }
    
    .item-quantity,
    .item-unit-price,
    .item-amount {
        width: 15%;
        text-align: right;
        font-family: 'Courier New', monospace;
    }
    
    /* ===== 金額計算エリア ===== */
    .invoice-calculation-table {
        width: 50%;
        margin-left: auto;
        margin-top: 20pt;
        border-collapse: collapse;
        font-size: 12pt;
    }
    
    .invoice-calculation-table td {
        border: 1pt solid black;
        padding: 8pt 12pt;
    }
    
    .calc-label-cell {
        background: #f8f9fa !important;
        font-weight: bold;
        text-align: left;
        width: 60%;
    }
    
    .calc-value-cell {
        text-align: right;
        font-family: 'Courier New', monospace;
        font-weight: bold;
        width: 40%;
    }
    
    .calc-total-row .calc-label-cell,
    .calc-total-row .calc-value-cell {
        background: #e3f2fd !important;
        font-size: 14pt;
        font-weight: bold;
        border-width: 2pt;
    }
    
    /* ===== 備考欄 ===== */
    .invoice-notes {
        margin-top: 25pt;
        padding: 10pt;
        border: 1pt solid black;
        background: #f8f9fa !important;
    }
    
    .notes-title {
        font-size: 12pt;
        font-weight: bold;
        margin-bottom: 8pt;
        border-bottom: 1pt solid #ccc;
        padding-bottom: 3pt;
    }
    
    .notes-content {
        font-size: 10pt;
        line-height: 1.5;
    }
    
    /* ===== 銀行情報（請求書用） ===== */
    .invoice-bank-info {
        margin-top: 20pt;
        padding: 10pt;
        border: 2pt solid #0066cc;
        background: #f0f8ff !important;
        page-break-inside: avoid;
    }
    
    .bank-info-title {
        font-size: 14pt;
        font-weight: bold;
        text-align: center;
        margin-bottom: 10pt;
        color: #0066cc !important;
    }
    
    .bank-details {
        font-size: 12pt;
        line-height: 1.6;
        font-family: 'MS Gothic', monospace;
    }
    
    .bank-name {
        font-weight: bold;
        font-size: 13pt;
    }
    
    .account-info {
        margin: 5pt 0;
        padding-left: 15pt;
    }
    
    /* ===== 日付・期限情報 ===== */
    .invoice-dates {
        display: flex;
        justify-content: space-between;
        margin: 20pt 0;
        font-size: 11pt;
    }
    
    .date-item {
        text-align: center;
        padding: 8pt;
        border: 1pt solid black;
        flex: 1;
        margin: 0 5pt;
    }
    
    .date-label {
        font-size: 9pt;
        color: #666 !important;
        margin-bottom: 3pt;
    }
    
    .date-value {
        font-size: 12pt;
        font-weight: bold;
        font-family: 'Courier New', monospace;
    }
    
    .estimate-valid-until {
        background: #e1f5fe !important;
        color: #01579b !important;
    }
    
    .invoice-payment-due {
        background: #ffebee !important;
        color: #b71c1c !important;
    }
    
    /* ===== ページ制御 ===== */
    .page-break-before {
        page-break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
    }
    
    .page-break-inside-avoid {
        page-break-inside: avoid;
    }
    
    .invoice-calculation-table,
    .invoice-bank-info,
    .invoice-notes {
        page-break-inside: avoid;
    }
    
    /* ===== フッター情報 ===== */
    .print-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 8pt;
        color: #666 !important;
        border-top: 0.5pt solid #ccc;
        padding-top: 5pt;
    }
    
    /* ===== 見積書専用スタイル ===== */
    .estimate-document .document-title::after {
        content: " （見積書）";
        color: #01579b !important;
    }
    
    .estimate-document .calc-total-row {
        background: #e1f5fe !important;
        color: #01579b !important;
    }
    
    /* ===== 請求書専用スタイル ===== */
    .invoice-document .document-title::after {
        content: " （請求書）";
        color: #b71c1c !important;
    }
    
    .invoice-document .calc-total-row {
        background: #ffebee !important;
        color: #b71c1c !important;
    }
    
    /* ===== 小さな画面での調整 ===== */
    @media print and (max-width: 8.5in) {
        .invoice-issuer-info {
            position: static;
            width: 100%;
            text-align: left;
            margin-bottom: 20pt;
        }
        
        .invoice-dates {
            flex-direction: column;
        }
        
        .date-item {
            margin: 5pt 0;
        }
        
        .invoice-calculation-table {
            width: 100%;
        }
    }
}

/* ===== 画面表示時の印刷プレビュー調整 ===== */
.print-preview-mode {
    background: white;
    color: black;
    font-family: 'MS Gothic', 'MS Mincho', '游明朝', 'YuMincho', serif;
    font-size: 12pt;
    line-height: 1.4;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 20mm 15mm;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.print-preview-mode .no-print {
    display: none;
}

/* ===== カラープリンター用の色指定 ===== */
@media print and (color) {
    .estimate-document .document-title {
        color: #01579b !important;
    }
    
    .invoice-document .document-title {
        color: #b71c1c !important;
    }
    
    .bank-info-title {
        color: #1a1a1a !important;  /* Soft Black - 統合デザインルール */
    }
}

/* ===== モノクロプリンター用の調整 ===== */
@media print and (monochrome) {
    .invoice-client-info,
    .invoice-issuer-info,
    .invoice-project-info,
    .invoice-notes,
    .invoice-bank-info,
    .calc-total-row,
    .estimate-valid-until,
    .invoice-payment-due {
        background: white !important;
        border-width: 2pt !important;
    }
    
    .item-detail,
    .issuer-reg-number,
    .date-label {
        color: black !important;
    }
}