/* CSS Variables for theming */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --income-color: #10b981;
    --income-bg: #d1fae5;
    --expense-color: #ef4444;
    --expense-bg: #fee2e2;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.tagline {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Section Styles */
section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin-bottom: 0;
}

/* Balance Section */
.balance-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
}

.balance-card {
    text-align: center;
    margin-bottom: 1.5rem;
}

.balance-card h2 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.balance-amount {
    font-size: 2.5rem;
    font-weight: 700;
}

.summary-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.summary-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.summary-card h3 {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.summary-card .amount {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Monthly Summary */
.month-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.month-nav {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.month-nav:hover {
    background: var(--primary-hover);
}

#current-month {
    font-weight: 500;
    min-width: 130px;
    text-align: center;
}

.monthly-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-md);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.stat-value.income {
    color: var(--income-color);
}

.stat-value.expense {
    color: var(--expense-color);
}

.category-breakdown h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.category-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-name {
    flex: 0 0 120px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.category-progress {
    flex: 1;
    height: 24px;
    background: var(--background);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.category-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.category-amount {
    flex: 0 0 80px;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 500;
}

.empty-categories {
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem;
}

/* Transaction Form */
.transaction-form {
    display: grid;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-submit {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 0.5rem;
}

.btn-submit:hover {
    background: var(--primary-hover);
}

.btn-submit:active {
    transform: scale(0.98);
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 0.75rem;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Transaction List */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transaction-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-md);
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.transaction-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.transaction-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.transaction-item.income .transaction-icon {
    background: var(--income-bg);
}

.transaction-item.expense .transaction-icon {
    background: var(--expense-bg);
}

.transaction-details {
    flex: 1;
    min-width: 0;
}

.transaction-description {
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.transaction-amount {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
}

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

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

.transaction-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background-color 0.2s;
    font-size: 1.25rem;
}

.transaction-delete:hover {
    color: var(--expense-color);
    background: var(--expense-bg);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 640px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .main-content {
        padding: 1rem;
    }

    section {
        padding: 1.25rem;
        border-radius: var(--radius-md);
    }

    .balance-amount {
        font-size: 2rem;
    }

    .monthly-stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
    }

    .stat-label {
        margin-bottom: 0;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-controls {
        width: 100%;
    }

    .filter-select {
        flex: 1;
    }

    .category-name {
        flex: 0 0 90px;
        font-size: 0.8rem;
    }

    .category-amount {
        flex: 0 0 70px;
        font-size: 0.8rem;
    }

    .transaction-item {
        padding: 0.875rem;
    }

    .transaction-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .transaction-amount {
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .month-selector {
        width: 100%;
        justify-content: space-between;
    }

    .transaction-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

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

.transaction-item {
    animation: fadeIn 0.3s ease;
}

/* Notification Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
