/* ===========================================
   QRouton見積書エディター - 2カラムレイアウト
=========================================== */

/* リセット・基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Helvetica Neue', 'Arial', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic Medium', 'Meiryo', sans-serif;
    background: #f8f9fa;
    color: #333;
    line-height: 1.6;
    -webkit-font-feature-settings: "palt";
    font-feature-settings: "palt";
}

/* ===========================================
   メインヘッダー
=========================================== */
.main-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.header-btn .material-icons {
    font-size: 16px;
    line-height: 1;
}

.header-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.header-btn.primary {
    background: #28a745;
    font-weight: 600;
}

.header-btn.primary:hover {
    background: #218838;
}

.header-btn.secondary {
    background: #6c757d;
    color: white;
    font-weight: 500;
}

.header-btn.secondary:hover {
    background: #5a6268;
}

/* ===========================================
   メインコンテナ（2カラムレイアウト）
=========================================== */
.main-container {
    display: flex;
    min-height: calc(100vh - 80px);
    gap: 0;
}

/* ===========================================
   左カラム：入力パネル
=========================================== */
.input-panel {
    width: 400px;
    background: white;
    border-right: 1px solid #e0e6ed;
    overflow-y: auto;
    height: calc(100vh - 80px);
    position: sticky;
    top: 80px;
}

.input-section {
    padding: 1.5rem;
}

/* フォームセクション */
.form-section {
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.form-section h2 {
    color: #495057;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 固定項目スタイル */
.fixed-item-row {
    padding: 1rem;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-bottom: 1rem;
}

.item-header {
    margin-bottom: 0.75rem;
}

.item-number {
    font-weight: 600;
    color: #667eea;
    font-size: 0.9rem;
}

.item-fields {
    display: grid;
    gap: 0.75rem;
}

.item-fields .form-input {
    padding: 0.6rem;
    font-size: 0.9rem;
}

/* セレクトボックス */
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.2s ease;
}

.form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* readonly フィールド */
.form-input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}



/* ラジオボタングループ */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    transition: all 0.2s ease;
    background: white;
}

.radio-label:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.radio-label input[type="radio"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
    cursor: pointer;
}

.radio-button {
    margin-left: 0.25rem;
}

/* ラジオボタン選択済み状態 */
.radio-label:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #e7f3ff;
    color: #0056b3;
}



/* 未入力フィールド強調表示 */
.field-required {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    border-radius: 4px !important;
    animation: gentle-pulse 2s ease-in-out infinite;
    position: relative;
}

.field-required::before {
    content: "⚠️";
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    animation: attention-icon 2s ease-in-out infinite;
}

@keyframes gentle-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.3); 
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(255, 193, 7, 0.1); 
    }
}

@keyframes attention-icon {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ===========================================
   右カラム：プレビューパネル
=========================================== */
.preview-panel {
    flex: 1;
    background: #f0f2f5;
    overflow-y: auto;
    padding: 1.5rem;
}



/* ===========================================
   プレビュー書類（A4サイズ）
=========================================== */
.paper-container {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.paper {
    width: 210mm;
    min-height: 297mm;
    background: white;
    padding: 20mm;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    position: relative;
}

/* 文書ヘッダー */
.document-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e6ed;
}

.document-title-section {
    flex: 1;
}

.document-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin: 0;
    letter-spacing: 2px;
    text-align: left;
}

.document-date-section {
    text-align: right;
    min-width: 200px;
}

/* 宛先・自社情報レイアウト */
.client-company-section {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.client-column {
    flex: 3;
}

.company-column {
    flex: 1;
}

.company-info-right {
    text-align: right;
    line-height: 1.4;
}

.company-name {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.5rem;
}

.company-address-line1, .company-address-line2, .company-address-line3 {
    font-size: 11px;
    color: #666;
    margin-bottom: 0.25rem;
}

.company-contact-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 11px;
    color: #666;
    margin-bottom: 0.25rem;
    gap: 0.3rem;
}

.contact-icon {
    font-size: 14px !important;
    color: #888;
}





.date-row {
    margin-bottom: 0.25rem;
    font-size: 11px;
}

.document-date-section .date-row label {
    display: inline-block;
    width: 70px;
    color: #666;
    text-align: left;
}

.date-display {
    color: #333;
    font-weight: 500;
}

/* 顧客情報セクション */
.client-section {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.client-name {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    margin-bottom: 0.25rem;
}

.client-department {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    margin-bottom: 0.5rem;
}

.client-person {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

/* プロジェクト情報セクション */
.project-section {
    margin-bottom: 2rem;
}

.project-label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.project-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    padding: 0.75rem;
    background: #e7f3ff;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

/* 見積項目テーブル */
.items-section {
    margin-bottom: 2rem;
}

.table-container {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.estimate-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.estimate-table thead {
    background: #f8f9fa;
}

.estimate-table th {
    padding: 0.75rem 0.5rem;
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    text-align: center;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}

.estimate-table th:last-child {
    border-right: none;
}

.estimate-table th.col-name {
    text-align: left;
    width: 50%;
}

.estimate-table th.col-price {
    width: 20%;
    text-align: center;
}

.estimate-table th.col-quantity {
    width: 15%;
    text-align: center;
}

.estimate-table th.col-total {
    width: 20%;
    text-align: center;
}

.estimate-table tbody {
    background: white;
}

.estimate-table tr {
    transition: background-color 0.2s ease;
}

.estimate-table tbody tr:hover {
    background: #f8f9fa;
}

.estimate-table td {
    padding: 0.75rem 0.5rem;
    font-size: 11px;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
    min-height: 40px;
}

.estimate-table td:last-child {
    border-right: none;
}

.estimate-table tbody tr:last-child td {
    border-bottom: none;
}



.estimate-table .item-name-display {
    text-align: left !important;
    font-weight: 500;
}

.estimate-table td:nth-child(1) {
    text-align: left;
}

.estimate-table td:nth-child(2) {
    text-align: right;
}

.estimate-table td:nth-child(3) {
    text-align: center;
}

.estimate-table td:nth-child(4) {
    text-align: right;
}

.estimate-table .item-total {
    font-weight: 600;
    color: #28a745;
}

/* 合計セクション */
.summary-section {
    margin-bottom: 2rem;
    display: flex;
    justify-content: flex-end;
}

.summary-table {
    width: 300px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    font-size: 12px;
    border-bottom: 1px solid #dee2e6;
    background: white;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.total-row {
    background: #f8f9fa;
    font-weight: 700;
    font-size: 14px;
    color: #333;
}

/* 備考セクション */
.notes-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.notes-header {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin-bottom: 1rem;
    text-align: center;
}

.notes-block {
    margin-bottom: 1.5rem;
}

.notes-block:last-child {
    margin-bottom: 0;
}

.notes-block-title {
    font-size: 12px;
    font-weight: 700;
    color: #495057;
    margin-bottom: 0.5rem;
}

.notes-list {
    margin: 0;
    padding-left: 1rem;
    list-style-type: disc;
}

.notes-list li {
    font-size: 10px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.notes-list li:last-child {
    margin-bottom: 0;
}

/* 文書フッター */
.document-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e6ed;
    text-align: left;
}

.document-footer p {
    font-size: 10px;
    color: #666;
    margin: 0;
}

/* ===========================================
   レスポンシブデザイン
=========================================== */
@media (max-width: 1200px) {
    .input-panel {
        width: 350px;
    }
    
    .paper {
        width: 180mm;
        padding: 15mm;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .input-panel {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
    }
    
    .preview-panel {
        padding: 1rem;
    }
    
    .paper {
        width: 100%;
        max-width: 210mm;
        padding: 10mm;
    }
    
    .header-actions {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .header-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }
}

/* ===========================================
   印刷スタイル
=========================================== */
@media print {
    @page {
        size: A4;
        margin: 10mm 12mm; /* 上下10mm、左右12mmで横幅を確保 */
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    body {
        font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic Medium', 'Meiryo', 'MS Gothic', sans-serif !important;
        font-size: 11pt !important; /* 12pt → 11ptに縮小 */
        line-height: 1.3 !important; /* 1.4 → 1.3に縮小 */
        -webkit-font-feature-settings: "palt";
        font-feature-settings: "palt";
        background: white !important;
    }
    
    .main-header,
    .input-panel {
        display: none !important;
    }
    
    .main-container {
        display: block !important;
    }
    
    .preview-panel {
        padding: 0 !important;
        background: white !important;
    }
    
    .paper-container {
        padding: 0 !important;
    }
    
    .paper {
        width: 100% !important;
        min-height: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 12mm !important; /* 適切なパディングを追加 */
        margin: 0 !important;
    }
    
    /* テーブル印刷調整 */
    .estimate-table {
        width: 100% !important;
        font-size: 10pt !important; /* テーブル文字をさらに小さく */
    }
    
    .estimate-table th,
    .estimate-table td {
        padding: 0.4rem 0.3rem !important; /* パディングを縮小 */
        font-size: 10pt !important;
    }
    
    .summary-table {
        width: 250px !important; /* 合計テーブルの幅を縮小 */
        font-size: 10pt !important;
    }
    
    .summary-row {
        padding: 0.5rem 0.7rem !important; /* パディングを縮小 */
        font-size: 11pt !important;
    }
    
    .summary-row.total-row {
        font-size: 12pt !important;
    }
    
    /* 文書ヘッダーの調整 */
    .document-title {
        font-size: 20pt !important; /* 24px → 20ptに縮小 */
    }
    
    .company-name {
        font-size: 14pt !important; /* 16px → 14ptに縮小 */
    }
    
    /* 備考セクションの調整 */
    .notes-section {
        padding: 1rem !important; /* パディングを縮小 */
        margin-top: 1.5rem !important;
    }
    
    .notes-list li {
        font-size: 9pt !important; /* 10px → 9ptに縮小 */
        line-height: 1.4 !important;
    }
}

/* ===========================================
   フェードインアニメーション
=========================================== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
} 