/**
 * 帳票共通スタイル（見積書・請求書）
 * invoice.css
 */

/* ===== モーダル基本スタイル ===== */
.invoice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 10000;
    overflow-y: auto;
    padding: 20px 0;
}

.invoice-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    margin: auto;
}

.invoice-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e6ed;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.invoice-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.invoice-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.invoice-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.invoice-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.invoice-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e0e6ed;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* ===== タブナビゲーション ===== */
.invoice-tab-nav {
    display: flex;
    border-bottom: 2px solid #e0e6ed;
    margin-bottom: 24px;
    gap: 4px;
}

.invoice-tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s;
    position: relative;
}

.invoice-tab-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.invoice-tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.invoice-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ===== タブコンテンツ ===== */
.invoice-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.invoice-tab-content.active {
    display: block;
}

.invoice-tab-content h3 {
    margin: 0 0 20px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
    border-left: 4px solid #667eea;
    padding-left: 12px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== フォーム要素 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #495057;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group.half {
    flex: 1;
}

.form-group.third {
    flex: 1;
}

.form-help {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

/* ===== 明細管理テーブル ===== */
.invoice-items-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.invoice-item-header {
    display: grid;
    grid-template-columns: 2fr 0.8fr 0.8fr 1.2fr 1.2fr 0.6fr;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 12px;
}

.invoice-item-row {
    display: grid;
    grid-template-columns: 2fr 0.8fr 0.8fr 1.2fr 1.2fr 0.6fr;
    gap: 12px;
    padding: 16px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e6ed;
    margin-bottom: 8px;
    transition: box-shadow 0.2s;
}

.invoice-item-row:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.item-col-desc {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-description {
    font-weight: 500;
}

.item-details textarea {
    font-size: 12px;
    min-height: 60px;
}

.item-unit,
.item-quantity,
.item-unit-price {
    height: 38px;
}

.item-amount {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #495057;
}

.item-col-action {
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-item-btn {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.add-item-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* ===== 金額計算表示 ===== */
.invoice-calculation {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.calculation-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #dee2e6;
}

.calculation-row:last-child {
    border-bottom: none;
}

.calculation-row.total {
    font-size: 1.1rem;
    font-weight: 700;
    color: #495057;
    border-top: 2px solid #667eea;
    padding-top: 12px;
    margin-top: 8px;
}

.calc-label {
    font-weight: 500;
    color: #6c757d;
}

.calc-value {
    font-weight: 600;
    color: #495057;
    font-family: 'Courier New', monospace;
}

/* ===== 事業者情報スタイル ===== */
.issuer-info-content {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.issuer-form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.issuer-form-section h4 {
    margin: 0 0 16px 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

.issuer-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.preset-list {
    background: white;
    border-radius: 6px;
    padding: 16px;
    border: 1px solid #e0e6ed;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.preset-item:last-child {
    border-bottom: none;
}

.preset-info h6 {
    margin: 0 0 4px 0;
    color: #495057;
}

.preset-info p {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
}

.preset-actions {
    display: flex;
    gap: 8px;
}

/* ===== プレビュー表示 ===== */
.issuer-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.preview-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e0e6ed;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.preview-card h5 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.issuer-display-preview {
    font-family: 'MS Gothic', monospace;
    line-height: 1.6;
    font-size: 13px;
}

.issuer-name-preview {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
}

.issuer-address-preview {
    margin-bottom: 8px;
}

.issuer-reg-preview {
    font-size: 11px;
    color: #6c757d;
}

.bank-display-preview {
    font-family: 'MS Gothic', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.bank-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.bank-details {
    margin-bottom: 8px;
}

.bank-notes-preview {
    font-size: 11px;
    color: #6c757d;
    border-top: 1px solid #eee;
    padding-top: 8px;
    margin-top: 8px;
}

/* ===== アクションボタン ===== */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    align-items: center;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #212529;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== レスポンシブデザイン ===== */
@media (max-width: 768px) {
    .invoice-modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 95vh;
    }
    
    .invoice-tab-nav {
        flex-wrap: wrap;
    }
    
    .invoice-tab-btn {
        font-size: 12px;
        padding: 10px 16px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .invoice-item-header,
    .invoice-item-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .item-col-desc,
    .item-col-unit,
    .item-col-quantity,
    .item-col-price,
    .item-col-amount,
    .item-col-action {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
    }
    
    .item-col-desc::before,
    .item-col-unit::before,
    .item-col-quantity::before,
    .item-col-price::before,
    .item-col-amount::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        font-size: 12px;
    }
    
    .issuer-preview {
        grid-template-columns: 1fr;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .invoice-modal {
        padding: 10px 5px;
    }
    
    .invoice-modal-header,
    .invoice-modal-body,
    .invoice-modal-footer {
        padding: 16px;
    }
    
    .invoice-tab-btn {
        font-size: 11px;
        padding: 8px 12px;
    }
}