/* ============================================================
   Family Budget — Tema custom (Bootstrap 5.3 compatibile)
   ============================================================ */

/* Alpine.js — nasconde gli elementi con x-cloak finché Alpine non inizializza */
[x-cloak] { display: none !important; }

:root {
    --fb-primary:   #6366f1;   /* indaco moderno */
    --fb-primary-2: #8b5cf6;   /* viola soft per gradient */
    --fb-success:   #10b981;
    --fb-danger:    #ef4444;
    --fb-warning:   #f59e0b;
    --fb-ink:       #0f172a;
    --fb-muted:     #64748b;
    --fb-surface:   #ffffff;
    --fb-surface-2: #f8fafc;
    --fb-border:    #e2e8f0;
    --fb-radius:    14px;
    --fb-shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --fb-shadow:    0 10px 30px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.05);
    --fb-shadow-lg: 0 25px 60px rgba(15,23,42,.12), 0 10px 25px rgba(15,23,42,.08);
}

/* Bootstrap overrides */
:root, [data-bs-theme="light"] {
    --bs-primary: var(--fb-primary);
    --bs-primary-rgb: 99, 102, 241;
    --bs-success: var(--fb-success);
    --bs-danger:  var(--fb-danger);
    --bs-warning: var(--fb-warning);
    --bs-body-bg: var(--fb-surface-2);
    --bs-body-color: var(--fb-ink);
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
    --bs-border-color: var(--fb-border);
}

[data-bs-theme="dark"] {
    --fb-ink: #e2e8f0;
    --fb-muted: #94a3b8;
    --fb-surface: #0f172a;
    --fb-surface-2: #020617;
    --fb-border: #1e293b;
    --bs-body-bg: var(--fb-surface-2);
    --bs-body-color: var(--fb-ink);
    --bs-border-color: var(--fb-border);
}

/* ─── Base ────────────────────────────────────────────────── */
.fb-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}
.fb-main { flex: 1; }

h1, h2, h3, h4, .fb-display, .fb-logo-text {
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ─── Bottom Nav (PWA) ────────────────────────────────────── */
.fb-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom));
    background: rgba(var(--bs-body-bg-rgb), 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--fb-border);
    z-index: 1030;
    padding-bottom: env(safe-area-inset-bottom);
}

.fb-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--fb-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    gap: 2px;
}

.fb-bottom-nav-item.active {
    color: var(--fb-primary);
}

.fb-bottom-nav-item i {
    font-size: 1.4rem;
}

/* FAB Rialzato */
.fb-fab-center {
    position: absolute;
    left: 50%;
    top: -24px;
    transform: translateX(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--fb-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.4);
    border: 4px solid var(--bs-body-bg);
}

.fb-fab-center:active {
    transform: translateX(-50%) scale(0.95);
}

@media (max-width: 991.98px) {
    .fb-bottom-nav { display: flex; }
    .fb-footer { padding-bottom: calc(85px + env(safe-area-inset-bottom)); }
    .fb-main { padding-bottom: 2rem; }
}

.btn {
    border-radius: 10px;
    font-weight: 500;
    transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background-image: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-2));
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99,102,241,.25);
}
.btn-primary:hover, .btn-primary:focus {
    background-image: linear-gradient(135deg, #5457e8, #7e48ef);
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(99,102,241,.35);
}

/* ─── Flash messages (posizione fissa in alto) ────────────── */
.fb-flash {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1080;
    min-width: 320px;
    max-width: 560px;
    border: none;
    border-radius: 12px;
}

/* ─── Navbar ──────────────────────────────────────────────── */
.fb-navbar {
    background: rgba(255,255,255,.8);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--fb-border);
}
[data-bs-theme="dark"] .fb-navbar { background: rgba(15,23,42,.75); }

/* ─── Swipe-to-delete UI ──────────────────────────────────── */
.fb-swipe-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--fb-radius);
    margin-bottom: 1rem;
}
.fb-swipe-item {
    position: relative;
    z-index: 2;
    background: var(--fb-surface);
    transition: transform 0.3s ease;
}
.fb-swipe-actions {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: var(--fb-danger);
    color: #fff;
    padding-right: 1.5rem;
    font-size: 1.5rem;
}

/* ─── Logo ────────────────────────────────────────────────── */
.fb-logo-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-2));
    box-shadow: 0 2px 6px rgba(99,102,241,.4);
}
.fb-logo-text {
    font-weight: 800;
}

/* ─── Hero ────────────────────────────────────────────────── */
.fb-hero {
    padding: 5rem 0 4rem;
    background:
        radial-gradient(ellipse at top left,  rgba(99,102,241,.10), transparent 60%),
        radial-gradient(ellipse at top right, rgba(139,92,246,.08), transparent 55%);
    position: relative;
    overflow: hidden;
}
.fb-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(99,102,241,.1);
    color: var(--fb-primary);
    padding: .35rem .8rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}
.fb-hero-title {
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    background: linear-gradient(180deg, var(--fb-ink), #334155);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
[data-bs-theme="dark"] .fb-hero-title {
    background: linear-gradient(180deg, #f1f5f9, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.fb-hero-subtitle {
    font-size: 1.15rem;
    color: var(--fb-muted);
    max-width: 54ch;
}

/* Card "mockup" nel hero */
.fb-hero-card {
    background: var(--fb-surface);
    border-radius: var(--fb-radius);
    padding: 1.5rem;
    border: 1px solid var(--fb-border);
    position: relative;
}
.fb-hero-card::before {
    content: '';
    position: absolute;
    inset: -20px;
    background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(139,92,246,.15));
    border-radius: 24px;
    z-index: -1;
    filter: blur(20px);
}
.fb-stat {
    background: var(--fb-surface-2);
    border-radius: 10px;
    padding: .75rem 1rem;
}
.fb-stat-label { font-size: .78rem; color: var(--fb-muted); }
.fb-stat-value { font-size: 1.35rem; font-weight: 700; font-family: 'Plus Jakarta Sans', sans-serif; }
.fb-badge-soft {
    background: rgba(99,102,241,.1);
    color: var(--fb-primary);
    font-weight: 600;
}

/* ─── Features ────────────────────────────────────────────── */
.fb-features { padding: 4rem 0 5rem; }
.fb-section-title {
    font-size: clamp(1.6rem, 2.5vw, 2.2rem);
    font-weight: 700;
    text-align: center;
}
.fb-feature-card {
    background: var(--fb-surface);
    border: 1px solid var(--fb-border);
    border-radius: var(--fb-radius);
    padding: 1.75rem 1.5rem;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.fb-feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--fb-shadow);
    border-color: transparent;
}
.fb-feature-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(139,92,246,.12));
    color: var(--fb-primary);
    font-size: 1.3rem;
}

/* ─── Footer ──────────────────────────────────────────────── */
.fb-footer {
    padding: 1.5rem 0;
    border-top: 1px solid var(--fb-border);
    background: var(--fb-surface);
}

/* ─── Errori ──────────────────────────────────────────────── */
.fb-error { padding: 6rem 0; }
.fb-error-code {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: clamp(5rem, 12vw, 9rem);
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ─── Utility ─────────────────────────────────────────────── */
.card {
    border-color: var(--fb-border);
    border-radius: var(--fb-radius);
}
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--fb-border);
    padding: .6rem .85rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--fb-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.input-group-lg > .form-control,
.input-group-lg > .input-group-text,
.input-group-lg > .btn {
    border-radius: 10px;
    font-size: 1rem;
}
.input-group-lg > .form-control { padding: .75rem .85rem; }
.input-group-lg > .input-group-text {
    background: var(--fb-surface);
    color: var(--fb-muted);
    border-color: var(--fb-border);
}
.form-check-input:checked {
    background-color: var(--fb-primary);
    border-color: var(--fb-primary);
}
.form-check-input:focus {
    border-color: var(--fb-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* Bottone primario con gradient (CTA) */
.btn-primary,
.btn-primary:focus {
    background: var(--fb-primary);
    border-color: var(--fb-primary);
    box-shadow: 0 6px 16px -6px rgba(99,102,241,.55);
}
.btn-primary:hover {
    background: #4f52e9;
    border-color: #4f52e9;
}
.fb-btn-gradient {
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-2)) !important;
    border: 0 !important;
    color: #fff !important;
    box-shadow: 0 10px 25px -8px rgba(99,102,241,.55);
    transition: transform .15s ease, box-shadow .15s ease;
}
.fb-btn-gradient:hover,
.fb-btn-gradient:focus {
    transform: translateY(-1px);
    color: #fff !important;
    box-shadow: 0 14px 30px -8px rgba(99,102,241,.65);
}
.fb-btn-gradient:active { transform: translateY(0); }

.fb-link-disabled {
    pointer-events: none;
    opacity: .55;
}
.link-muted { color: var(--fb-muted); text-decoration: none; }
.link-muted:hover { color: var(--fb-primary); }

/* ─── Avatar ──────────────────────────────────────────────── */
.fb-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-2));
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: .02em;
    box-shadow: 0 4px 12px -4px rgba(99,102,241,.55);
}

/* ─── Auth layout ─────────────────────────────────────────── */
.fb-auth-body {
    background: linear-gradient(160deg, #eef2ff 0%, #faf5ff 50%, #f8fafc 100%);
    min-height: 100vh;
    min-height: 100dvh;
}
[data-bs-theme="dark"] .fb-auth-body {
    background: linear-gradient(160deg, #0b1020 0%, #0f172a 60%, #020617 100%);
}

.fb-auth-shell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
    overflow: hidden;
}

.fb-auth-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.fb-auth-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .45;
}
.fb-auth-blob--1 {
    width: 420px; height: 420px;
    background: radial-gradient(circle at center, var(--fb-primary), transparent 70%);
    top: -120px; right: -80px;
}
.fb-auth-blob--2 {
    width: 520px; height: 520px;
    background: radial-gradient(circle at center, var(--fb-primary-2), transparent 70%);
    bottom: -200px; left: -140px;
}

.fb-auth-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.fb-auth-brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    text-decoration: none;
    color: var(--fb-ink);
    align-self: center;
    font-weight: 700;
}
.fb-auth-brand .fb-logo-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    letter-spacing: -.01em;
}

.fb-auth-card {
    background: var(--fb-surface);
    border: 1px solid var(--fb-border);
    border-radius: 20px;
    padding: 1.75rem 1.5rem;
    box-shadow: var(--fb-shadow-lg);
}
@media (min-width: 480px) {
    .fb-auth-card { padding: 2.25rem 2rem; }
}

.fb-auth-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 1.65rem;
    letter-spacing: -.02em;
    margin-bottom: .35rem;
}
.fb-auth-sub { color: var(--fb-muted); margin-bottom: 0; font-size: .95rem; }

.fb-auth-form label { font-weight: 600; font-size: .9rem; }

.fb-auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--fb-muted);
    font-size: .8rem;
    margin: 1.5rem 0 1rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.fb-auth-divider::before,
.fb-auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--fb-border);
}
.fb-auth-divider span { padding: 0 .75rem; }

.fb-auth-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 0 .25rem;
    flex-wrap: wrap;
}

/* ─── Dashboard ───────────────────────────────────────────── */
.fb-stat-card {
    background: var(--fb-surface);
    border: 1px solid var(--fb-border);
    border-radius: var(--fb-radius);
    padding: 1.25rem;
    box-shadow: var(--fb-shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}
.fb-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--fb-shadow);
}
.fb-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1.25rem;
    margin-bottom: .75rem;
}
.fb-stat-label { font-size: .85rem; color: var(--fb-muted); margin-bottom: .25rem; }
.fb-stat-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.fb-bg-soft-primary { background: rgba(99,102,241,.12); color: var(--fb-primary); }
.fb-bg-soft-success { background: rgba(16,185,129,.14); color: var(--fb-success); }
.fb-bg-soft-warning { background: rgba(245,158,11,.16); color: var(--fb-warning); }
.fb-bg-soft-info    { background: rgba(14,165,233,.14); color: #0ea5e9; }

.fb-empty-state {
    background: var(--fb-surface);
    border: 1px dashed var(--fb-border);
    border-radius: var(--fb-radius);
    padding: 2.5rem 1.5rem;
}
.fb-empty-icon {
    font-size: 2.5rem;
    color: var(--fb-muted);
    margin-bottom: .75rem;
}

/* ─── Mobile touch targets ───────────────────────────────── */
@media (max-width: 575.98px) {
    .btn-lg { min-height: 48px; }
    .form-control, .input-group-lg > .form-control { min-height: 48px; }
    .fb-auth-title { font-size: 1.5rem; }
    .fb-flash {
        left: 12px;
        right: 12px;
        max-width: none;
    }
}
