/* ============================================================
   SISTEMA FINANCEIRO - JOÃO & TAÍS
   Design moderno mobile-first
   ============================================================ */

:root {
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --shadow: 0 4px 6px -1px rgba(0,0,0,.3), 0 2px 4px -2px rgba(0,0,0,.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.3), 0 4px 6px -4px rgba(0,0,0,.2);
    --radius: 12px;
    --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
}

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

/* === SIDEBAR (Desktop) === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.logo i { color: var(--primary); font-size: 1.5rem; }

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

.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-weight: 600; font-size: .95rem; }
.user-email { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-menu {
    list-style: none;
    padding: 12px 12px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu li { margin: 2px 0; }

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: .92rem;
    font-weight: 500;
    transition: all .15s;
}
.sidebar-menu a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-menu a.active { background: var(--primary); color: white; }
.sidebar-menu a i { font-size: 1.1rem; }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: .92rem;
    transition: all .15s;
}
.logout-btn:hover { background: var(--danger); color: white; }

/* === MOBILE TOPBAR === */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
}
.logo-mini { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.logo-mini i { color: var(--primary); font-size: 1.3rem; }
.avatar-mini {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700;
}

/* === BOTTOM NAV (Mobile) === */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    justify-content: space-around;
    z-index: 90;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 500;
    flex: 1;
    text-align: center;
}
.bottom-nav a i { font-size: 1.4rem; }
.bottom-nav a.active { color: var(--primary); }

/* === MAIN CONTENT === */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 32px;
    min-height: 100vh;
}

/* === PAGE HEADER === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: .95rem; margin-top: 4px; }

/* === CARDS === */
.card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    color: var(--text) !important;
    box-shadow: var(--shadow);
}
.card-body { padding: 20px; }
.card-title { color: var(--text); font-weight: 600; }

/* === STAT CARDS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-label {
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
}
.stat-card .stat-extra {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 6px;
}
.stat-card.entrada { border-left: 4px solid var(--success); }
.stat-card.entrada .stat-value { color: var(--success); }
.stat-card.saida { border-left: 4px solid var(--danger); }
.stat-card.saida .stat-value { color: var(--danger); }
.stat-card.saldo { border-left: 4px solid var(--primary); }
.stat-card.saldo.negativo { border-left-color: var(--danger); }
.stat-card.saldo.negativo .stat-value { color: var(--danger); }
.stat-card.assinaturas { border-left: 4px solid var(--warning); }
.stat-card.assinaturas .stat-value { color: var(--warning); }

/* === BUTTONS === */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline-light { color: var(--text); border-color: var(--border); }

/* === FORMS === */
.form-control, .form-select {
    background: var(--bg) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 .2rem rgba(99,102,241,.25) !important;
    background: var(--bg) !important;
    color: var(--text) !important;
}
.form-label { color: var(--text-muted); font-weight: 500; font-size: .85rem; }

/* === TABLES === */
.table {
    color: var(--text) !important;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-striped-bg: rgba(255,255,255,.02);
    --bs-table-striped-color: var(--text);
    --bs-table-hover-bg: rgba(255,255,255,.04);
    --bs-table-hover-color: var(--text);
    --bs-table-border-color: var(--border);
}
.table thead th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

/* === MODAIS === */
.modal-content {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.btn-close { filter: invert(1) brightness(2); }

/* === BADGES === */
.badge-tipo {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.badge-tipo.fixo { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-tipo.variavel { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-tipo.assinatura { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge-tipo.entrada { background: rgba(16,185,129,.15); color: #34d399; }
.badge-tipo.saida { background: rgba(239,68,68,.15); color: #f87171; }
.badge-tipo.pago { background: rgba(16,185,129,.15); color: #34d399; }
.badge-tipo.pendente { background: rgba(245,158,11,.15); color: #fbbf24; }

.badge-conta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text);
}
.badge-conta::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--cor, var(--text-muted));
}

/* === ASSINATURAS === */
.subscription-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform .15s, box-shadow .15s;
}
.subscription-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.sub-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.sub-info { flex: 1; min-width: 0; }
.sub-name { font-weight: 600; font-size: .95rem; }
.sub-meta { color: var(--text-muted); font-size: .8rem; }
.sub-value { font-weight: 700; font-size: 1.05rem; }

.alert-vencimento {
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.3);
    color: #fca5a5;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: .85rem;
}

/* === LOGIN PAGE === */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
    padding: 20px;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 8px;
}
.login-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}
.login-logo p { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: .3; display: block; margin-bottom: 12px; }

/* === CHARTS === */
.chart-container {
    position: relative;
    height: 280px;
}

/* === RESPONSIVO === */
@media (max-width: 991px) {
    .sidebar { display: none; }
    .mobile-topbar { display: flex; }
    .bottom-nav { display: flex; }
    .main-content {
        margin-left: 0;
        padding: 16px 16px calc(80px + env(safe-area-inset-bottom));
    }
    .page-title { font-size: 1.3rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

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

/* === FAB === */
.fab {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 20px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    border: none;
    box-shadow: 0 8px 16px rgba(99,102,241,.4);
    z-index: 80;
    cursor: pointer;
    transition: transform .15s;
}
.fab:hover { transform: scale(1.05); background: var(--primary-hover); }
@media (min-width: 992px) { .fab { bottom: 24px; } }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
