/* ============================================================
   FinTrack — Custom Styles
   ============================================================ */

/* ── Root variables ─────────────────────────────────────── */
:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --topbar-bg: #1e293b;
    --body-bg: #f1f5f9;
    --card-border: rgba(226, 232, 240, 0.9);
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.05), 0 4px 14px rgba(15, 23, 42, 0.04);
}

/* ── Global ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.925rem;
    color: #0f172a;
}

a { text-decoration: none; }

.amount-value {
    font-variant-numeric: tabular-nums;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    flex-shrink: 0;
}

#sidebar .nav-link {
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 0.875rem;
    white-space: nowrap;
}

#sidebar .nav-link:hover {
    background-color: var(--sidebar-hover);
}

#sidebar .nav-link.active {
    background-color: #3b82f6 !important;
    color: #fff !important;
    font-weight: 600;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background-color: #475569;
    border-radius: 50%;
}

/* ── Main content ────────────────────────────────────────── */
#main-content {
    min-height: 100vh;
    overflow-x: hidden;
    min-width: 0;
}

/* ── Topbar (mobile) ─────────────────────────────────────── */
.topbar {
    background-color: var(--topbar-bg);
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* ── Auth pages ──────────────────────────────────────────── */
.auth-bg {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
}

.auth-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ── Summary cards ───────────────────────────────────────── */
.summary-card {
    border: 1px solid var(--card-border);
    border-radius: 14px;
    background-color: #fff;
    box-shadow: var(--card-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

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

/* ── Cards ───────────────────────────────────────────────── */
.table-card {
    border: 1px solid var(--card-border);
    border-radius: 14px;
    background-color: #fff;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

/* ── Tables ──────────────────────────────────────────────── */
.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0 !important;
    background: #f8fafc;
    white-space: nowrap;
}

.table td { vertical-align: middle; }

.table-hover tbody tr:hover { background-color: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────── */
.badge-income  { background-color: #dcfce7; color: #16a34a; font-weight: 600; }
.badge-expense { background-color: #fee2e2; color: #dc2626; font-weight: 600; }

.badge-soft-neutral {
    background-color: #f1f5f9;
    color: #475569;
    font-weight: 500;
    border: 1px solid #e2e8f0;
}

/* ── Chart containers ────────────────────────────────────── */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

.chart-container--doughnut {
    position: relative;
    width: 100%;
    height: 220px;
}

.chart-container canvas,
.chart-container--doughnut canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ── Category legend (Doughnut) ──────────────────────────── */
.category-legend {
    max-height: 185px;
    overflow-y: auto;
    padding-right: 4px;
}

.category-legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    transition: background-color 0.12s ease;
}

.category-legend-item:hover {
    background-color: #f8fafc;
}

.category-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Empty state ─────────────────────────────────────────── */
.chart-empty-state {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem 1rem;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background-color: #f8fafc;
}

.chart-empty-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }

.page-header h1 {
    font-size: 1.45rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

/* ── Icon picker (categories) ────────────────────────────── */
.icon-picker { background: #f8fafc; max-height: 160px; overflow-y: auto; }

.icon-option input:checked + .icon-box-pick {
    background-color: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.icon-box-pick {
    width: 38px;
    height: 38px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all .15s;
    color: #475569;
}

.icon-box-pick:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; }
.btn-sm { border-radius: 6px; }

/* ── Form controls ───────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 8px;
    border-color: #e2e8f0;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input-group-text {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #64748b;
}

/* ── Pagination ──────────────────────────────────────────── */
.page-link { border-radius: 6px !important; margin: 0 2px; color: #3b82f6; }
.page-item.active .page-link { background-color: #3b82f6; border-color: #3b82f6; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { border-radius: 10px; border: none; }

/* ── FAB Button (mobile) ─────────────────────────────────── */
.fab-btn {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1015;
    border-radius: 50% !important;
}

@media (min-width: 768px) {
    .fab-btn { display: none !important; }
}

/* ── Responsive ──────────────────────────────────────────── */
#wrapper { display: flex; }

@media (max-width: 767.98px) {
    #sidebar { display: none !important; }
    #wrapper { flex-direction: column; }

    .main-inner {
        padding-bottom: 5.5rem !important;
    }

    .page-header h1 { font-size: 1.25rem; }

    .summary-card { border-radius: 12px; }

    .chart-container { height: 250px; }
    .chart-container--doughnut { height: 215px; }

    .table th, .table td { font-size: 0.8rem; padding: 0.55rem; }
}

@media (max-width: 575.98px) {
    .page-header { flex-direction: column; align-items: flex-start !important; }
}

/* ── Utility ─────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.text-nowrap    { white-space: nowrap; }
.min-w-0        { min-width: 0; }

/* ── Scrollbar (webkit) ──────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
