/* ===== Evo Dingee Tracker – app styles + color tokens (light & dark) ===== */

/* ---------- Tokens: light ---------- */
html:root {
    --mud-typography-default-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-h1-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-h2-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-h3-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-h4-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-h5-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-h6-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-subtitle1-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-subtitle2-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-body1-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-body2-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-button-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-caption-family: 'Figtree', 'Segoe UI', system-ui, sans-serif;
    --mud-typography-button-text-transform: none;

    /* Brand */
    --evo-navy: #12355B;
    --evo-lagoon: #0B7A75;          /* filled backgrounds */
    --evo-accent: #0B7A75;          /* text, icons, focus rings */
    --evo-income: #1F8A4C;
    --evo-expense: #C8453B;
    --evo-unpaid: #C98A12;

    /* Surfaces & text */
    --evo-bg: #F1F6F6;
    --evo-surface: #FFFFFF;
    --evo-surface-hover: #F6FAFA;
    --evo-surface-muted: #FAFCFC;
    --evo-border: #DCE6E8;
    --evo-border-strong: #B9CCD0;
    --evo-text: #12355B;
    --evo-muted: #526577;
    --evo-faint: #A7B4BF;
    --evo-strong: #12355B;          /* dark fills: today, active filter, owed card */
    --evo-lagoon-soft: #D7EFEC;
    --evo-chip-base: #FFFFFF;

    /* Status tints */
    --evo-income-soft: #E3F3E9;
    --evo-expense-soft: #FBE8E6;
    --evo-unpaid-soft: #FDF1D8;
    --evo-unpaid-ink: #8A5E00;
    --evo-unpaid-line: #F0D48E;
    --evo-invited-soft: #E2EEF8;
    --evo-invited-ink: #1F5F92;
    --evo-seg-bg: #EEF3F4;
    --evo-warn-box: #FDF6E5;
    --evo-warn-line: #F0DDA8;
    --evo-ok-box: #EAF6EF;
    --evo-ok-line: #BFE2CC;
}

/* ---------- Tokens: dark ---------- */
html.evo-dark {
    color-scheme: dark;

    --evo-accent: #34B8AE;
    --evo-income: #4CC38A;
    --evo-expense: #F07167;
    --evo-unpaid: #E6B450;

    --evo-bg: #0E1720;
    --evo-surface: #16222E;
    --evo-surface-hover: #1C2A38;
    --evo-surface-muted: #121D27;
    --evo-border: #263645;
    --evo-border-strong: #3A5063;
    --evo-text: #E4EDF2;
    --evo-muted: #9AAEBD;
    --evo-faint: #5E7283;
    --evo-strong: #23476E;
    --evo-lagoon-soft: #12403E;
    --evo-chip-base: #16222E;

    --evo-income-soft: #173A2A;
    --evo-expense-soft: #402222;
    --evo-unpaid-soft: #3A2F14;
    --evo-unpaid-ink: #F0C66B;
    --evo-unpaid-line: #5A4718;
    --evo-invited-soft: #16304A;
    --evo-invited-ink: #8CC4F0;
    --evo-seg-bg: #0F1A24;
    --evo-warn-box: #2E2614;
    --evo-warn-line: #4D3F1C;
    --evo-ok-box: #15301F;
    --evo-ok-line: #245237;

    /* Keep MudBlazor surfaces in sync, including on the static account pages */
    --mud-palette-background: #0E1720;
    --mud-palette-surface: #16222E;
    --mud-palette-text-primary: #E4EDF2;
    --mud-palette-text-secondary: #9AAEBD;
    --mud-palette-lines-default: #263645;
    --mud-palette-appbar-background: #0C1C2E;
}

body {
    font-family: var(--mud-typography-default-family);
    background: var(--evo-bg);
    color: var(--evo-text);
}

/* ---------- App bar ---------- */
.evo-appbar { padding-top: env(safe-area-inset-top, 0px); }

.evo-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.evo-topnav { margin-left: 32px; gap: 4px; }

.evo-topnav a {
    color: rgba(255, 255, 255, .72);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
}

.evo-topnav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.evo-topnav a.active { color: #fff; background: rgba(255, 255, 255, .14); }
.evo-user { font-weight: 500; margin-right: 4px; opacity: .9; }

/* ---------- Main content ---------- */
.evo-main {
    background: var(--evo-bg);
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));   /* room for the bottom nav */
}

.evo-container { padding-top: 20px; padding-bottom: 24px; }

.evo-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 16px;
}

.evo-title { font-weight: 800 !important; letter-spacing: -0.02em; }

/* ---------- Active trips hero ---------- */
.evo-active-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: var(--evo-lagoon) !important;
    color: #fff !important;
    border-radius: 14px !important;
}

.evo-active-icon { font-size: 2.4rem !important; opacity: .85; }
.evo-active-number { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.evo-active-label { font-size: .95rem; opacity: .9; margin-top: 4px; }

/* ---------- Budget stats ---------- */
.evo-stat {
    padding: 14px 16px;
    border: 1px solid var(--evo-border);
    height: 100%;
}

.evo-stat-label { font-size: .85rem; color: var(--evo-muted); font-weight: 500; }
.evo-stat-value { font-size: 1.45rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

.text-income { color: var(--evo-income); }
.text-expense { color: var(--evo-expense); }
.text-unpaid { color: var(--evo-unpaid); }

/* ---------- Mobile bottom navigation ---------- */
.evo-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1300;
    display: flex;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--evo-surface);
    border-top: 1px solid var(--evo-border);
}

.evo-bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--evo-muted);
    text-decoration: none;
    font-size: .78rem;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.evo-bottomnav a.active { color: var(--evo-accent); }

.evo-bottomnav a.active .mud-icon-root {
    background: var(--evo-lagoon-soft);
    border-radius: 16px;
    padding: 2px 16px;
    width: auto;
    box-sizing: content-box;
}

/* ---------- Desktop / mobile switching (MudBlazor md = 960px) ---------- */
.desktop-only { display: none !important; }

@media (min-width: 960px) {
    .desktop-only { display: flex !important; }
    .evo-bottomnav { display: none; }
    .evo-main { padding-bottom: 0; }
    .evo-container { padding-top: 32px; }
}

/* ---------- Admin: invites ---------- */
.evo-invite-add {
    padding: 16px;
    border: 1px solid var(--evo-border);
}

.evo-invite-add-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.evo-invite-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--evo-surface);
    border: 1px solid var(--evo-border);
    border-radius: 10px;
}

.evo-invite-main { flex: 1; min-width: 0; }
.evo-invite-email { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.evo-invite-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 4px;
    font-size: .82rem;
    color: var(--evo-muted);
}

.evo-invite-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

/* ---------- Account pages (Bootstrap markup) inside the app ---------- */
.evo-container h1 { font-weight: 800; font-size: 1.8rem; color: var(--evo-text); }
.evo-container .btn-primary { background: var(--evo-lagoon); border-color: var(--evo-lagoon); }
.evo-container .btn-primary:hover { background: #09625e; border-color: #09625e; }
.evo-container .nav-pills .nav-link { color: var(--evo-accent); }
.evo-container .nav-pills .nav-link.active { background: var(--evo-lagoon); color: #fff; }
html.evo-dark .evo-container .form-text { color: var(--evo-muted); }

/* ---------- Reconnect message ---------- */
#components-reconnect-modal {
    display: none;
    position: fixed;
    top: calc(72px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: block;
}

.evo-reconnect-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--evo-navy);
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    white-space: nowrap;
}

.evo-reconnect-box button {
    border: 0;
    border-radius: 999px;
    padding: 4px 12px;
    background: #fff;
    color: var(--evo-navy);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.evo-reconnect-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: evo-spin .8s linear infinite;
}

.evo-reconnect-lost { display: none; }

#components-reconnect-modal.components-reconnect-failed .evo-reconnect-lost,
#components-reconnect-modal.components-reconnect-rejected .evo-reconnect-lost { display: inline-block; }

#components-reconnect-modal.components-reconnect-failed .evo-reconnect-connecting,
#components-reconnect-modal.components-reconnect-rejected .evo-reconnect-connecting,
#components-reconnect-modal.components-reconnect-failed .evo-reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .evo-reconnect-spinner { display: none; }

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

/* ---------- Blazor error bar ---------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: #FFF4D6;
    color: #5a4300;
    box-shadow: 0 -1px 4px rgba(18, 53, 91, .15);
}

#blazor-error-ui .reload { margin-left: 8px; font-weight: 600; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }

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