/* ============================================
   FinTrack Pro - Main Stylesheet
   Dark Theme, Modern Design
   ============================================ */

:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --primary-dark: #4f46e5;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.2);
    --info: #06b6d4;
    --purple: #8b5cf6;

    --bg-base: #0a0a0f;
    --bg-surface: #111118;
    --bg-card: #16161f;
    --bg-card-hover: #1c1c28;
    --bg-input: #1e1e2a;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);

    --text-primary: #f0f0f5;
    --text-secondary: #8b8b9e;
    --text-muted: #5a5a6e;

    --sidebar-width: 240px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --font-heading: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 30px var(--primary-glow);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 99px; }

/* ── Sidebar ────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.brand-sub {
    font-size: 10px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 2px;
    display: block;
    margin-top: -2px;
}

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

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 12px 20px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(99,102,241,.15), rgba(99,102,241,.05));
    color: var(--primary);
    border-left: 2px solid var(--primary);
    margin-left: 6px;
}

.nav-item i { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.net-worth-card {
    background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(139,92,246,.1));
    border: 1px solid rgba(99,102,241,.2);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.nw-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.nw-amount { font-family: var(--font-heading); font-size: 18px; font-weight: 700; color: var(--primary); }

/* ── Main Content ───────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
}

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

/* ── Topbar ─────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.btn-toggle-sidebar {
    width: 36px; height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all .2s;
}

.btn-toggle-sidebar:hover { border-color: var(--primary); color: var(--primary); }

.page-breadcrumb {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 99px;
}

.btn-quick-add {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 99px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-quick-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

/* ── Page Body ──────────────────────────────── */
.page-body {
    padding: 24px;
    flex: 1;
}

/* ── Cards ──────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .2s;
}

.card:hover { border-color: var(--border-hover); }
.card-body { padding: 20px; }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

/* ── Stat Cards ─────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all .3s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent-color, var(--primary));
    opacity: 0.7;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-hover);
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    margin: 4px 0;
}

.stat-change {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Account Cards ──────────────────────────── */
.account-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all .3s;
}

.account-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.account-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 99px;
    background: rgba(255,255,255,.08);
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.account-name {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.account-balance {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
}

.account-number {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    letter-spacing: 2px;
}

/* ── Transaction List ───────────────────────── */
.tx-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    transition: all .2s;
}

.tx-item:last-child { border-bottom: none; }
.tx-item:hover { padding-left: 4px; }

.tx-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.tx-info { flex: 1; min-width: 0; }

.tx-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.tx-amount {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    text-align: right;
    flex-shrink: 0;
}

.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }
.tx-amount.transfer { color: var(--info); }

/* ── Budget Progress ────────────────────────── */
.budget-item {
    margin-bottom: 16px;
}

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

.budget-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.budget-amounts {
    font-size: 12px;
    color: var(--text-secondary);
}

.budget-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 99px;
    overflow: hidden;
}

.budget-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ── Forms ──────────────────────────────────── */
.form-control, .form-select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 14px !important;
    transition: border-color .2s, box-shadow .2s !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-glow) !important;
    outline: none !important;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-control::placeholder { color: var(--text-muted) !important; }

/* ── Buttons ────────────────────────────────── */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-success-custom {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-danger-custom {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

/* ── Modal ──────────────────────────────────── */
.glass-modal {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-hover) !important;
    border-radius: var(--radius-lg) !important;
    color: var(--text-primary) !important;
}

.modal-backdrop { backdrop-filter: blur(4px); }

.modal-type-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.type-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.type-tab.active {
    background: var(--bg-card);
    color: var(--primary);
}

.amount-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border-hover);
    border-radius: var(--radius);
    padding: 8px 16px;
    gap: 8px;
    margin: 8px 0;
    transition: border-color .2s;
}

.amount-input-wrapper:focus-within { border-color: var(--primary); }

.currency-sign {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-muted);
}

.amount-big-input {
    flex: 1;
    background: none;
    border: none;
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}

.amount-big-input::placeholder { color: var(--text-muted); }

/* ── Tables ─────────────────────────────────── */
.table {
    color: var(--text-primary) !important;
    font-size: 14px;
}

.table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
    padding: 10px 12px !important;
    background: transparent !important;
}

.table td {
    border-color: var(--border) !important;
    padding: 12px !important;
    vertical-align: middle;
    background: transparent !important;
}

.table tbody tr:hover td {
    background: rgba(255,255,255,.02) !important;
}

/* ── Badges ─────────────────────────────────── */
.badge-custom {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}

.badge-income {
    background: var(--success-glow);
    color: var(--success);
    border: 1px solid rgba(16,185,129,.2);
}

.badge-expense {
    background: var(--danger-glow);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,.2);
}

.badge-transfer {
    background: rgba(6,182,212,.1);
    color: var(--info);
    border: 1px solid rgba(6,182,212,.2);
}

/* ── Progress Bars ──────────────────────────── */
.progress {
    background: var(--bg-input) !important;
    border-radius: 99px !important;
    height: 8px !important;
}

.progress-bar { border-radius: 99px !important; }

/* ── Debt Cards ─────────────────────────────── */
.debt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all .2s;
}

.debt-card:hover { border-color: var(--border-hover); }

.debt-person {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

/* ── Section Headers ────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Empty State ────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    text-align: center;
}

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

/* ── Donut Chart Container ──────────────────── */
.chart-container {
    position: relative;
}

/* ── Savings Goal Card ──────────────────────── */
.goal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all .2s;
}

.goal-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }

.goal-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.goal-amounts {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0;
}

/* ── Color dots ─────────────────────────────── */
.color-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Date Filter ────────────────────────────── */
.date-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.date-filter-btn {
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
}

.date-filter-btn.active, .date-filter-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── Toast ──────────────────────────────────── */
.toast {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-hover) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .page-body { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stat-value { font-size: 20px; }
}

/* ── Loading Spinner ────────────────────────── */
.loading-spin {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc Utilities ─────────────────────────── */
.text-success-custom { color: var(--success) !important; }
.text-danger-custom { color: var(--danger) !important; }
.text-warning-custom { color: var(--warning) !important; }
.text-info-custom { color: var(--info) !important; }
.text-primary-custom { color: var(--primary) !important; }
.text-muted-custom { color: var(--text-muted) !important; }
.text-secondary-custom { color: var(--text-secondary) !important; }
.fw-syne { font-family: var(--font-heading); }
.divider { border-color: var(--border) !important; }
.gap-6 { gap: 6px !important; }
.cursor-pointer { cursor: pointer; }

/* ── Chart Legend ───────────────────────────── */
.custom-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.legend-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.legend-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

/* ── Heatmap ────────────────────────────────── */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--bg-input);
    transition: all .2s;
}

/* ── Report Cards ───────────────────────────── */
.report-stat {
    text-align: center;
    padding: 16px;
}

.report-stat-value {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    display: block;
}

.report-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Filter Row ─────────────────────────────── */
.filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-row .form-control,
.filter-row .form-select {
    max-width: 160px !important;
}

/* ── Category Icon Badge ────────────────────── */
.cat-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

/* ── Overlay ────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}

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

/* ── Monthly chart ──────────────────────────── */
.chart-wrapper { position: relative; height: 220px; }
