/* =========================
   Reset & Base Styles
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =========================
   Tailwind-like Container Utility
   Responsive max-widths, centered, horizontal padding
========================= */
.container {
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    width: 100%;
    max-width: 100%;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding-top: 24px;
    padding-bottom: 24px;
    border-radius: 10px;
    transition: box-shadow 0.3s;
}

@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 800px;
    }
}

/* =========================
   Body Styles
========================= */
body {
    font-family: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f7fa;
    display: flex;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

/* =========================
   Header
========================= */
header h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 2rem;
    color: #222;
    letter-spacing: 1px;
    transition: color 0.2s;
}

/* =========================
   Section Spacing
========================= */
.input-section,
.filter-section,
.overview,
.entries {
    margin-bottom: 24px;
}

/* =========================
   Form Inputs & Actions
========================= */
.input-section label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.input-section input[type="text"],
.input-section input[type="number"],
.input-section select {
    width: 100%;
    padding: 10px;
    margin-bottom: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    background: #fafbfc;
}

.input-section input:focus,
.input-section select:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 0 2px #c8e6c9;
    transform: translateY(-2px) scale(1.01);
}

.input-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

button {
    font-family: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    padding: 10px 18px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    will-change: transform;
}

button#add-entry {
    background-color: #4CAF50;
    color: white;
}

button#add-entry:hover,
.actions button.edit-btn:hover {
    background-color: #388e3c;
    transform: translateY(-2px) scale(1.05);
}

button#reset-fields {
    background-color: #f44336;
    color: white;
}

button#reset-fields:hover {
    background-color: #b71c1c;
    transform: translateY(-2px) scale(1.05);
}

/* =========================
   Filter Section
========================= */
.filter-section fieldset {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px 16px;
    display: flex;
    gap: 18px;
    align-items: center;
    transition: border-color 0.2s;
}

.filter-section legend {
    font-weight: 600;
    color: #444;
}

.filter-section label {
    font-size: 1rem;
    cursor: pointer;
}

input[type="radio"] {
    margin-right: 5px;
    accent-color: #4CAF50;
    transition: accent-color 0.2s;
}

/* =========================
   Overview Section
========================= */
.overview {
    display: flex;
    flex-wrap: wrap;
    /* Allow items to wrap on smaller screens */
    justify-content: space-between;
    align-items: stretch;
    background: #e3f2fd;
    padding: 14px 18px;
    border-radius: 6px;
    font-size: 1.1rem;
    color: #222;
    gap: 10px;
    transition: background 0.2s;
}

.overview div {
    flex: 1 1 180px;
    /* Grow and shrink, min width for better wrapping */
    text-align: center;
    min-width: 120px;
    word-break: break-word;
    padding: 8px 0;
    margin: 2px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Responsive adjustments for overview section */
@media (max-width: 900px) {
    .overview {
        font-size: 1rem;
        gap: 8px;
        padding: 10px;
    }

    .overview div {
        min-width: 100px;
        font-size: 1rem;
    }
}

@media (max-width: 648px) {
    .overview {
        flex-direction: column;
        align-items: stretch;
    }

    .overview div {
        flex: unset;
        /* Remove flex: 1 1 180px; for better stacking */
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .overview {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
    }

    .overview div {
        min-width: 0;
        width: 100%;
        font-size: 0.98rem;
        padding: 8px 0;
    }
}

/* =========================
   Entries List
========================= */
.entries h2 {
    margin-bottom: 12px;
    font-size: 1.2rem;
    color: #333;
}

ul#entries-list {
    list-style-type: none;
    padding: 0;
}

li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.4s forwards;
    transition: background 0.2s, transform 0.2s;
}

li:last-child {
    border-bottom: none;
}

li .actions {
    display: flex;
    gap: 8px;
}

.actions button {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 7px 12px;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.2s;
    will-change: transform;
}

.actions button.edit-btn:hover {
    background-color: #1565c0;
    transform: translateY(-2px) scale(1.07);
}

.actions button.delete-btn {
    background-color: #f44336;
}

.actions button.delete-btn:hover {
    background-color: #b71c1c;
    transform: translateY(-2px) scale(1.07);
}

/* Distinct backgrounds and padding for income and expense entries */
.entry-income {
    background-color: #e6f9ea;
    /* light green */
    margin: 0.5rem 0;
    padding: 10px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.entry-expense {
    background-color: #fdeaea;
    /* light red */
    margin: 0.5rem 0;
    padding: 10px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

/* Fade-in animation for list items */
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   Responsive Design
========================= */
@media (max-width: 1024px) {
    .container {
        max-width: 90vw;
    }
}

@media (max-width: 768px) {
    .container {
        max-width: 98vw;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .overview {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        align-items: stretch;
    }

    .overview div {
        min-width: 0;
        width: 100%;
    }

    .input-actions {
        flex-direction: column;
        gap: 8px;
    }

    .filter-section fieldset {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    li {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}
