/**
 * 請求書固有スタイル
 * invoice-preview.css
 */

/* ===== 請求書専用カラーテーマ ===== */
:root {
    --invoice-primary: #dc3545;
    --invoice-secondary: #c82333;
    --invoice-accent: #fd7e14;
    --invoice-light: #f8d7da;
    --invoice-dark: #721c24;
    --invoice-success: #28a745;
}

/* ===== 請求書モーダルのカスタマイズ ===== */
.invoice-modal.invoice-type .invoice-modal-header {
    background: linear-gradient(135deg, var(--invoice-primary) 0%, var(--invoice-secondary) 100%);
}

.invoice-modal.invoice-type .invoice-tab-btn.active {
    background: linear-gradient(135deg, var(--invoice-primary) 0%, var(--invoice-secondary) 100%);
}

.invoice-modal.invoice-type .invoice-tab-btn.active::after {
    background: linear-gradient(135deg, var(--invoice-primary) 0%, var(--invoice-secondary) 100%);
}

.invoice-modal.invoice-type .invoice-tab-content h3 {
    border-left-color: var(--invoice-primary);
}

/* ===== 請求書専用アイコンとラベル ===== */
.invoice-type #invoiceModalTitle::before {
    content: '📄 ';
}

.invoice-type .btn-primary {
    background: linear-gradient(135deg, var(--invoice-primary) 0%, var(--invoice-secondary) 100%);
}

.invoice-type .form-group input:focus,
.invoice-type .form-group select:focus,
.invoice-type .form-group textarea:focus {
    border-color: var(--invoice-primary);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* ===== 支払期限表示の強調 ===== */
.payment-due-display {
    background: var(--invoice-light);
    border: 2px solid var(--invoice-primary);
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    margin: 12px 0;
    position: relative;
}

.payment-due-display.urgent {
    animation: urgentPulse 2s ease-in-out infinite;
}

.payment-due-label {
    font-size: 12px;
    color: var(--invoice-dark);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.payment-due-date {
    font-size: 18px;
    font-weight: 700;
    color: var(--invoice-primary);
    margin-top: 4px;
}

.payment-due-countdown {
    font-size: 11px;
    color: var(--invoice-accent);
    margin-top: 4px;
    font-weight: 600;
}

@keyframes urgentPulse {
    0% { 
        border-color: var(--invoice-primary);
        background: var(--invoice-light);
    }
    50% { 
        border-color: var(--invoice-accent);
        background: #fff5f5;
    }
    100% { 
        border-color: var(--invoice-primary);
        background: var(--invoice-light);
    }
}

/* ===== 請求書明細テーブル ===== */
.invoice-type .invoice-item-header {
    background: linear-gradient(135deg, var(--invoice-primary) 0%, var(--invoice-secondary) 100%);
}

.invoice-type .add-item-btn {
    background: linear-gradient(135deg, var(--invoice-primary) 0%, var(--invoice-accent) 100%);
}

.invoice-type .add-item-btn:hover {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* ===== 請求金額計算の強調表示 ===== */
.invoice-type .invoice-calculation {
    background: linear-gradient(135deg, var(--invoice-light) 0%, #fee6e6 100%);
    border: 2px solid rgba(220, 53, 69, 0.3);
}

.invoice-type .calculation-row.total {
    border-top-color: var(--invoice-primary);
    color: var(--invoice-primary);
}

.invoice-type .calc-value {
    color: var(--invoice-primary);
}

/* ===== 銀行振込情報表示 ===== */
.bank-info-section {
    background: linear-gradient(135deg, #e3f2fd 0%, #f5f9ff 100%);
    border: 2px solid #2196f3;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.bank-info-section h4 {
    color: #1a1a1a;  /* Soft Black - 統合デザインルール */
    margin: 0 0 16px 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bank-info-section h4::before {
    content: '🏦';
}

.bank-details-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-family: 'MS Gothic', 'Courier New', monospace;
}

.bank-label {
    font-weight: 600;
    color: #1a1a1a;  /* Soft Black - 統合デザインルール */
}

.bank-value {
    color: #333;
}

/* ===== 請求書ステータスバッジ ===== */
.invoice-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-status.draft {
    background: #e9ecef;
    color: #6c757d;
}

.invoice-status.draft::before {
    content: '📝';
}

.invoice-status.sent {
    background: var(--invoice-light);
    color: var(--invoice-primary);
}

.invoice-status.sent::before {
    content: '📤';
}

.invoice-status.paid {
    background: #d4edda;
    color: #155724;
}

.invoice-status.paid::before {
    content: '💰';
}

.invoice-status.overdue {
    background: #f8d7da;
    color: #721c24;
    animation: overdueBlink 3s ease-in-out infinite;
}

.invoice-status.overdue::before {
    content: '⚠️';
}

@keyframes overdueBlink {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.6; }
}

/* ===== 入金管理パネル ===== */
.payment-management-panel {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #0ea5e9;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.payment-management-panel h4 {
    color: #0284c7;
    margin: 0 0 16px 0;
    font-weight: 600;
}

.payment-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.payment-item {
    background: white;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid rgba(14, 165, 233, 0.2);
}

.payment-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
}

.payment-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--invoice-primary);
    font-family: 'Courier New', monospace;
}

.payment-date {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.payment-status-display {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.payment-status-display.unpaid {
    background: #fef2f2;
    color: #dc2626;
}

.payment-status-display.paid {
    background: #f0fdf4;
    color: #16a34a;
}

.payment-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===== プレビューモーダルスタイル ===== */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    padding: 20px;
}

.preview-modal-content {
    background: white;
    border-radius: 12px;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

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

.preview-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

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

.preview-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.preview-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 24px;
}

.preview-container,
.invoice-preview-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    background: #f8fafc;
    border-radius: 8px;
    padding: 20px;
}

.document-preview {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    max-width: 210mm; /* A4幅 */
    min-height: 297mm; /* A4高 */
    transform-origin: top center;
    transition: transform 0.2s;
}

.document-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #64748b;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== プレビューコントロール ===== */
.preview-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 16px 0;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.control-group select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
}

/* ===== プレビューフッター ===== */
.preview-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
    flex-wrap: wrap;
    gap: 16px;
}

.document-info {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 14px;
    color: #1f2937;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.footer-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.payment-status input[type="checkbox"] {
    margin-right: 6px;
}

.payment-date {
    margin-left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.payment-date input[type="date"] {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
}

/* ===== レスポンシブデザイン ===== */
@media (max-width: 1024px) {
    .preview-modal-content {
        width: 98%;
        height: 95vh;
    }
    
    .document-preview {
        max-width: 90%;
    }
}

@media (max-width: 768px) {
    .preview-modal {
        padding: 10px;
    }
    
    .preview-modal-content {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    .preview-modal-header,
    .preview-modal-body,
    .preview-modal-footer {
        padding: 16px;
    }
    
    .preview-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .preview-actions .btn {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .document-info {
        flex-direction: column;
        gap: 12px;
    }
    
    .info-item {
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }
    
    .footer-actions {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .footer-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .payment-management-panel {
        padding: 16px;
    }
    
    .payment-info {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .bank-details-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .preview-modal-header h2 {
        font-size: 1.2rem;
    }
    
    .preview-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .payment-amount {
        font-size: 16px;
    }
    
    .payment-due-date {
        font-size: 16px;
    }
}