@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-bg: #f5f7fa;
    --sidebar-bg: #1e2a47;
    --card-bg: #ffffff;
    --text-primary: #1e2a47;
    --text-secondary: #6c757d;
    --text-light: #ffffff;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

/* Basic Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-primary);
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* App Layout */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: #1e2a47; /* Explicit color instead of CSS variable */
    color: var(--text-light);
    padding: 16px;
    display: flex;
    flex-direction: column;
    opacity: 1 !important;
    z-index: 1001 !important;
    height: 100vh;
    overflow-y: auto;
    width: 260px;
    box-sizing: border-box;
}

.sidebar-close {
    display: none; /* Hide on desktop */
}


.sidebar-header {
    background-color: #1e2a47 !important;
    padding-bottom: 10px;
}
.sidebar-header .logo {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.sidebar-header .logo span {
    font-weight: 400;
    color: var(--accent-blue);
}

.sidebar-header .tagline {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.sidebar-nav {
    background-color: #1e2a47 !important;
}
.sidebar-nav ul {
    background-color: #1e2a47 !important;
    padding-left: 0;
    margin: 0;
}
.sidebar-nav ul li {
    margin-bottom: 10px;
    background-color: #1e2a47 !important;
}

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    transition: background-color 0.3s;
    font-weight: 500;
    background-color: #1e2a47 !important;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav ul li a i {
    font-size: 20px;
    margin-right: 15px;
}

.sidebar-nav ul li.active a,
.sidebar-nav ul li a:hover,
.sidebar-nav ul li.active a {
    background-color: #2c3a58 !important; /* Slightly darker than sidebar bg */
    color: var(--text-light);
}

.sidebar-nav ul li.active a {
    box-shadow: inset 3px 0 0 0 var(--accent-blue);
}


/* Page container */
.page {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.page.active-page {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Main Content */
.main-content {

    padding: 20px 30px;
    overflow-y: auto;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-title h1 {
    font-size: 28px;
    font-weight: 600;
}

.header-title p {
    color: var(--text-secondary);
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-toolbar .theme-toggle,
.header-toolbar .user-profile {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.header-icon-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
}

.header-icon-btn:hover {
    color: var(--text-primary);
}


.balance-info {
    text-align: right;
}

.balance-info p {
    color: var(--text-secondary);
    font-size: 12px;
}

.balance-info h2 {
    font-size: 22px;
    color: #22c55e; /* Change to green as in screenshot */
    font-weight: 700;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 20px;
}

.card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card:last-child {
    margin-bottom: 0;
}

/* Card Specific Styles */
/* NEW Quick Actions */
.quick-actions-new {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 0;
    background-color: #f0f0f0;
    box-shadow: none;
}
.action-btn-new {
    padding: 20px;
    border-radius: 12px;
    border: none;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}
.action-btn-new:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}
.action-btn-new i { font-size: 24px; }
.action-btn-new.green { background-color: var(--accent-green); }
.action-btn-new.red { background-color: var(--accent-red); }
.action-btn-new.blue { background-color: var(--accent-blue); }
.action-btn-new.purple { background-color: var(--accent-purple); }


/* NEW Summary Cards */
.summary-card-new {
    grid-column: span 2;
    display: flex;
    align-items: center;
    gap: 20px;
}
.summary-card-new .summary-icon {
    font-size: 28px;
    padding: 15px;
    border-radius: 50%;
    color: #fff;
}
.summary-card-new.green .summary-icon { background-color: var(--accent-green); }
.summary-card-new.red .summary-icon { background-color: var(--accent-red); }
.summary-card-new.blue .summary-icon { background-color: var(--accent-blue); }
.summary-card-new.purple .summary-icon { background-color: var(--accent-purple); }

.summary-card-new .summary-details p {
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.summary-card-new .summary-details h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.summary-card-new .summary-details .change-indicator,
.summary-card-new .summary-details .sub-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.chart-container {
    grid-column: span 2;
}

.expense-category-chart {
    grid-column: span 2;
}
#expense-category-chart-container {
    position: relative;
    min-height: 250px; /* Adjust as needed */
    display: flex;
    align-items: center;
    justify-content: center;
}

.income-expense-chart {
    height: 16rem; /* Fixed height for the income vs expense chart container */
    position: relative;
}
.empty-chart-message {
    color: var(--text-secondary);
    font-size: 14px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.chart-header h3 { font-size: 16px; font-weight: 600; }
.chart-header select {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-bg);
}

.recent-transactions {
    grid-column: 1 / span 2;
}
.card-header {

    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-header .view-all {
    font-size: 13px;
    color: var(--accent-blue);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}
#transaction-list .empty-state {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
}

.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;
}
.transaction-desc {
    font-weight: 500;
}
.transaction-cat {
    font-size: 12px;
    color: var(--text-secondary);
}
.transaction-amount {
    font-weight: 600;
}

.financial-tips {


    grid-column: 3 / span 2;
}
.financial-tips h3 { font-size: 16px; font-weight: 600; margin-bottom: 15px; }
.financial-tips ul li {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
}
.financial-tips ul li .tip-icon {
    font-size: 20px;
    margin-right: 15px;
}
.financial-tips ul li .tip-icon.info { color: var(--accent-blue); }
.financial-tips ul li .tip-icon.success { color: var(--accent-green); }
.financial-tips ul li .tip-icon.warning { color: var(--accent-purple); }


/* --- GENERIC & REUSABLE COMPONENTS --- */
.btn-primary, .btn-primary-green, .btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary { background-color: var(--accent-blue); }
.btn-primary:hover { background-color: #2563eb; }
.btn-primary-green { background-color: var(--accent-green); }
.btn-primary-green:hover { background-color: #059669; }
.btn-danger { background-color: var(--accent-red); }
.btn-danger:hover { background-color: #dc2626; }

.form-inline {
    display: flex;
    gap: 15px;
    align-items: center;
}
.form-inline input, .form-inline select {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}
.form-inline input:focus, .form-inline select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    align-items: end;
}
.form-grid-layout .form-group {
    margin-bottom: 0;
}
.form-grid-layout .form-group-full {
    grid-column: 1 / -1;
}
.form-grid-layout button {
    width: 100%;
    justify-content: center;
}

/* --- TRANSAKSI PAGE --- */

.table-container {
    width: 100%;
    overflow-x: auto;
}
.transaction-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
.transaction-table th, .transaction-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.transaction-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--text-secondary);
}
.transaction-table tbody tr:hover {
    background-color: #f8f9fa;
}
.transaction-table .amount-income { color: var(--accent-green); font-weight: 600; }
.transaction-table .amount-expense { color: var(--accent-red); font-weight: 600; }
.transaction-table .badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}
.transaction-table .badge.income { background-color: var(--accent-green); }
.transaction-table .badge.expense { background-color: var(--accent-red); }
.transaction-table .action-delete {
    background: none;
    border: none;
    color: var(--accent-red);
    font-size: 20px;
    cursor: pointer;
}

/* --- KATEGORI PAGE --- */
.category-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}
.category-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}
.category-list li:nth-child(odd) { background-color: #f8f9fa; }
#expense-category-list li { border-left: 3px solid var(--accent-red); }
#income-category-list li { border-left: 3px solid var(--accent-green); }
.category-list .action-delete {
    background: none;
    border: none;
    color: var(--accent-red);
    font-size: 20px;
    cursor: pointer;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
}
.category-list li:hover .action-delete {
    visibility: visible;
    opacity: 1;
}

/* --- ANGGARAN & TARGET TABUNGAN --- */
.budget-container, .savings-goal-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.budget-card, .savings-goal-card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.budget-card .card-header, .savings-goal-card .card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}
.progress-bar-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 15px;
    height: 10px;
    margin: 15px 0;
}
.progress-bar {
    height: 100%;
    background-color: var(--accent-green);
    border-radius: 15px;
}
.budget-details, .savings-details {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}
.savings-goal-card .btn-primary {
    width: 100%;
    justify-content: center;
    margin-top: 15px;
}

/* --- KALKULATOR PAGE --- */
.calculator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.calculator-results {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    background-color: #eef2ff; /* light blue */
}
.calculator-results.green { background-color: #f0fdf4; /* light green */ }
.calculator-results h4 { margin-bottom: 10px; }
.calculator-results p { margin-bottom: 5px; }
.calculator-results p span { font-weight: 600; }
.full-width { width: 100%; justify-content: center; }

/* --- PENGATURAN PAGE --- */
.settings-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}
.settings-buttons {
    display: flex;
    gap: 15px;
}

/* --- LAPORAN PAGE --- */
.laporan-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.laporan-charts .card {
    margin-bottom: 0; /* Remove extra margin from card inside this grid */
}
.laporan-charts .card canvas {
    height: 300px !important; /* Force a fixed height */
    width: 100% !important;
}
.chart-container-laporan {
    position: relative;
    height: 300px; /* Match canvas height */
    display: flex;
    align-items: center;
    justify-content: center;
}


/* --- MODAL STYLES --- */


.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* Hidden by default, changed to 'flex' by JS */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 450px;
    position: relative;
    animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-content h3 {
    margin-bottom: 25px;
    font-size: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--primary-bg);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background-color: var(--accent-blue);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.btn-submit:hover {
    background-color: #2563eb; /* A slightly darker blue */
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}

/* Responsive Adjustments */
@media (max-width: 1200px) {

    .laporan-charts {
        grid-template-columns: 1fr;
    }
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .quick-actions-new, .chart-container, .recent-transactions, .financial-tips, .expense-category-chart {
        grid-column: 1 / -1;
    }
    .summary-card-new {
        grid-column: span 1;
    }
    .category-lists, .calculator-container {
        grid-template-columns: 1fr;
    }
}


@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        /* In a real app, this would be a toggleable sidebar */
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        z-index: 1001;
        background-color: var(--sidebar-bg);
        padding: 20px;
        flex-direction: column;
        transition: transform 0.3s ease-in-out;
        transform: translateX(-100%);
    }
    .sidebar.active {
        display: flex;
        transform: translateX(0);
        box-shadow: 2px 0 5px rgba(0,0,0,0.3);
        opacity: 1 !important;
        z-index: 1001 !important;
    }

    .sidebar-close {
        display: block;
        position: absolute;
        top: 15px;
        right: 20px;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 28px;
        cursor: pointer;
        z-index: 1002;
        transition: color 0.2s;
    }
    .sidebar-close:hover {
        color: var(--text-light);
    }

    .sidebar-toggle {
        display: inline-flex;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 28px;
        cursor: pointer;
        margin-right: 15px;
        z-index: 1100;
    }
    .main-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .main-content {
        padding: 15px;
    }
    .header-title h1 { font-size: 24px; }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .quick-actions-new {
        grid-template-columns: 1fr 1fr;
    }
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
}

/* About Me / Donate page styles */
.page-aboutme {
    padding: 20px;
}

.aboutme-card {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}

.donate-image-container {
    margin: 20px 0;
    width: 100%;
    max-width: 320px;
    height: auto;
    margin-left: auto;
    margin-right: auto;
}

.donate-image-container img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Responsive adjustments for smartphone screens */
@media (max-width: 480px) {
    .aboutme-card {
        padding: 10px;
    }
    .donate-image-container {
        max-width: 100%;
    }
}

/* Additional styles for About Me / Donate page enhancements */
#page-aboutme .aboutme-card p {
    margin-bottom: 12px;
    line-height: 1.5;
    text-align: justify;
    white-space: pre-line;
}

#page-aboutme h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
}

#copy-account-btn {
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#copy-account-btn:hover {
    background-color: #059669;
}

.donation-stats {
    margin-top: 15px;
    font-size: 14px;
    color: var(--text-secondary);
}

.smile-illustration {
    font-size: 48px;
    margin-top: 20px;
    animation: smileBounce 2s infinite ease-in-out;
}

@keyframes smileBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}
