/* =====================================================================
   Finanças do Casal — Design System moderno
   Camada sobre o Bootstrap 5: glass, gradientes, animações e mobile nativo
   ===================================================================== */

:root {
    --fc-radius: 1rem;
    --fc-radius-sm: .65rem;
    --fc-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -8px rgba(16, 24, 40, .10);
    --fc-shadow-lg: 0 12px 40px -8px rgba(16, 24, 40, .18);
    --fc-ease: cubic-bezier(.22, 1, .36, 1);   /* easeOutQuint — sensação nativa */
    --fc-ease-spring: cubic-bezier(.34, 1.56, .64, 1); /* leve overshoot */
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior-y: none;               /* sem "elástico" de página, como app */
    -webkit-tap-highlight-color: transparent;  /* toque limpo no mobile */
    background:
        radial-gradient(1100px 500px at 85% -10%, rgba(var(--bs-primary-rgb), .10), transparent 60%),
        radial-gradient(900px 420px at -10% 30%, rgba(var(--bs-primary-rgb), .06), transparent 55%),
        var(--bs-tertiary-bg);
    background-attachment: fixed;
}

::selection { background: rgba(var(--bs-primary-rgb), .22); }

/* Scrollbar discreta */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .18); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(0, 0, 0, .3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Navbar (vidro) ---------- */
.navbar-tema {
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 6px 24px -12px rgba(0, 0, 0, .35);
}
.navbar-brand { letter-spacing: .2px; }
.navbar .nav-link {
    border-radius: .6rem;
    padding: .45rem .75rem;
    transition: background-color .2s var(--fc-ease), transform .2s var(--fc-ease);
}
.navbar .nav-link:hover { background: rgba(255, 255, 255, .12); }
[data-bs-theme="light"].navbar .nav-link:hover,
.navbar[data-bs-theme="light"] .nav-link:hover { background: rgba(0, 0, 0, .08); }
.navbar .nav-link.active { background: rgba(255, 255, 255, .18); }
.navbar[data-bs-theme="light"] .nav-link.active { background: rgba(0, 0, 0, .12); }

/* ---------- Cards ---------- */
.card {
    border: 1px solid rgba(16, 24, 40, .06);
    border-radius: var(--fc-radius);
    box-shadow: var(--fc-shadow);
    transition: transform .28s var(--fc-ease), box-shadow .28s var(--fc-ease);
}
@media (hover: hover) {
    .card:hover { transform: translateY(-3px); box-shadow: var(--fc-shadow-lg); }
    .modal .card:hover, .card .card:hover { transform: none; box-shadow: var(--fc-shadow); }
}
.card-header { border-top-left-radius: var(--fc-radius) !important; border-top-right-radius: var(--fc-radius) !important; }

/* Entrada com stagger (JS define --d por elemento) */
.fc-reveal { opacity: 0; transform: translateY(14px); }
.fc-reveal.is-visible {
    animation: fcRise .55s var(--fc-ease) both;
    animation-delay: var(--d, 0ms);
}
@keyframes fcRise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Página entra suave */
main.container { animation: fcPage .45s var(--fc-ease) both; }
@keyframes fcPage {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Botões ---------- */
.btn {
    border-radius: var(--fc-radius-sm);
    font-weight: 500;
    position: relative;
    overflow: hidden;
    transition: transform .18s var(--fc-ease), box-shadow .18s var(--fc-ease),
                background-color .18s, border-color .18s, color .18s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
    background-image: linear-gradient(160deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 55%);
    box-shadow: 0 4px 14px -4px rgba(var(--bs-primary-rgb), .55);
}
.btn-primary:hover { box-shadow: 0 8px 22px -6px rgba(var(--bs-primary-rgb), .65); transform: translateY(-1px); }
.btn-primary:active { transform: scale(.96); }

/* Efeito ripple (span injetado pelo JS) */
.fc-ripple {
    position: absolute; border-radius: 50%; pointer-events: none;
    background: currentColor; opacity: .25; transform: scale(0);
    animation: fcRipple .55s var(--fc-ease) forwards;
}
@keyframes fcRipple { to { transform: scale(2.6); opacity: 0; } }

/* ---------- Formulários ---------- */
.form-control, .form-select, .input-group-text {
    border-radius: var(--fc-radius-sm);
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.form-control:focus, .form-select:focus {
    border-color: rgba(var(--bs-primary-rgb), .55);
    box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .12);
}
.input-group .input-group-text { background: var(--bs-tertiary-bg); }
.input-group:focus-within .input-group-text {
    border-color: rgba(var(--bs-primary-rgb), .55);
    color: rgb(var(--bs-primary-rgb));
}
.form-label { font-weight: 500; font-size: .875rem; }

/* Campo monetário ganha destaque ao digitar */
input[inputmode="decimal"] { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .2px; }

/* ---------- Tabelas ---------- */
.table { --bs-table-hover-bg: rgba(var(--bs-primary-rgb), .045); }
.table > :not(caption) > * > * { padding-top: .65rem; padding-bottom: .65rem; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--bs-secondary-color); font-weight: 600; border-bottom-width: 1px;
}
.table tbody tr { transition: background-color .15s; }

/* ---------- Badges / Progress ---------- */
.badge { font-weight: 600; letter-spacing: .02em; border-radius: 99px; padding: .4em .7em; }
.progress { border-radius: 99px; overflow: hidden; background: rgba(var(--bs-primary-rgb), .10); }
.progress-bar { border-radius: 99px; transition: width 1s var(--fc-ease); position: relative; }
.progress-bar::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
    background-size: 200% 100%; animation: fcShimmer 2.2s linear infinite;
}
@keyframes fcShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Alertas / Modais / Dropdowns ---------- */
.alert { border: 0; border-radius: var(--fc-radius-sm); box-shadow: var(--fc-shadow); animation: fcAlert .4s var(--fc-ease-spring) both; }
@keyframes fcAlert {
    from { opacity: 0; transform: translateY(-12px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.alert.fc-hide { transition: opacity .4s, transform .4s; opacity: 0; transform: translateY(-8px); }

.modal-content { border: 0; border-radius: var(--fc-radius); box-shadow: var(--fc-shadow-lg); }
.modal.fade .modal-dialog { transform: translateY(18px) scale(.97); transition: transform .3s var(--fc-ease); }
.modal.show .modal-dialog { transform: none; }

.dropdown-menu {
    border: 1px solid rgba(16, 24, 40, .07); border-radius: var(--fc-radius-sm);
    box-shadow: var(--fc-shadow-lg); animation: fcDrop .18s var(--fc-ease) both;
}
.dropdown-item { border-radius: .45rem; margin: 0 .25rem; width: auto; transition: background-color .15s; }
@keyframes fcDrop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Skeleton (carregamento) ---------- */
.fc-skeleton {
    background: linear-gradient(90deg, var(--bs-secondary-bg) 25%, var(--bs-tertiary-bg) 50%, var(--bs-secondary-bg) 75%);
    background-size: 200% 100%; animation: fcShimmer 1.4s linear infinite; border-radius: var(--fc-radius-sm);
}

/* =====================================================================
   Mobile-first: o app deve parecer nativo no celular
   ===================================================================== */

@media (max-width: 991.98px) {
    .btn-sm { padding: .35rem .6rem; }
    .form-control, .form-select { min-height: 2.5rem; }
    input.form-control, select.form-select, textarea.form-control { font-size: 16px; } /* sem zoom no iOS */
    .input-group-sm > .form-control, .input-group-sm > .form-select { font-size: 16px; }
    .table { font-size: .85rem; }
    h1.h3 { font-size: 1.25rem; }

    body { padding-bottom: 5.5rem; } /* espaço para a nav inferior */
    main.container { padding-left: .75rem; padding-right: .75rem; }

    .card { border-radius: var(--fc-radius); }
}

/* ---------- Navegação inferior estilo app ---------- */
.nav-mobile {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
    display: flex; justify-content: space-around; align-items: stretch;
    background: color-mix(in srgb, var(--bs-body-bg) 78%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--bs-border-color-translucent);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .08);
    padding-bottom: env(safe-area-inset-bottom); /* iPhone com notch */
}
@supports not (background: color-mix(in srgb, red, blue)) {
    .nav-mobile { background: var(--bs-body-bg); }
}
.nav-mobile a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem;
    padding: .55rem .25rem .5rem; text-decoration: none; position: relative;
    color: var(--bs-secondary-color); font-size: .65rem; font-weight: 500;
    transition: color .2s var(--fc-ease), transform .2s var(--fc-ease);
}
.nav-mobile a i { font-size: 1.3rem; line-height: 1; transition: transform .25s var(--fc-ease-spring); }
.nav-mobile a:active i { transform: scale(.85); }
.nav-mobile a.active { color: rgb(var(--bs-primary-rgb)); }
.nav-mobile a.active i { transform: translateY(-1px); }
.nav-mobile a.active::before {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 2rem; height: 3px; border-radius: 0 0 99px 99px;
    background: rgb(var(--bs-primary-rgb));
    animation: fcNavDot .3s var(--fc-ease-spring) both;
}
@keyframes fcNavDot { from { width: 0; opacity: 0; } to { width: 2rem; opacity: 1; } }

/* Botão central "Nova" em destaque (FAB) */
.nav-mobile a.nav-fab i {
    font-size: 1.6rem; color: rgb(var(--bs-primary-rgb));
    filter: drop-shadow(0 4px 10px rgba(var(--bs-primary-rgb), .45));
    transform: translateY(-4px);
}
.nav-mobile a.nav-fab:active i { transform: translateY(-4px) scale(.88); }

@media (min-width: 992px) {
    .nav-mobile { display: none; }
}

/* ---------- Lista de transações em cards no celular ---------- */
.transacao-card {
    display: flex; align-items: center; gap: .75rem;
    padding: .7rem .85rem; border-bottom: 1px solid var(--bs-border-color-translucent);
    transition: background-color .15s;
}
.transacao-card:active { background: rgba(var(--bs-primary-rgb), .06); }
.transacao-card:last-child { border-bottom: 0; }
.transacao-card .tc-icone {
    width: 2.4rem; height: 2.4rem; flex: 0 0 auto; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.transacao-card .tc-meta { font-size: .72rem; color: var(--bs-secondary-color); }
.min-w-0 { min-width: 0; }
.transacao-card .tc-valor { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Cabeçalhos de página empilham melhor no celular */
@media (max-width: 575.98px) {
    .visao-pills { width: 100%; }
    .visao-pills a { flex: 1; text-align: center; }
}

/* ---------- Tela de login ---------- */
.auth-body {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; padding: 1.5rem 1rem;
    background: linear-gradient(-45deg, #0f172a, #1e3a8a, #312e81, #0f766e);
    background-size: 300% 300%;
    animation: fcGradient 16s ease infinite;
}
@keyframes fcGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.auth-card {
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, .5);
    animation: fcRise .6s var(--fc-ease) both;
}
.auth-icon { display: inline-block; animation: fcFloat 3.5s ease-in-out infinite; }
@keyframes fcFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ---------- Acessibilidade: respeita quem prefere menos movimento ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    html { scroll-behavior: auto; }
    .fc-reveal { opacity: 1; transform: none; }
}
