/* ========================================
   印刷用スタイル
   ======================================== */

@media print {
    /* ページ設定 */
    @page {
        margin: 5mm;
    }

    /* A4サイズ用 */
    @page a4 {
        size: A4 landscape;
        margin: 5mm;
    }

    /* A3サイズ用 */
    @page a3 {
        size: A3 landscape;
        margin: 10mm;
    }

    /* 印刷時に非表示にする要素 */
    .no-print,
    .header,
    .color-toolbar,
    .btn-add-task,
    .task-delete-btn,
    .modal,
    .loading {
        display: none !important;
    }

    /* ページ全体 */
    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    .app-container {
        width: 100%;
        max-width: none;
    }

    /* 印刷エリア */
    .print-area {
        width: 297mm !important;
        height: 210mm !important;
        margin: 0 auto;
        box-shadow: none;
    }

    /* 案件名エリア */
    .project-title-area {
        background: white;
        padding: 0.5rem 2px;
        border-bottom: 2px solid #000;
        page-break-after: avoid;
        display: flex;
        gap: 0.1rem;
        align-items: center;
    }

    .project-title-area {
        display: flex !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        gap: 0.1rem !important;
    }

    .project-meta {
        display: flex !important;
        gap: 0.1rem !important;
        margin-left: 0.1rem !important;
    }

    .project-title-field {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .project-title-label {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-align: center;
    }

    .meta-field {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
    }

    .project-title-field-main {
        flex: 1 !important;
        margin-right: 0.1rem !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    .project-title-field-main label {
        text-align: center !important;
        width: 100% !important;
    }

    .project-title-field-main input {
        width: 813px !important;
        line-height: 1.2 !important;
        box-sizing: border-box !important;
        height: auto !important;
        border-bottom: 2px solid #000 !important;
        border-top: none !important;
        border-left: none !important;
        border-right: none !important;
        border-radius: 0 !important;
        padding: 0.25rem 2px 0.35rem 2px !important;
        text-align: center !important;
    }

    .meta-field input {
        width: 150px !important;
        padding: 0.3rem 0.5rem 0.5rem 0.5rem !important;
        border: 1px solid #ccc !important;
        border-radius: 4px !important;
        font-size: 0.875rem !important;
        line-height: 1.2 !important;
        box-sizing: border-box !important;
        height: auto !important;
    }

    #projectTitle {
        width: 100% !important;
        font-weight: 600 !important;
        font-size: 1.05rem !important;
        padding: 0.25rem 0.5rem 0.35rem 0.5rem !important;
        text-align: center !important;
    }

    /* ガントチャート */
    .gantt-workspace {
        flex: 1;
        padding: 0.5rem 0.5rem 0.375rem;
        page-break-inside: avoid;
        overflow: hidden;
    }

    .gantt-container {
        display: flex;
        border: 2px solid #000;
        page-break-inside: avoid;
        height: calc(48px + var(--row-count, 26) * var(--row-height, 22px) + 4px);
        overflow: hidden;
    }

    /* タスクリスト */
    .task-list {
        width: 230px;
        min-width: 230px;
        max-width: 230px;
        border-right: 2px solid #000;
        page-break-inside: avoid;
        flex-shrink: 0;
    }
    
    .task-list-header {
        display: flex !important;
    }

    .task-list-body {
        max-height: none;
        overflow: visible;
    }

    .task-row {
        height: var(--row-height, 22px) !important;
        display: flex !important;
        align-items: center !important;
        padding: 0 1rem !important;
    }

    .task-name-input {
        border: none !important;
        background: transparent !important;
        font-size: 0.85rem !important;
        padding: 0 0.25rem 0 1rem !important;
        transform-origin: left center !important;
        font-weight: 500 !important;
        line-height: 1.2 !important;
        height: auto !important;
        box-sizing: border-box !important;
    }

    /* チャートエリア */
    .chart-area {
        overflow: hidden;
        page-break-inside: avoid;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
    }

    .chart-timeline {
        overflow: hidden !important;
        background: var(--bg-secondary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .timeline-cell {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .chart-content {
        overflow: hidden;
        position: relative;
        height: calc(var(--row-count, 26) * var(--row-height, 22px));
    }
    
    .chart-grid,
    .chart-bars {
        position: absolute;
    }
    
    .project-meta {
        font-size: 0.75rem;
    }
    
    .meta-field input {
        border: none;
        background: transparent;
        font-size: 0.75rem;
    }

    /* 背景色を維持 */
    .grid-cell.saturday,
    .grid-cell.sunday,
    .grid-cell.today {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* タスクバーの色を維持 */
    .task-bar {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }

    /* ページ分割の制御 */
    .task-row,
    .task-bar {
        page-break-inside: avoid;
    }

    /* A4印刷用（すべてA4に最適化） */
    body.print-a4 {
        page: a4;
    }

    .gantt-container {
        font-size: 0.7rem;
        border: 2px solid #000;
    }

    .task-bar {
        font-size: 0.65rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1.2 !important;
        border-radius: 4px !important;
    }
    
    .task-bar-text {
        line-height: 1.2 !important;
    }

    /* 備考欄 */
    .notes-area {
        background: white;
        padding: 0.5rem;
        border-top: 2px solid #000;
        page-break-before: avoid;
        height: 80px;
        display: flex;
        flex-direction: row;
    }

    .notes-label {
        font-weight: 600;
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
        display: block;
    }

    .notes-textarea {
        flex: 1;
        border: 1px solid #ccc;
        background: transparent;
        width: 100%;
        padding: 0.5rem !important;
        font-size: 0.65rem !important;
        resize: none;
        line-height: 1.3 !important;
        box-sizing: border-box !important;
        height: auto !important;
    }
}
