:root {
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --light-bg: #f8f9fa;
    --dark-text: #343a40;
    --light-text: #f8f9fa;
    --border-color: #dee2e6;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
@keyframes spinner-border {
    to { transform: rotate(360deg); }
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--light-bg);
    color: var(--dark-text);
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header & Week Selector */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.week-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 0.5rem;
    border-radius: 50px;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

.week-selector h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.week-selector button {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.3s;
}

.week-selector button:hover {
    background: #357ABD;
}

/* Display Panel */
.display-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.display-box {
    background: #fff;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
}
.display-box.remaining {
    grid-column: 1 / -1; /* Span full width */
    background: var(--primary-color);
    color: white;
}
.display-box h3 {
    margin-bottom: 0.5rem;
    font-weight: 400;
    font-size: 0.9rem;
}
.display-box p {
    font-size: 1.8rem;
    font-weight: 700;
}
.display-box.remaining p.negative {
    color: #ffdddd;
}

.inline-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    transition: all 0.3s;
}
.inline-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Expense List & Form */
.content-area {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.toggle-form-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

#add-expense-toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
}
#add-expense-toggle-btn:hover {
    background: #357ABD;
}

#expense-list-container {
    list-style: none;
}
.expense-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}
.expense-item:last-child {
    border-bottom: none;
}
.expense-info {
    flex-grow: 1;
}
.expense-info .description {
    font-weight: 600;
}
.expense-info .date {
    font-size: 0.8rem;
    color: #6c757d;
}
.expense-amount {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--danger-color);
    margin: 0 1rem;
}
.delete-btn {
    background: #e9ecef;
    color: #6c757d;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}
.delete-btn:hover {
    background: var(--danger-color);
    color: white;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}
.modal-content {
    background-color: #fefefe;
    margin: 40% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
    animation: slide-up 0.3s ease-out;
}
@keyframes slide-up {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.close-btn {
    color: #aaa;
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.modal-content h3 {
    text-align: center;
    margin-bottom: 1.5rem;
}
.modal-content input {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}
.modal-content button {
    width: 100%;
    padding: 0.8rem;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}
/* Add this to the end of your style.css file */
.edit-btn {
    background: #e9ecef;
    color: #6c757d;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    margin-right: 0.5rem; /* Add space between buttons */
    line-height: 30px; /* Center the pencil icon */
}

.edit-btn:hover {
    background: var(--primary-color);
    color: white;
}
/* Add this to the end of your style.css file */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    border: .2em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
    margin-left: 0.5rem;
}
/*
========================================
  Authentication Page Styles
========================================
*/
body.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-container {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
    margin: 1rem;
}

.auth-container h2 {
    text-align: center;
    color: var(--dark-text);
    margin-bottom: 2rem;
    font-weight: 600;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-container input {
    width: 100%;
    padding: 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.auth-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.auth-container button[type="submit"] {
    width: 100%;
    padding: 0.9rem;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.auth-container button[type="submit"]:hover {
    background-color: #357ABD;
}

.error-message {
    color: var(--danger-color);
    text-align: center;
    margin-top: 1rem;
    font-weight: 500;
    min-height: 1.2em; /* Prevents layout shift when message appears */
}

.form-toggle {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #6c757d;
}

.form-toggle a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.form-toggle a:hover {
    text-decoration: underline;
}
/*
========================================
  New Two-Column Auth Page Layout
========================================
*/
.login-page-wrapper {
    display: flex;
    flex-direction: column; /* Mobile-first: stack columns */
    width: 100%;
    min-height: 100vh;
    background-color: #fff;
}

.info-panel {
    background-color: var(--primary-color);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
}

.info-panel h1 {
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.info-panel p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.features-list {
    list-style: none;
    padding: 0;
    text-align: left;
    display: inline-block;
    font-size: 1.1rem;
}

.features-list li {
    margin-bottom: 1rem;
}

.auth-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    flex-grow: 1;
}

/* Make body.auth-page simpler */
body.auth-page {
    display: block;
}

.auth-container {
    box-shadow: none; /* Shadow is on the wrapper on desktop */
    padding: 1rem;
    margin: 0;
}

.expense-item-wrapper {
    border-bottom: 1px solid var(--border-color);
}
.expense-item-wrapper:last-child {
    border-bottom: none;
}
.expense-item { padding: 0.8rem 0; }
.expense-item.main-expense {
    font-weight: bold;
}
.expense-actions {
    display: flex;
}
.add-sub-item-btn {
    background: var(--success-color);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    margin-right: 0.5rem;
    line-height: 30px;
}
.sub-items-container {
    padding-left: 2rem;
    border-left: 3px solid #f1f3f5;
    margin-left: 0.5rem;
}
.sub-item {
    font-size: 0.95rem;
}
.sub-item .expense-amount {
    font-weight: 400;
    font-size: 1rem;
}
/* Add these styles to the end of your style.css file */
.breakdown {
    font-size: 0.8rem;
    font-weight: 400;
    color: #6c757d;
    margin-top: 4px;
}
.breakdown .sub-total {
    font-weight: 600;
    color: var(--danger-color);
}
.breakdown .main-total {
    font-weight: 600;
    color: #343a40;
}
/* Add these styles to the end of your style.css file */
.category-remaining {
    font-weight: 600;
}
.category-remaining.positive {
    color: var(--success-color);
}
.category-remaining.negative {
    color: var(--danger-color);
}
/*
========================================
  Password Rules Styling
========================================
*/
.password-rules {
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
    margin: -0.5rem 0 1rem 0; /* Position it between password and button */
}

/* Desktop Styles */
@media (min-width: 992px) {
    .login-page-wrapper {
        flex-direction: row; /* Side-by-side on desktop */
    }

    .info-panel {
        width: 45%;
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: left;
    }

    .info-content {
        max-width: 450px;
    }
    
    .auth-panel {
        width: 55%;
    }

    .auth-container {
         /* Add back shadow for the auth form card on desktop */
        box-shadow: var(--shadow);
        padding: 2.5rem;
    }
}
@media (min-width: 600px) {
    .modal-content {
        margin: 15% auto;
    }
}