/* ============================================================
   Finance Dashboard – App CSS
   ============================================================ */

/* --- Variables --- */
:root {
    --sidebar-bg:      #0f172a;
    --sidebar-width:   260px;
    --sidebar-text:    rgba(255,255,255,0.75);
    --sidebar-active:  #6366f1;
    --body-bg:         #f8fafc;
    --card-bg:         #ffffff;
    --card-radius:     12px;
    --card-shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);

    --primary:   #6366f1;
    --success:   #22c55e;
    --danger:    #ef4444;
    --warning:   #f59e0b;
    --info:      #3b82f6;

    --text-main:   #1e293b;
    --text-muted:  #64748b;
    --border:      #e2e8f0;

    --navbar-height: 64px;
    --font-main:     'Inter', -apple-system, sans-serif;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-main);
    font-size: 0.9rem;
    color: var(--text-main);
    background: var(--body-bg);
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Layout
   ============================================================ */

.app-wrapper {
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform .3s ease;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: var(--navbar-height);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.3px;
}

.sidebar-logo .fa-wallet {
    font-size: 1.3rem;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background .2s, color .2s;
    margin-bottom: 2px;
}

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

.sidebar-nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-nav-item.active {
    background: var(--primary);
    color: #fff;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-username {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-role {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
    transition: margin-left .3s ease;
    overflow-x: hidden;
}

/* --- Top Navbar --- */
.top-navbar {
    height: var(--navbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

/* --- Content Area --- */
.content-area {
    /* padding handled by inner container-fluid */
}

/* ============================================================
   Mobile Responsive
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
}


/* ============================================================
   Components
   ============================================================ */

/* --- Cards --- */
.card-panel {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.card-panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
}

.card-panel-body {
    padding: 20px;
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

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

.stat-card-income .stat-card-icon  { background: rgba(34,197,94,.12);  color: var(--success); }
.stat-card-expense .stat-card-icon { background: rgba(239,68,68,.12);  color: var(--danger);  }
.stat-card-balance .stat-card-icon { background: rgba(99,102,241,.12); color: var(--primary); }
.stat-card-warning .stat-card-icon { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-card-danger .stat-card-icon  { background: rgba(239,68,68,.15);  color: var(--danger);  }

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-change {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* --- Info Cards --- */
.info-card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    padding: 16px 20px;
}

.info-card-label {
    font-size: 0.775rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.info-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

/* --- Avatar --- */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    user-select: none;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.7rem;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    font-size: 1.5rem;
}

/* --- Tables --- */
.data-table {
    margin: 0;
    font-size: 0.875rem;
}

.data-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--body-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

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

.table-danger-light td  { background: rgba(239,68,68,.04) !important; }
.table-warning-light td { background: rgba(245,158,11,.04) !important; }

/* --- Badges --- */
.badge-cat {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.775rem;
    font-weight: 500;
}

.bg-primary-soft   { background: rgba(99,102,241,.12)  !important; }
.bg-success-soft   { background: rgba(34,197,94,.12)   !important; }
.bg-danger-soft    { background: rgba(239,68,68,.12)   !important; }
.bg-warning-soft   { background: rgba(245,158,11,.12)  !important; }
.bg-secondary-soft { background: rgba(100,116,139,.12) !important; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }

/* --- Buttons --- */
.btn-icon {
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    transition: background .2s, color .2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-icon:hover {
    background: var(--body-bg);
    color: var(--text-main);
}

.btn-icon-sm {
    padding: 4px 8px;
    font-size: 0.78rem;
    border-radius: 6px;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Transaction List --- */
.transaction-list {
    padding: 0;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    transition: background .15s;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item:hover {
    background: #f8fafc;
}

.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

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

.transaction-title {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-meta {
    font-size: 0.775rem;
    color: var(--text-muted);
}

.transaction-amount {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* --- Pie Chart Legend --- */
.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}

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

.pie-legend-label {
    flex: 1;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pie-legend-val {
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
}

/* --- Toast --- */
.app-toast {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
    min-width: 280px;
    max-width: 380px;
}

/* --- Category Chips (Settings) --- */
.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid currentColor;
    font-size: 0.8rem;
    background: #fff;
}

.btn-chip-del {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: color .15s;
}

.btn-chip-del:hover { color: var(--danger); }

/* --- Color Preset Buttons --- */
.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0,0,0,.2);
    transition: transform .15s;
}

.color-preset:hover {
    transform: scale(1.2);
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(99,102,241,.35);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.btn-login {
    height: 44px;
    font-weight: 600;
    border-radius: 10px;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-content {
    border-radius: 14px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 14px 20px;
}

.modal-body {
    padding: 20px;
}

/* ============================================================
   Forms
   ============================================================ */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.875rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-control {
    padding: 8px 12px;
}

.form-select {
    padding: 8px 2.25rem 8px 12px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.input-group-text {
    border-radius: 8px;
    border-color: var(--border);
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > .input-group-text:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 16px;
    transition: all .2s;
}

.btn-primary   { background: var(--primary);  border-color: var(--primary);  }
.btn-success   { background: var(--success);  border-color: var(--success);  }
.btn-danger    { background: var(--danger);   border-color: var(--danger);   }
.btn-warning   { background: var(--warning);  border-color: var(--warning); color: #fff; }

.btn-primary:hover  { background: #4f52e0; border-color: #4f52e0; }
.btn-success:hover  { background: #16a34a; border-color: #16a34a; }
.btn-danger:hover   { background: #dc2626; border-color: #dc2626; }
.btn-warning:hover  { background: #d97706; border-color: #d97706; }

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-success { color: var(--success); border-color: var(--success); }
.btn-outline-success:hover { background: var(--success); color: #fff; }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 0.815rem; }

/* ============================================================
   Utilities
   ============================================================ */
.fw-semibold { font-weight: 600; }

.text-nowrap { white-space: nowrap; }

/* Dropdown */
.dropdown-menu {
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    border: 1px solid var(--border);
    padding: 6px;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-main);
}

.dropdown-item:hover {
    background: var(--body-bg);
}

/* Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Chart canvas */
canvas {
    display: block;
}

/* Table responsive fixes */
.table-responsive {
    border-radius: 0;
}

/* Toolbar filter row — horizontally scrollable on mobile */
@media (max-width: 575.98px) {
    .filter-toolbar {
        flex-direction: column;
        align-items: stretch !important;
    }
    .filter-toolbar .d-flex {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
}

/* Sidebar toggle button */
.sidebar-close,
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close {
    color: rgba(255,255,255,0.75);
}

.sidebar-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

body.sidebar-open {
    overflow: hidden;
}

/* ── Shared Account ─────────────────────────────────────────────────── */

.shared-member-card {
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}

.shared-split-bar-wrap {
    background: var(--border);
    border-radius: 4px;
    height: 5px;
    margin: 6px 0 2px;
    overflow: hidden;
}

.shared-split-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width .3s;
}

.shared-split-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.shared-split-row {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.shared-split-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shared-split-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.avatar-xs {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.6rem !important;
    flex-shrink: 0;
}
