@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-sidebar: #0B1A2A; 
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #f1f5f9;
    
    --green: #22c55e;
    --green-light: #dcfce7;
    --red: #ef4444;
    --red-light: #fee2e2;
    --blue: #3b82f6;
    --blue-light: #dbeafe;
    --yellow: #eab308;
    --yellow-light: #fef9c3;
    --white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.logo-container {
    display: flex;
    justify-content: center; 
    align-items: center;
    margin-bottom: 40px;
    
    /* These negative margins pull the logo out past the sidebar's padding */
    margin-left: -24px;
    margin-right: -24px;
    
    /* Calculate the width to account for the pulled margins (100% + 24px left + 24px right) */
    width: calc(100% + 48px); 
}

.main-logo {
    width: 100%;         
    max-width: none;     /* Removed the limit so it can stretch fully */
    height: auto;        
    display: block;
    mix-blend-mode: screen; 
}

.sidebar-nav { display: flex; flex-direction: column; gap: 8px; flex-grow: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: #94a3b8;
    border-radius: 12px;
    font-weight: 500;
    transition: 0.2s;
}

.nav-item:hover, .nav-item.active {
    background-color: var(--green);
    color: var(--white);
}

.promo-card {
    background-color: #16273A;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    font-size: 13px;
    color: #cbd5e1;
}

.promo-illustration {
    margin-top: 10px;
    font-size: 24px;
    color: var(--yellow);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
}

.header-titles h2 { font-size: 24px; color: #0f172a; }
.header-titles p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.header-actions { display: flex; align-items: center; gap: 24px; }

.btn-add {
    background-color: var(--green);
    color: var(--white);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}
.btn-add:hover { background-color: #16a34a; }

/* Dark mode toggle switch */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #e2e8f0;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.slider.round { border-radius: 24px; }

.profile-icon {
    width: 40px;
    height: 40px;
    background-color: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
}

/* Cards & Grid */
.dashboard-grid {
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.card {
    background-color: var(--white);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #f8fafc;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.summary-card { display: flex; align-items: center; gap: 16px; }
.summary-card h3 { font-size: 24px; margin: 4px 0; color: #0f172a; }
.summary-card .label { font-size: 14px; font-weight: 600; color: #334155; }
.summary-card .sub-label { font-size: 12px; color: var(--text-muted); }

.icon-box {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* Layout for Charts and Lists */
.charts-and-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-card h3, .transactions-card h3 {
    font-size: 18px;
    color: #0f172a;
    margin-bottom: 20px;
}

.chart-container { height: 280px; width: 100%; }

.total-expenses-footer {
    display: flex;
    justify-content: space-between;
    background-color: #f0fdf4;
    color: #166534;
    padding: 16px 20px;
    border-radius: 12px;
    margin-top: 24px;
    font-size: 16px;
}
.total-expenses-footer strong { font-size: 20px; }

/* Transactions */
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;}
.view-all { color: var(--green); text-decoration: none; font-size: 14px; font-weight: 600; }

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.transaction-item:last-child { border-bottom: none; }

.t-left { display: flex; align-items: center; gap: 16px; }
.t-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.t-left h4 { font-size: 16px; color: #0f172a; }
.t-left p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.t-right { text-align: right; }
.t-right h4 { font-size: 16px; font-weight: 600; }
.t-right p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Budget Tip */
.budget-tip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
}
.tip-left { display: flex; align-items: center; gap: 20px; }
.tip-left h4 { font-size: 18px; color: #0f172a; }
.tip-left p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.tip-right { width: 350px; }
.budget-labels { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: #334155; margin-bottom: 8px;}
.progress-bar { background-color: #e2e8f0; height: 10px; border-radius: 5px; overflow: hidden; margin-bottom: 8px;}
.progress-fill { background-color: var(--green); height: 100%; border-radius: 5px;}
.progress-percent { display: block; text-align: right; font-size: 14px; font-weight: 700; color: #0f172a; }

/* Utilities */
.bg-green-light { background-color: #dcfce7; }
.bg-red-light { background-color: #fee2e2; }
.bg-blue-light { background-color: #dbeafe; }
.bg-yellow-light { background-color: #fef9c3; }
.bg-green { background-color: var(--green); }
.text-green { color: #16a34a; }
.text-red { color: #dc2626; }
.text-blue { color: #2563eb; }
.text-yellow { color: #ca8a04; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    display: none; 
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--white);
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 { font-size: 20px; color: #0f172a; }

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}
.close-btn:hover { color: var(--red); }

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.btn-submit-form {
    width: 100%;
    background-color: var(--green);
    color: var(--white);
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    margin-top: 10px;
    transition: 0.2s;
}
.btn-submit-form:hover { background-color: #16a34a; }
/* --- New Clear Button Styles --- */
.btn-clear {
    background-color: #f1f5f9;
    color: var(--text-muted);
    border: none;
    padding: 8px 16px;
    border-radius: 20px; /* Pill shape matches the toggle */
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-clear:hover {
    background-color: #fee2e2;
    color: var(--red);
}

/* --- Dark Mode Theme Variables & Overrides --- */
body.dark-theme {
    --bg-main: #0f172a;
    --white: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --bg-sidebar: #020617;
}

body.dark-theme .card,
body.dark-theme .top-header,
body.dark-theme .modal-content {
    background-color: var(--white);
    border-color: var(--border-color);
    box-shadow: none;
}

/* Fix text colors in dark mode */
body.dark-theme .header-titles h2,
body.dark-theme .summary-card h3,
body.dark-theme .chart-card h3,
body.dark-theme .transactions-card h3,
body.dark-theme .t-left h4,
body.dark-theme .tip-left h4,
body.dark-theme .progress-percent,
body.dark-theme .modal-header h2 {
    color: #f8fafc;
}

body.dark-theme .summary-card .label,
body.dark-theme .budget-labels,
body.dark-theme .form-group label {
    color: #cbd5e1;
}

/* Fix specific background boxes in dark mode */
body.dark-theme .budget-tip,
body.dark-theme .total-expenses-footer {
    background-color: #0f172a;
    border-color: #334155;
}

body.dark-theme .transaction-item {
    border-bottom-color: #334155;
}

/* Form inputs in dark mode */
body.dark-theme input, 
body.dark-theme select {
    background-color: #0f172a;
    color: #f8fafc;
    border-color: #334155;
}

/* Clear button dark mode hover */
body.dark-theme .btn-clear { background-color: #334155; color: #cbd5e1; }
body.dark-theme .btn-clear:hover { background-color: #7f1d1d; color: #fca5a5; }
/* Custom size for the Budget Tip image */
.budget-icon {
    width: 56px;
    height: 56px;
    object-fit: contain; /* Keeps the image from stretching */
    border-radius: 50%;  /* Keeps the circular shape neat */
}
/* --- Mobile Hamburger Menu & Overlay --- */
.menu-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    font-size: 24px;
    color: #0f172a;
    cursor: pointer;
    transition: 0.2s;
}

body.dark-theme .menu-toggle { color: #f8fafc; }

.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    z-index: 40;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* --- Responsive Breakpoints --- */

/* Tablets & Small Laptops */
@media (max-width: 1024px) {
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .charts-and-lists { grid-template-columns: 1fr; }
}

/* Mobile Phones */
@media (max-width: 768px) {
    .menu-toggle { display: block; }
    
    /* Turn Sidebar into a sliding drawer */
    .sidebar {
        position: fixed;
        left: -300px; /* Hidden off-screen */
        top: 0;
        bottom: 0;
        z-index: 50;
        transition: left 0.3s ease;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar.open { left: 0; /* Slides in */ }
    
    /* Adjust header for mobile */
    .top-header { 
        padding: 20px; 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 20px; 
    }
    .header-actions { 
        width: 100%; 
        justify-content: space-between; 
    }
    
    /* Adjust grid and padding */
    .dashboard-grid { padding: 20px; }
    .summary-cards { grid-template-columns: 1fr; }
    
    /* Fix budget tip stacking */
    .budget-tip { flex-direction: column; align-items: flex-start; gap: 20px; }
    .tip-right { width: 100%; }
}

/* Very Small Phones */
@media (max-width: 480px) {
    .header-actions { flex-wrap: wrap; gap: 16px; }
    .btn-add { width: 100%; justify-content: center; }
}

/* --- Dark Mode Toggle Switch Animation --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-left: 10px;
}

/* Hide default HTML checkbox */
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

/* The sliding track */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1; /* Gray when off */
  transition: 0.3s;
}

/* The white circle inside the switch */
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* When checked (ON), change background to green */
input:checked + .slider {
  background-color: #22c55e;
}

/* When checked (ON), slide the circle to the right */
input:checked + .slider:before {
  transform: translateX(20px); 
}

/* Make it pill-shaped */
.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}
