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

:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1a1d23;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-sidebar: #adb5bd;
    --text-sidebar-active: #ffffff;
    --border-color: #dee2e6;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 240px;
}

[data-theme="dark"] {
    --bg-primary: #121418;
    --bg-secondary: #1e2128;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #2d3138;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* ── Layout ── */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 i {
    color: var(--accent);
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.3);
    font-weight: 600;
    margin-top: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-sidebar-active);
}

.sidebar-nav a.active {
    background: rgba(67,97,238,0.12);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Top Navbar ── */

.top-navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-right .notification-link {
    position: relative;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.notification-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 10px;
    font-weight: 600;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-menu {
    position: relative;
}

.user-menu-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 1001;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown a,
.user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 16px;
    color: var(--text-primary);
    font-size: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--bg-primary);
}

.user-dropdown .divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ── Page Content ── */

.page-content {
    padding: 24px;
    flex: 1;
}

/* ── Cards ── */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}

.card-body {
    padding: 20px;
}

/* ── Stat Cards ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-card .stat-value.positive {
    color: var(--success);
}

.stat-card .stat-value.negative {
    color: var(--danger);
}

/* ── Tables ── */

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover {
    background: rgba(0,0,0,0.02);
}

[data-theme="dark"] .data-table tr:hover {
    background: rgba(255,255,255,0.02);
}

.data-table .amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.data-table .amount.expense {
    color: var(--danger);
}

.data-table .amount.income {
    color: var(--success);
}

.data-table .actions {
    white-space: nowrap;
}

.data-table .actions a {
    color: var(--text-secondary);
    margin-right: 8px;
    font-size: 0.85rem;
}

.data-table .actions a:hover {
    color: var(--accent);
}

/* ── Category Badge ── */

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(0,0,0,0.05);
}

[data-theme="dark"] .category-badge {
    background: rgba(255,255,255,0.08);
}

.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* ── Forms ── */

.form-container {
    max-width: 640px;
}

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

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control,
.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 16px;
    height: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ── Progress Bar ── */

.progress-bar-container {
    background: var(--bg-primary);
    border-radius: 20px;
    height: 10px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.5s ease;
}

/* ── Filter Bar ── */

.filter-bar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-bar label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-bar .form-control,
.filter-bar .form-select {
    padding: 6px 10px;
    font-size: 0.8rem;
    min-width: 140px;
}

/* ── Pagination ── */

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 20px 0 0;
    justify-content: center;
}

.pagination li a,
.pagination li span {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.pagination li.active span {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination li.disabled span {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* ── Alerts / Messages ── */

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert .close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ── Notification Items ── */

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    align-items: flex-start;
}

.notification-item.unread {
    background: rgba(67,97,238,0.04);
}

.notification-item .notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.notification-item .notif-content {
    flex: 1;
}

.notification-item .notif-title {
    font-weight: 500;
    font-size: 0.875rem;
}

.notification-item .notif-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.notification-item .notif-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Charts ── */

.chart-container {
    position: relative;
    width: 100%;
    max-height: 300px;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* ── Goal / Budget Cards ── */

.item-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.item-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.item-card .item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.item-card .item-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.item-card .item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.item-card .item-amounts {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-top: 8px;
}

.item-card .item-footer {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

/* ── Badge ── */

.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e9ecef; color: #495057; }

/* ── Auth Pages (non-sidebar) ── */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 32px;
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    font-size: 1.3rem;
    margin-bottom: 24px;
    text-align: center;
}

/* ── Footer ── */

.site-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .filter-group {
        width: 100%;
    }

    .filter-bar .form-control,
    .filter-bar .form-select {
        width: 100%;
        min-width: unset;
    }

    .item-cards {
        grid-template-columns: 1fr;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 16px;
    }
}

/* ── Error list in forms ── */

.errorlist {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}

.errorlist li {
    color: var(--danger);
    font-size: 0.8rem;
}

.helptext {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
