/* 
    Fully Responsive Fintech Design System | Glassmorphism Edition
    Modern, translucent, and vibrant dashboard theme.
*/

:root {
    --primary-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --budget-gradient: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(168, 85, 247, 0.4));
    
    --bg-mesh: fixed radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
               fixed radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
               fixed radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #a855f7;
    --card-radius: 20px;
}

/* Dark mode overrides (Glass remains consistent but deeper) */
body.dark-mode {
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-mesh);
    background-color: #0f172a;
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Light Mode Background Update */
body:not(.dark-mode) {
    background: #f8fafc;
    background-image: none;
    color: #1e293b;
}

.container {
    width: 100%;
    margin: 0 auto;
    padding: clamp(16px, 4vw, 32px);
    max-width: 1400px;
    position: relative;
    transition: padding 0.3s ease;
}

/* --- HEADER --- */
.top-header {
    text-align: center;
    position: relative;
    margin-bottom: 32px;
    z-index: 1100; /* Higher than modal (1000) to ensure clicks pass through */
}

.pill-label {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    color: var(--accent-color);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    border: 1px solid var(--glass-border);
}

.total-expense-label {
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.total-amount {
    font-size: clamp(2.5rem, 10vw, 4.5rem);
    font-weight: 950;
    margin: -4px 0 0;
    color: #ffffff;
    letter-spacing: -2px;
    transition: color 0.3s ease;
}

body:not(.dark-mode) .total-amount {
    color: #000000;
}

.theme-toggle-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    box-shadow: var(--glass-shadow);
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
}

#guest-actions, #user-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* --- FIXED NAV CONTROLS --- */
.fixed-top-left {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2000;
    display: flex;
    gap: 12px;
    align-items: center;
}

.fixed-top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    align-items: center;
}

.user-profile-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.user-avatar {
    font-size: 1.2rem;
}

.user-name {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text-main);
}

body:not(.dark-mode) .user-name {
    color: #1e293b;
}

@media (max-width: 650px) {
    .fixed-top-left { top: 10px; left: 10px; gap: 8px; flex-wrap: wrap;}
    .fixed-top-right { top: 10px; right: 10px; }
    .user-name { display: none; }
    .user-profile-display { padding: 8px; }
    #settings-btn span { display: none; }
    #logout-btn span { display: none; }
    .add-btn { padding: 10px 14px; }
}

.add-btn {
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.add-btn:hover { transform: scale(1.05); }

/* --- DASHBOARD GRID --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (min-width: 700px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 950px) {
    .dashboard-grid { grid-template-columns: 320px 1fr 340px; }
    .form-column { grid-row: span 1; }
}

.status-column, .ai-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-column .card, .ai-column .card {
    margin-bottom: 20px;
}

/* --- GLASS CARD SYSTEM --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--card-radius);
    padding: clamp(20px, 3vw, 24px);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    height: auto;
    transition: transform 0.2s ease, background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Light Mode Card Highlight Update */
body:not(.dark-mode) .card {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.1), var(--glass-shadow);
}

.card:hover { transform: translateY(-4px); background: rgba(255, 255, 255, 0.08); }

.h-full { height: 100%; }

.gradient-card { border: none; }
.budget-card { 
    background: var(--budget-gradient); 
    display: flex; justify-content: space-between; align-items: center;
}

.card-icon-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    opacity: 0.9; margin-bottom: 8px;
}

.card-title { font-size: 1.4rem; font-weight: 800; line-height: 1.1; }
.card-subtitle { font-size: 0.8rem; opacity: 0.8; }

/* --- CSS-BASED BUDGET CIRCLE --- */
.budget-circle-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.budget-circle {
    width: 100px; /* Adjusted from 120px to fit existing card padding better */
    height: 100px;
    border-radius: 50%;
    background: conic-gradient(
      var(--accent-color) calc(var(--progress) * 1%),
      rgba(255, 255, 255, 0.1) 0%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.6s ease-in-out;
}

.budget-circle::before {
    content: "";
    width: 80px; /* Slightly smaller than circle to create the donut effect */
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px); /* Glass effect for the center */
    border-radius: 50%;
    position: absolute;
}

.circle-percentage {
    position: relative;
    z-index: 2;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
}

/* --- FORM STYLES --- */
.section-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 16px; color: var(--accent-color); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

input, select {
    width: 100%; padding: 14px 16px; border-radius: 14px;
    border: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.2);
    color: var(--text-main); font-size: 1rem; font-weight: 600; outline: none;
    transition: border 0.3s ease, background 0.3s ease, color 0.3s ease;
}

/* Light Mode Input Contrast Fix */
body:not(.dark-mode) input,
body:not(.dark-mode) select {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

body:not(.dark-mode) input::placeholder { color: #94a3b8; }
body:not(.dark-mode) select option { background: #ffffff; color: #1e293b; }

input:focus, select:focus { border-color: var(--accent-color); }

.save-btn {
    width: 100%; padding: 16px; border-radius: 16px; border: none;
    background: var(--primary-gradient); color: white; font-weight: 800;
    cursor: pointer; box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

/* --- RECENT TRANSACTIONS --- */
.transaction-controls { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

@media (min-width: 600px) {
    .transaction-controls { flex-direction: row; justify-content: space-between; align-items: center; }
    .control-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
}

.filter-select, .date-inputs input {
    padding: 8px 12px;
    font-size: 0.75rem;
    height: 38px;
    width: auto;
    min-width: 130px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    transition: all 0.2s;
}

body:not(.dark-mode) .filter-select,
body:not(.dark-mode) .date-inputs input {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

.date-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.transaction-table { width: 100%; border-collapse: collapse; min-width: 500px; }
.transaction-table th { text-align: left; padding: 12px; color: var(--text-muted); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; border-bottom: 1px solid var(--glass-border); }
.transaction-table td { padding: 14px 12px; font-size: 0.9rem; border-bottom: 1px solid var(--glass-border); vertical-align: middle; }
.amount-td { font-weight: 800; color: var(--text-main); }

body:not(.dark-mode) .amount-td { color: #1e293b; }


.action-btns { 
    display: flex; justify-content: flex-end; align-items: center; gap: 12px; 
    min-width: 80px;
}
.edit-btn, .delete-btn {
    background: none; border: none; cursor: pointer; font-size: 1.1rem;
    padding: 6px; border-radius: 8px; transition: background 0.2s;
}
.edit-btn:hover { background: rgba(99, 102, 241, 0.2); }
.delete-btn:hover { background: rgba(239, 68, 68, 0.2); }

/* --- ANALYTICS --- */
.chart-wrapper { height: 260px; margin-top: 10px; padding: 10px; }

.progress-container { height: 10px; background: rgba(0, 0, 0, 0.2); border-radius: 10px; overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; width: 0%; transition: width 0.6s ease; }
.progress-green { background: #10b981; }
.progress-red { background: #ef4444; }

/* AI CARD */
.ai-card { border-left: 6px solid var(--accent-color); }
/* Specific override for uniform full boundary in Light Mode */
body:not(.dark-mode) .ai-card { border-left: 2px solid var(--accent-color); }
.ai-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }
.get-ai-btn { width: 100%; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); color: var(--accent-color); font-weight: 800; cursor: pointer; }

/* MODAL */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(10px); display: flex; justify-content: center; align-items: flex-end; z-index: 1000; }
.modal-content { background: var(--glass-bg); backdrop-filter: blur(24px); border: 1px solid var(--glass-border); width: 100%; max-width: 500px; padding: 32px; border-radius: 32px 32px 0 0; }

@media (min-width: 768px) {
    .modal { align-items: center; }
    .modal-content { border-radius: 32px; max-width: 450px; }
}

.hidden { display: none !important; }

/* --- AUTH STATIC SECTION (Login Overlap Fix) --- */
.auth-section {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 40px;
    padding-bottom: 60px;
}

.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border-radius: 32px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease;
}

/* Mobile optimization */
@media (max-width: 375px) {
    .container { padding: 16px; }
    .card { padding: 20px; }
    .total-amount { font-size: 2.5rem; }
    .auth-card { padding: 24px; border-radius: 24px; }
}

/* --- PROFILE DROPDOWN --- */
.profile-dropdown-container { position: relative; } 
.profile-dropdown { position: absolute; top: 100%; right: 0; margin-top: 12px; background: var(--glass-bg); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: var(--glass-shadow); display: flex; flex-direction: column; width: 200px; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 2500; } 
.profile-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); } 
.dropdown-item { padding: 12px 16px; color: var(--text-main); text-decoration: none; font-size: 0.85rem; font-weight: 600; cursor: pointer; background: transparent; border: none; text-align: left; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--glass-border); transition: background 0.2s; width: 100%; } 
.dropdown-item:last-child { border-bottom: none; color: #ef4444; } 
.dropdown-item:hover { background: rgba(255, 255, 255, 0.1); } 
.dropdown-header { padding: 12px 16px; border-bottom: 1px solid var(--glass-border); color: var(--text-muted); font-size: 0.75rem; }
