/* ═══════════════════════════════════════════
   Variables
═══════════════════════════════════════════ */
:root {
    --sidebar-width:    260px;
    --sidebar-bg:       #1e293b;
    --sidebar-text:     #94a3b8;
    --sidebar-active:   #3b82f6;
    --topbar-height:    64px;
    --body-bg:          #f1f5f9;
    --card-radius:      0.75rem;
    --font:             'Inter', system-ui, -apple-system, sans-serif;
}

/* ═══════════════════════════════════════════
   Base
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--body-bg);
    font-family: var(--font);
    font-size: 0.9375rem;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.fw-bold, .fw-semibold, .stat-value, .topbar-title, .sidebar-brand {
    font-family: var(--font);
    letter-spacing: -0.02em;
}

/* Crisp number rendering for amounts */
.stat-value, .fw-semibold, td {
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════
   Auth Pages
═══════════════════════════════════════════ */
.auth-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 460px;
}

.auth-card {
    border: none;
    border-radius: 1rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
}

.btn-auth {
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   App Layout
═══════════════════════════════════════════ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: var(--topbar-height);
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.7rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.06);
}

.sidebar-nav li a.active {
    color: #ffffff;
    background: rgba(59, 130, 246, 0.15);
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-nav li a i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-info span {
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info small {
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 1.125rem;
}

.sidebar-toggle { color: #64748b; }

/* ── Page Content ── */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ═══════════════════════════════════════════
   Cards
═══════════════════════════════════════════ */
.card {
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
    background: #ffffff !important;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.875rem 1.25rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    font-weight: 600;
    color: #1e293b;
}

/* ═══════════════════════════════════════════
   Stat Cards
═══════════════════════════════════════════ */
.stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    height: 100%;
}

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

.stat-label {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}

.bg-primary-soft { background: rgba(13,  110, 253, 0.10); }
.bg-success-soft { background: rgba(25,  135,  84, 0.10); }
.bg-warning-soft { background: rgba(255, 193,   7, 0.12); }
.bg-info-soft    { background: rgba(13,  202, 240, 0.10); }
.bg-danger-soft  { background: rgba(220,  53,  69, 0.10); }

/* ═══════════════════════════════════════════
   Welcome Banner
═══════════════════════════════════════════ */
.welcome-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--card-radius);
    padding: 1.5rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.welcome-banner h4 { color: white; margin-bottom: 0.25rem; }
.welcome-banner .text-muted { color: rgba(255,255,255,0.75) !important; }

.welcome-banner .btn {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    color: white;
    font-weight: 600;
}

.welcome-banner .btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.6);
    color: white;
}

/* ═══════════════════════════════════════════
   Empty State
═══════════════════════════════════════════ */
.empty-state {
    text-align: center;
    color: #94a3b8;
}

.empty-state i { opacity: 0.4; }

/* ═══════════════════════════════════════════
   Tables
═══════════════════════════════════════════ */
.table th {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e2e8f0 !important;
}

.table td { vertical-align: middle; }

/* ═══════════════════════════════════════════
   Category Badge
═══════════════════════════════════════════ */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════
   Forms
═══════════════════════════════════════════ */
.form-floating label { color: #64748b; }

/* ═══════════════════════════════════════════
   Topbar Toggle Button
═══════════════════════════════════════════ */
.topbar-toggle {
    color: #1e293b;
    padding: 0.4rem 0.5rem;
    font-size: 1.375rem;
    border-radius: 0.5rem;
    line-height: 1;
    border: none;
    background: transparent;
}
.topbar-toggle:hover,
.topbar-toggle:focus { background: #f1f5f9; color: #1e293b; outline: none; }

.topbar-app-name {
    font-weight: 700;
    font-size: 1rem;
    color: #1e293b;
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════
   Sidebar Overlay
═══════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1039;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ═══════════════════════════════════════════
   Bottom Navigation (hidden by default)
═══════════════════════════════════════════ */
.bottom-nav { display: none; }

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.4rem 0.5rem;
    border-radius: 0.625rem;
    transition: color 0.15s;
    flex: 1;
    min-width: 0;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}
.bottom-nav-item i      { font-size: 1.35rem; line-height: 1; }
.bottom-nav-item.active { color: #6366f1; }
.bottom-nav-item.active i { color: #6366f1; }

.bottom-nav-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff !important;
    border-radius: 50%;
    font-size: 1.5rem;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(99,102,241,0.45);
    flex-shrink: 0;
    transition: transform 0.18s, box-shadow 0.18s;
    margin-bottom: 6px;
}
.bottom-nav-fab:hover,
.bottom-nav-fab:active {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99,102,241,0.55);
    color: #fff !important;
}

/* ═══════════════════════════════════════════
   Responsive — Tablet & Mobile (≤ 991px)
═══════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0,0,0,0.18);
    }
    .main-content   { margin-left: 0; }
    .page-content   { padding-bottom: 76px; }

    /* Bottom nav visible */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 62px;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.07);
        z-index: 1030;
        align-items: center;
        justify-content: space-around;
        padding: 0 0.375rem;
    }
}

/* ═══════════════════════════════════════════
   Responsive — Phones (≤ 767px)
═══════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .page-content { padding: 1rem; padding-bottom: 76px; }
    .topbar       { padding: 0 0.875rem; }

    /* Stat card tighter */
    .stat-card    { padding: 1rem; gap: 0.75rem; }
    .stat-value   { font-size: 1.25rem; }
    .stat-icon    { width: 46px; height: 46px; font-size: 1.2rem; border-radius: 10px; }

    /* Welcome banner */
    .welcome-banner { padding: 1.25rem; }
    .welcome-banner h4 { font-size: 1.125rem; }

    /* Card headers allow wrapping */
    .card-header  { flex-wrap: wrap; }

    /* Table action buttons - compact */
    .table .btn-sm { padding: 0.25rem 0.4rem; }

    /* Profile stat values */
    .profile-stat { padding: 0.75rem 0.25rem; }
    .profile-stat-value { font-size: 1rem; }
}

/* ═══════════════════════════════════════════
   Responsive — Small Phones (≤ 575px)
═══════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .page-content { padding: 0.875rem; padding-bottom: 76px; }

    /* Stat cards — 2 per row auto via Bootstrap, shrink values */
    .stat-value   { font-size: 1.1rem; }
    .stat-icon    { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 9px; }
    .stat-label   { font-size: 0.75rem; }

    /* Welcome banner stacks */
    .welcome-banner { flex-direction: column; align-items: flex-start; }
    .welcome-banner .btn { align-self: stretch; text-align: center; }
    .welcome-banner h4 { font-size: 1rem; }

    /* Analytics period filter wraps */
    .analytics-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.625rem;
    }

    /* Filter form submit full width */
    .filter-submit { width: 100% !important; }

    /* Pagination smaller */
    .page-link { padding: 0.3rem 0.55rem; font-size: 0.8125rem; }

    /* Auth card padding */
    .auth-card .card-body { padding: 1.75rem 1.25rem !important; }

    /* Profile stat value truncate for long amounts */
    .profile-stat-value { font-size: 0.9rem; word-break: break-all; }
}

/* ═══════════════════════════════════════════
   Dashboard — Active Stat Card
═══════════════════════════════════════════ */
.stat-card-active {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.15) !important;
}

/* ═══════════════════════════════════════════
   Category Cards
═══════════════════════════════════════════ */
.cat-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    transition: box-shadow 0.2s;
}

.cat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.cat-icon-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Icon Picker ── */
.icon-picker { display: flex; flex-wrap: wrap; gap: 4px; }

.icon-btn {
    padding: 0.2rem 0.35rem;
    font-size: 1.1rem;
    line-height: 1.2;
    border-color: #e2e8f0 !important;
}

.icon-btn:hover {
    background: #e2e8f0 !important;
    transform: scale(1.15);
}

/* ═══════════════════════════════════════════
   Profile Page
═══════════════════════════════════════════ */
.profile-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-stat {
    text-align: center;
    padding: 1rem 0.5rem;
}

.profile-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}

.profile-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
}

/* ═══════════════════════════════════════════
   Income / Transaction Colors
═══════════════════════════════════════════ */
.text-income { color: #198754 !important; }

.txn-type-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
}
.txn-dot-income  { background: #198754; }
.txn-dot-expense { background: #dc3545; }

.stat-card-surplus { border-left: 3px solid #198754 !important; }
.stat-card-deficit { border-left: 3px solid #dc3545 !important; }

.btn-income-banner {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    color: white;
    font-weight: 600;
}
.btn-income-banner:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.6);
    color: white;
}

/* ── Profile Tabs ── */
.nav-tabs .nav-link {
    color: #64748b;
    border: none;
    padding: 0.875rem 1.25rem;
    font-weight: 500;
}

.nav-tabs .nav-link:hover { color: #1e293b; background: #f8fafc; }

.nav-tabs .nav-link.active {
    color: #0d6efd;
    border-bottom: 2px solid #0d6efd;
    background: transparent;
    font-weight: 600;
}
