/* Base & Variables */
:root {
    /* Nepali Vibrant Palette */
    --primary: #DC143C;    /* Crimson Red (Rhododendron) */
    --primary-dark: #b91c1c;
    --secondary: #003893;  /* Deep Blue (Flag border/Moon/Sun) */
    --accent: #FFD700;     /* Marigold Gold */
    
    --bg-body: #F3F4F6;    /* Light Grayish Blue */
    --bg-card: #FFFFFF;
    
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    
    --font-main: 'Outfit', 'Inter', 'Poppins', sans-serif;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-blue: 0 4px 14px 0 rgba(0, 56, 147, 0.39);
}

/* Dark Mode Theme */
[data-theme="dark"] {
    --bg-body: #111827;
    --bg-card: #1F2937;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    
    /* Adjust vibrant colors for dark mode readability */
    --primary: #EF4444; 
    --secondary: #3B82F6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

[data-theme="dark"] input, 
[data-theme="dark"] select,
[data-theme="dark"] .btn-export {
    background: #374151;
    border-color: #4B5563;
    color: #F9FAFB;
}

[data-theme="dark"] .btn-export:hover {
    background: #4B5563;
}

[data-theme="dark"] .input-group label {
    color: #D1D5DB;
}

/* Base Card Style */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.5rem;
    color: var(--primary);
    padding: 0.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.logo i {
    color: var(--secondary);
    font-size: 1.8rem;
}

.stats-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    text-align: center;
    border-top: 4px solid var(--primary);
    box-shadow: var(--shadow-lg);
}

.stats-card h3 {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--secondary);
    line-height: 1.2;
}

.budget-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: #f3f4f6;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    align-self: center;
}

#editBudgetBtn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

#editBudgetBtn:hover { 
    transform: scale(1.2); 
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 10px;
    background: #E5E7EB;
    border-radius: 5px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--success);
    border-radius: 5px;
    transition: width 0.6s ease-out, background-color 0.3s ease;
}

.budget-status {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.2rem;
}

/* Quick Stats */
.quick-stats {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-left: 4px solid var(--accent);
}

.quick-stats h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.quick-stats h3 i {
    color: var(--accent);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 700;
}

.btn-export {
    width: 100%;
    padding: 0.6rem;
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-export:hover {
    background: #F3F4F6;
    color: var(--primary);
    border-color: var(--primary);
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar { 
    width: 8px; 
}

::-webkit-scrollbar-track { 
    background: transparent; 
}

::-webkit-scrollbar-thumb { 
    background: #CBD5E1; 
    border-radius: 4px; 
}

::-webkit-scrollbar-thumb:hover { 
    background: #94A3B8; 
}

/* Add Form Section */
.add-section {
    padding: 1.5rem;
    background: #fff;
    border-left: 5px solid var(--secondary);
    animation: slideUp 0.4s ease-out;
}

.add-section h2 {
    margin-bottom: 1.2rem;
    font-size: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.add-section h2 i {
    color: var(--secondary);
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    align-items: flex-end;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1 1 200px;
}

.input-group:nth-child(1) { 
    flex: 2 1 300px; 
}

.input-group:nth-child(2) { 
    flex: 1 1 120px; 
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

input, select {
    width: 100%;
    background: #F9FAFB;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

input:focus, select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(0, 56, 147, 0.1);
    background: #fff;
}

input[type="date"] {
    padding-right: 0.5rem;
}

.btn-add {
    flex: 1 1 200px;
    height: 46px;
    background: var(--secondary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-blue);
    transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
    margin-top: 0;
}

.btn-add:hover {
    background: #002a70;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(0, 56, 147, 0.45);
}

.btn-add:active {
    transform: translateY(0);
}

/* List Section */
.list-section {
    animation: slideUp 0.5s ease-out;
}

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

.section-header h2 {
    font-size: 1.25rem;
    color: var(--text-main);
}

#filterCategory {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

#filterCategory:hover {
    border-color: var(--secondary);
}

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

.transaction-item {
    display: flex;
    align-items: center;
    padding: 1.2rem;
    gap: 1.2rem;
    background: #fff;
    border-left: 4px solid transparent;
    animation: slideIn 0.3s ease-out;
}

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

.icon-box {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
}

/* Vibrant Category Colors */
.category-food .icon-box { 
    background: #FEF2F2; 
    color: #EF4444; 
}

.category-food { 
    border-left-color: #EF4444; 
}

.category-transport .icon-box { 
    background: #EFF6FF; 
    color: #3B82F6; 
}

.category-transport { 
    border-left-color: #3B82F6; 
}

.category-shopping .icon-box { 
    background: #FDF4FF; 
    color: #D946EF; 
}

.category-shopping { 
    border-left-color: #D946EF; 
}

.category-entertainment .icon-box { 
    background: #FFF7ED; 
    color: #F97316; 
}

.category-entertainment { 
    border-left-color: #F97316; 
}

.category-bills .icon-box { 
    background: #FFFBEB; 
    color: #F59E0B; 
}

.category-bills { 
    border-left-color: #F59E0B; 
}

.category-health .icon-box { 
    background: #ECFDF5; 
    color: #10B981; 
}

.category-health { 
    border-left-color: #10B981; 
}

.category-other .icon-box { 
    background: #F3F4F6; 
    color: #6B7280; 
}

.category-other { 
    border-left-color: #6B7280; 
}

.details {
    flex: 1;
}

.details h4 {
    font-size: 1.05rem;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.details p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.amount-box {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    background: #F3F4F6;
    color: var(--text-muted);
}

.btn-icon:hover {
    background: var(--secondary);
    color: #fff;
    transform: scale(1.1);
}

.btn-icon.delete:hover {
    background: var(--primary);
    color: #fff;
}

.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    background: #fff;
    border-radius: 16px;
    border: 1px dashed var(--border-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #D1D5DB;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: #fff;
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    position: relative;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: zoomIn 0.3s ease-out;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
}

.close-modal:hover { 
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-content .input-group {
    margin-bottom: 1.2rem;
}

.modal-content input, 
.modal-content select {
    width: 100%;
    background: #F9FAFB;
    border: 1px solid var(--border-color);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
}

.btn-save {
    width: 100%;
    padding: 0.8rem;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    margin-top: 1rem;
    transition: background 0.2s, transform 0.1s;
}

.btn-save:hover { 
    background: #059669;
    transform: translateY(-1px);
}

.btn-save:active {
    transform: translateY(0);
}

/* Animations */
@keyframes slideIn { 
    from { 
        opacity: 0; 
        transform: translateX(-10px); 
    } 
    to { 
        opacity: 1; 
        transform: translateX(0); 
    } 
}

@keyframes slideUp { 
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    } 
    to { 
        opacity: 1; 
        transform: translateY(0); 
    } 
}

@keyframes zoomIn { 
    from { 
        opacity: 0; 
        transform: scale(0.95); 
    } 
    to { 
        opacity: 1; 
        transform: scale(1); 
    } 
}

/* Search Box */
.search-box {
    position: relative;
    width: 200px;
}

.search-box input {
    padding-left: 2.2rem;
    height: 38px;
    font-size: 0.9rem;
}

.search-box i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        height: auto;
        padding: 1rem;
        overflow: visible;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        height: auto;
        gap: 1rem;
        overflow: visible;
        margin-bottom: 2rem;
    }

    .logo {
        flex: 1 1 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .stats-card {
        flex: 1 1 300px;
    }

    .quick-stats {
        flex: 1 1 300px;
    }

    .main-content {
        overflow: visible;
    }
}

@media (max-width: 600px) {
    .form-grid {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-add {
        width: 100%;
        margin-top: 1rem;
    }

    .transaction-item {
        flex-direction: column;
        text-align: center;
        gap: 0.8rem;
    }
    
    .details { 
        flex: 0; 
        margin-bottom: 0.5rem; 
    }
    
    .amount-box { 
        margin-bottom: 0.5rem; 
    }
    
    .actions { 
        justify-content: center; 
    }
}
