/* Budget Tracker - スタイルシート */

:root {
    --primary-color: #3498db;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --bg-color: #f8f9fa;
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--dark-color);
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
    background: linear-gradient(135deg, var(--primary-color), #5dade2);
    color: white;
    border-radius: 10px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* サマリーセクション */
.summary-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.summary-card {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

.summary-card h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    opacity: 0.7;
}

.amount {
    font-size: 2rem;
    font-weight: bold;
}

.income-card .amount {
    color: var(--success-color);
}

.expense-card .amount {
    color: var(--danger-color);
}

.balance-card .amount {
    color: var(--primary-color);
}

.amount.positive {
    color: var(--success-color);
}

.amount.negative {
    color: var(--danger-color);
}

/* 入力セクション */
.input-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    margin-bottom: 40px;
}

.input-section h2 {
    margin-bottom: 20px;
    color: var(--dark-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark-color);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--light-color);
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ボタン */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--dark-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #34495e;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* チャートセクション */
.chart-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    margin-bottom: 40px;
}

.chart-section h2 {
    margin-bottom: 20px;
}

.chart-container {
    height: 300px;
    margin-bottom: 40px;
}

.category-breakdown {
    margin-top: 40px;
}

.category-breakdown h3 {
    margin-bottom: 20px;
}

.category-breakdown canvas {
    max-height: 300px;
}

/* 履歴セクション */
.history-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    margin-bottom: 40px;
}

.history-section h2 {
    margin-bottom: 20px;
}

.filter-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--light-color);
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-btn:hover {
    border-color: var(--primary-color);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.transaction-list {
    max-height: 400px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--light-color);
    transition: background-color 0.3s;
}

.transaction-item:hover {
    background-color: #f8f9fa;
}

.transaction-info h4 {
    margin-bottom: 5px;
    color: var(--dark-color);
}

.transaction-info p {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.transaction-amount {
    display: flex;
    align-items: center;
    gap: 15px;
}

.transaction-amount span {
    font-weight: bold;
    font-size: 1.1rem;
}

.transaction-amount .income {
    color: var(--success-color);
}

.transaction-amount .expense {
    color: var(--danger-color);
}

.delete-btn {
    padding: 5px 10px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

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

.no-transactions {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

/* エクスポートセクション */
.export-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.export-section h2 {
    margin-bottom: 20px;
}

.export-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .summary-section {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* iOSでのズーム防止 */
    }

    .transaction-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .transaction-amount {
        width: 100%;
        justify-content: space-between;
    }

    .export-buttons {
        flex-direction: column;
    }

    .export-buttons .btn {
        width: 100%;
    }
}

/* 印刷用スタイル */
@media print {
    body {
        background: white;
    }

    .filter-controls,
    .delete-btn,
    .export-section {
        display: none;
    }

    .container {
        max-width: 100%;
    }

    .summary-card,
    .input-section,
    .chart-section,
    .history-section {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* スクロールバーのカスタマイズ */
.transaction-list::-webkit-scrollbar {
    width: 8px;
}

.transaction-list::-webkit-scrollbar-track {
    background: var(--light-color);
    border-radius: 4px;
}

.transaction-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.transaction-list::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.summary-card,
.input-section,
.chart-section,
.history-section,
.export-section {
    animation: fadeIn 0.5s ease-out;
}