/* AgentFin — tema "Neo-Tactile" (vidro fosco escuro, azul + brilho ciano) */

:root {
    --bg: #0b0f17;
    --bg-2: #121826;
    --glass: rgba(255, 255, 255, 0.06);
    --glass-strong: rgba(255, 255, 255, 0.10);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text: #e8edf7;
    --text-soft: #9aa6bd;
    --accent: #3d7bff;
    --accent-2: #2ee6f2;
    --income: #34d399;
    --expense: #ff7a6b;
    --radius: 22px;
    --radius-sm: 14px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    --glow: 0 0 0 1px rgba(46, 230, 242, 0.35), 0 0 24px rgba(46, 230, 242, 0.35);

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-primary: var(--accent);
    --bs-primary-rgb: 61, 123, 255;
    --bs-border-radius: var(--radius-sm);
}

* { -webkit-tap-highlight-color: transparent; }

body.app {
    min-height: 100vh;
    background: radial-gradient(120% 80% at 10% 0%, #1a2340 0%, var(--bg) 55%) fixed, var(--bg);
    color: var(--text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

/* Manchas de luz no fundo, que dão profundidade ao vidro */
.bg-orbs {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(320px 320px at 85% 15%, rgba(61, 123, 255, 0.25), transparent 70%),
        radial-gradient(280px 280px at 10% 80%, rgba(46, 230, 242, 0.14), transparent 70%);
}

.text-soft    { color: var(--text-soft) !important; }
.text-accent  { color: var(--accent-2) !important; }
.text-income  { color: var(--income) !important; }
.text-expense { color: var(--expense) !important; }

/* ---------- Vidro ---------- */
.glass-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    transition: transform .18s ease, box-shadow .18s ease;
}

@media (hover: hover) {
    .glass-card:hover { transform: translateY(-2px); }
}

.glass-alert {
    border-radius: var(--radius-sm);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.glass-input,
.glass-input:focus {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
}

.glass-input:focus {
    border-color: var(--accent-2);
    box-shadow: var(--glow);
}

/* ---------- Botões em pílula ---------- */
.btn-pill {
    border-radius: 999px;
    padding: .75rem 1.4rem;
    font-weight: 600;
    transition: transform .15s ease, box-shadow .15s ease;
}

.btn-pill:active { transform: scale(.98); }

.btn-primary.btn-pill {
    background: linear-gradient(135deg, #4d8bff, var(--accent));
    border: 0;
    box-shadow: 0 10px 24px rgba(61, 123, 255, 0.4);
}

.btn-primary.btn-pill:hover { box-shadow: 0 12px 30px rgba(61, 123, 255, 0.55); }

.btn-glass {
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    color: var(--text);
}

.btn-glass:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); }

/* ---------- Login ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem 1rem;
}

.auth-card { width: 100%; max-width: 380px; padding: 2rem 1.6rem; }

/* ---------- Topo ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(1rem + env(safe-area-inset-top)) 1rem 1rem;
    max-width: 720px;
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    letter-spacing: .2px;
}

.brand-lg { font-size: 1.6rem; }

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-2);
    box-shadow: var(--glow);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #06101f;
}

.avatar-lg { width: 52px; height: 52px; font-size: 1.3rem; }

.container-app { max-width: 720px; margin: 0 auto; padding: 0 1rem; }

/* ---------- Dashboard ---------- */
.hero-card { padding: 1.4rem 1.3rem; }

.hero-value {
    font-size: clamp(2rem, 8vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -.5px;
    font-variant-numeric: tabular-nums;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .8rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    position: relative;
}

.stat strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat-wide { grid-column: 1 / -1; }

.stat-icon {
    position: absolute;
    top: 1rem;
    right: 1.1rem;
    font-size: 1.1rem;
}

.empty-state {
    display: flex;
    align-items: center;
    gap: .9rem;
    color: var(--text-soft);
}

.empty-state i { font-size: 1.4rem; color: var(--accent-2); }

/* ---------- Navegação inferior ---------- */
.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(680px, calc(100% - 24px));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: .45rem;
    border-radius: 26px;
    background: rgba(18, 24, 38, 0.72);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    z-index: 1030;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .45rem 0;
    border-radius: 18px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: .72rem;
}

.nav-item i { font-size: 1.25rem; }

.nav-item.active {
    color: var(--text);
    background: rgba(61, 123, 255, 0.18);
}

.nav-item.active i { color: var(--accent-2); }
.nav-item.is-disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Botão "+" flutuante ---------- */
.fab {
    position: fixed;
    right: max(18px, calc(50% - 340px));
    bottom: calc(96px + env(safe-area-inset-bottom));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    color: #fff;
    background: linear-gradient(135deg, #4d8bff, var(--accent));
    box-shadow: 0 12px 28px rgba(61, 123, 255, 0.5), var(--glow);
    text-decoration: none;
    z-index: 1031;
}

.fab.is-disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Fase 2: lançamentos ---------- */
.link-accent { color: var(--accent-2); text-decoration: none; }

.btn-back {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text);
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    text-decoration: none;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.month-nav a {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    text-decoration: none;
}

/* Filtros em "pílulas" com rolagem horizontal no celular */
.chips {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    padding: .4rem .9rem;
    border-radius: 999px;
    font-size: .85rem;
    color: var(--text-soft);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    text-decoration: none;
}

.chip.active {
    color: var(--text);
    background: rgba(61, 123, 255, 0.25);
    border-color: rgba(61, 123, 255, 0.6);
}

.chip-sep { flex: 0 0 1px; background: var(--glass-border); margin: .2rem .1rem; }

/* Lista de lançamentos */
.tx-list { list-style: none; margin: 0; padding: .3rem .4rem; }
.tx-list:hover { transform: none; }

.tx-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tx-item:last-child { border-bottom: 0; }

.tx-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--text);
    text-decoration: none;
}

.tx-icon {
    flex: 0 0 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
}

.tx-icon.is-expense { background: rgba(255, 122, 107, 0.14); color: var(--expense); }
.tx-icon.is-income  { background: rgba(52, 211, 153, 0.14); color: var(--income); }

.tx-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.tx-title,
.tx-meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-title { font-weight: 600; }
.tx-meta  { font-size: .78rem; color: var(--text-soft); }

.tx-amount {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.badge-previsto {
    margin-top: .15rem;
    padding: .05rem .5rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 600;
    color: var(--accent-2);
    background: rgba(46, 230, 242, 0.12);
}

.tx-pay .btn { padding: .3rem .7rem; font-size: .78rem; }

/* Formulário */
.form-card:hover { transform: none; }

.segmented {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    gap: .3rem;
    padding: .3rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
}

.segmented-option {
    text-align: center;
    padding: .55rem .5rem;
    border-radius: 999px;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.segmented-sm .segmented-option { padding: .45rem .3rem; font-size: .85rem; }

.btn-check:checked + .segmented-option {
    color: #fff;
    background: linear-gradient(135deg, #4d8bff, var(--accent));
    box-shadow: 0 6px 16px rgba(61, 123, 255, 0.35);
}

.btn-check:checked + .segmented-option.is-despesa { background: linear-gradient(135deg, #ff8f7f, #f0604f); box-shadow: 0 6px 16px rgba(240, 96, 79, 0.35); }
.btn-check:checked + .segmented-option.is-receita { background: linear-gradient(135deg, #45e0a8, #1fb985); box-shadow: 0 6px 16px rgba(31, 185, 133, 0.35); }
.btn-check:focus-visible + .segmented-option { box-shadow: var(--glow); }

.input-money { position: relative; }

.input-money span {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-soft);
    font-weight: 600;
}

.amount-input {
    padding-left: 3rem !important;
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.form-select.glass-input option { background: var(--bg-2); color: var(--text); }
input[type="date"].glass-input { color-scheme: dark; }

/* ---------- Fase 3: recibos ---------- */
.receipt-box { display: flex; flex-direction: column; gap: .6rem; }

.receipt-preview {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .6rem;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
}

.receipt-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

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

.receipt-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    padding: .75rem;
    border-radius: 999px;
    color: var(--accent-2);
    background: rgba(46, 230, 242, 0.08);
    border: 1px solid rgba(46, 230, 242, 0.3);
}

.receipt-loading.d-none { display: none !important; }

.ring {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(46, 230, 242, 0.25);
    border-top-color: var(--accent-2);
    box-shadow: 0 0 12px rgba(46, 230, 242, 0.5);
    animation: spin .8s linear infinite;
}

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

/* Campos preenchidos pela IA ganham brilho ciano até o usuário conferir */
.ai-filled { border-color: var(--accent-2) !important; box-shadow: var(--glow); }

.tx-meta .bi-receipt { color: var(--accent-2); }

/* ---------- Fase 4: fixos ---------- */
.tx-item.is-inactive { opacity: .5; }
.tx-meta .bi-arrow-repeat { color: var(--accent-2); }
.amount-sm { font-size: 1.15rem; }
.due { font-weight: 600; color: var(--text-soft); }
.due.is-today { color: #ffc861; }
.due.is-late { color: var(--expense); }
input[type="month"].glass-input { color-scheme: dark; }

/* ---------- Fase 5: dashboard ---------- */
.xsmall { font-size: .75rem; }
.stat { min-width: 0; }
.chart-card:hover { transform: none; }
.chart-box { position: relative; width: 100%; }

.chart-legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--text-soft); }
.chart-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-income  { background: #00a888; }
.swatch-expense { background: #e76624; }

.chart-table { margin-top: .6rem; font-size: .85rem; }
.chart-table summary { color: var(--accent-2); cursor: pointer; font-size: .8rem; }
.chart-table .table { --bs-table-bg: transparent; margin-top: .4rem; }
.chart-table td, .chart-table th { border-color: rgba(255, 255, 255, 0.06); font-variant-numeric: tabular-nums; }
.stat > .small:first-of-type { padding-right: 1.6rem; }
