@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4f46e5;
    --primary-soft: #818cf8;
    --bg-grad-1: #e0e7ff;
    --bg-grad-2: #fae8ff;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #1e1b4b;
    --text-muted: #6b7280;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--bg-grad-1), var(--bg-grad-2));
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    color: var(--text-main);
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Floating Shapes */
.background-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary), var(--primary-soft));
    opacity: 0.15;
    filter: blur(50px);
    animation: float 20s infinite ease-in-out;
}

.shape:nth-child(1) {
    width: 50vw;
    height: 50vw;
    top: -10vh;
    left: -10vw;
    animation-duration: 25s;
}

.shape:nth-child(2) {
    width: 40vw;
    height: 40vw;
    bottom: -5vh;
    right: -5vw;
    background: #f472b6;
    animation-delay: -5s;
}

.shape:nth-child(3) {
    width: 20vw;
    height: 20vw;
    top: 40%;
    left: 40%;
    background: #34d399;
    animation-duration: 18s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-30px) scale(1.05);
    }
}

.container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);

    /* Responsive sizing */
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    max-height: 800px;
    /* Prevent it from being too tall on large screens */
    display: flex;
    flex-direction: column;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    background: linear-gradient(to right, var(--primary), #ec4899);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

/* Auth Section Centered */
#auth-section {
    max-width: 400px;
    margin: auto;
    width: 100%;
}

.tabs {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.5rem;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

input {
    width: 100%;
    padding: 16px;
    border: 2px solid transparent;
    background: white;
    border-radius: 12px;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary-soft);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

button {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

button:hover {
    background: #4338ca;
    transform: translateY(-2px);
    box-shadow: 0 15px 20px -3px rgba(79, 70, 229, 0.4);
}

/* Dashboard Layout */
#dashboard-section {
    flex: 1;
    min-height: 0;
    display: none;
    /* Toggled by JS */
    flex-direction: column;
}

#dashboard-section .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.inline-edit-form {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 60%;
}

.inline-input {
    width: 100%;
    padding: 5px;
    border: 1px solid var(--primary-soft);
    border-radius: 4px;
    font-size: 0.9rem;
    margin: 0 !important;
    /* Override global input margin */
}

.inline-input-amount {
    width: 80px;
    padding: 5px;
    border: 1px solid var(--primary-soft);
    border-radius: 4px;
    font-size: 0.9rem;
    margin: 0 !important;
}

#dashboard-section .content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.add-expense {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    max-height: 100%;
    overflow-y: auto;
}

.add-expense h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.list-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary);
}

.search-container {
    flex: 1;
    margin: 0 1.5rem;
}

.search-container input {
    margin: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
    width: 100%;
    max-width: 300px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.5);
}

.total-display {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.expense-list {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#expenses-ul {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-right: 5px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.expense-item {
    background: white;
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.expense-item:hover {
    transform: translateX(8px) scale(1.01);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}


.edit-btn {
    background: #e0e7ff !important;
    color: var(--primary) !important;
    margin-right: 5px !important;
}

.edit-btn:hover {
    background: #c7d2fe !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #dashboard-section .content {
        gap: 1rem;
        grid-template-columns: 1fr;
    }

    .container {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .add-expense {
        margin-bottom: 1rem;
    }
}

#auth-message {
    text-align: center;
    margin-top: 1rem;
    color: var(--danger);
}

.logout-btn {
    background: #e0e7ff;
    color: var(--primary);
    width: auto;
    padding: 0.75rem 1.5rem;
    box-shadow: none;
}

.logout-btn:hover {
    background: #c7d2fe;
    transform: translateY(-1px);
}

.expense-actions button {
    width: 32px;
    height: 32px;
    padding: 0;
    background: #fee2e2;
    color: var(--danger);
    border-radius: 8px;
    box-shadow: none;
    margin: 0;
}


.expense-actions button:hover {
    background: var(--danger);
    color: white;
}

/* Financial Summary & Budget */
.financial-summary {
    display: flex;
    gap: 15px;
    align-items: center;
}

.budget-display {
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--primary);
    /* Changed to primary from accent-primary which was undefined */
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    width: auto;
    height: auto;
    box-shadow: none;
}

.budget-container {
    margin-bottom: 20px;
    padding: 0 10px;
    flex-shrink: 0;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    /* Increased opacity for visibility */
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    /* Default to primary */
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.progress-fill.over-budget {
    background: #FF4D4D;
    /* Red */
}

.progress-fill.warning-budget {
    background: #FFC107;
    /* Yellow/Orange */
}


#budget-input {
    width: 100px;
    padding: 2px 5px;
    margin: 0;
    font-size: 1rem;
    border: 1px solid var(--primary-soft);
    border-radius: 4px;
    background: transparent;
    color: var(--text-main);
    display: inline-block;
}

#budget-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}


.confirm-btn {
    background: #22c55e !important;
    /* Green */
    color: white !important;
    margin-right: 5px !important;
    width: auto !important;
    padding: 5px 10px !important;
    font-size: 0.85rem !important;
}

.confirm-btn:hover {
    background: #16a34a !important;
}

.cancel-btn {
    background: #94a3b8 !important;
    /* Gray */
    color: white !important;
    width: auto !important;
    padding: 5px 10px !important;
    font-size: 0.85rem !important;
}

.cancel-btn:hover {
    background: #64748b !important;
}