/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
header {
    background: white;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 28px;
}

header h1 i {
    color: #3498db;
    margin-right: 10px;
}

nav {
    display: flex;
    gap: 15px;
}

/* ボタンスタイル */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-preview {
    background: #e67e22;
    color: white;
}

.btn-preview:hover {
    background: #d35400;
}

.btn-add {
    background: #1abc9c;
    color: white;
    margin-top: 10px;
}

.btn-add:hover {
    background: #16a085;
}

.btn.active {
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* フォームセクション */
.form-section, .list-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.form-section h2, .list-section h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 24px;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 30px;
}

.form-group h3 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group h3 i {
    color: #3498db;
}

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

.form-field {
    flex: 1;
}

.form-field.full-width {
    flex: 1 1 100%;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.required {
    color: #e74c3c;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea {
    resize: vertical;
    font-family: inherit;
}

/* 請求明細テーブル */
.items-container {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.items-table th {
    background: #34495e;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 500;
}

.items-table td {
    padding: 10px;
    border-bottom: 1px solid #ecf0f1;
}

.items-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.items-table input:focus {
    outline: none;
    border-color: #3498db;
}

.delete-item-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.delete-item-btn:hover {
    background: #c0392b;
}

/* 金額計算セクション */
.calculation-section {
    background: #ecf0f1;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    margin-left: auto;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 16px;
}

.calc-row label {
    font-weight: 500;
}

.tax-row {
    border-top: 1px solid #bdc3c7;
    border-bottom: 1px solid #bdc3c7;
}

.tax-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tax-input input {
    width: 80px;
    padding: 6px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
}

.total-row {
    font-size: 20px;
    font-weight: bold;
    color: #27ae60;
}

#subtotalDisplay, #taxAmountDisplay, #totalDisplay {
    font-weight: bold;
}

/* アクションボタン */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* 一覧表示 */
.list-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    position: relative;
    min-width: 250px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c8d;
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
}

.filter-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-box select {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
}

.invoice-list-container {
    display: grid;
    gap: 15px;
}

.invoice-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    transition: all 0.3s;
    cursor: pointer;
}

.invoice-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.invoice-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.invoice-number {
    font-weight: bold;
    color: #2c3e50;
    font-size: 18px;
}

.invoice-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.status-draft {
    background: #95a5a6;
    color: white;
}

.status-sent {
    background: #3498db;
    color: white;
}

.status-paid {
    background: #27ae60;
    color: white;
}

.invoice-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    color: #555;
}

.invoice-info {
    display: flex;
    flex-direction: column;
}

.invoice-info-label {
    font-size: 12px;
    color: #7f8c8d;
}

.invoice-info-value {
    font-weight: 500;
    color: #2c3e50;
}

.invoice-amount {
    font-size: 24px;
    font-weight: bold;
    color: #27ae60;
}

.invoice-card-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.invoice-card-actions .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* プレビューセクション */
.preview-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.preview-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.invoice-preview-content {
    background: white;
    max-width: 210mm;
    margin: 0 auto;
    padding: 40px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* 印刷用請求書スタイル */
.invoice-document {
    font-size: 14px;
    line-height: 1.8;
}

.invoice-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #2c3e50;
}

.invoice-title {
    font-size: 32px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.invoice-metadata {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.issuer-info, .client-info-box {
    flex: 1;
}

.section-title {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 16px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.info-line {
    margin: 5px 0;
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
}

.invoice-items-table th {
    background: #34495e;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 500;
}

.invoice-items-table td {
    padding: 12px;
    border-bottom: 1px solid #ecf0f1;
}

.invoice-items-table .text-right {
    text-align: right;
}

.invoice-summary {
    max-width: 400px;
    margin-left: auto;
    margin-top: 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #ecf0f1;
}

.summary-row.total {
    background: #ecf0f1;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #2c3e50;
}

.invoice-notes {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.invoice-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #ecf0f1;
}

.bank-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

/* 印刷用スタイル */
@media print {
    body {
        background: white;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    header, .preview-actions {
        display: none !important;
    }
    
    .invoice-preview-content {
        box-shadow: none;
        padding: 0;
        max-width: 100%;
    }
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 20px;
    }
    
    nav {
        flex-direction: column;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .calculation-section {
        max-width: 100%;
    }
    
    .list-controls {
        flex-direction: column;
    }
    
    .invoice-metadata {
        flex-direction: column;
        gap: 20px;
    }
    
    .items-table {
        font-size: 12px;
    }
    
    .items-table th,
    .items-table td {
        padding: 8px 4px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* 空のリスト表示 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: #95a5a6;
}

/* ローディング表示 */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.loading i {
    font-size: 48px;
    animation: spin 1s linear infinite;
}

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