/* =====================================================================
   FaithfullyGiving design tokens + app-shell styles
   ---------------------------------------------------------------------
   Layered ON TOP of MudBlazor's --mud-palette-* variables (this file must
   load AFTER MudBlazor.min.css). Component CSS should use these tokens or
   --mud-palette-* — never literal colors — so light and dark both work.
   Palette values themselves come from FaithfullyGiving.Data/Theming/AppThemeTokens.cs
   via Client/Theming/FgTheme.cs. Mirrored in FaithfullyGiving.MAUI/wwwroot/css/tokens.css.
   ===================================================================== */

:root {
    --fg-radius: 10px;
    --fg-radius-sm: 6px;
    --fg-radius-lg: 14px;
    --fg-space-1: 4px;
    --fg-space-2: 8px;
    --fg-space-3: 12px;
    --fg-space-4: 16px;
    --fg-space-5: 24px;
    --fg-space-6: 32px;
    --fg-content-max: 1400px;
    --fg-border: 1px solid var(--mud-palette-lines-default);
    --fg-shadow-sm: 0 1px 2px rgba(20, 15, 10, 0.06), 0 1px 1px rgba(20, 15, 10, 0.04);
    --fg-shadow-md: 0 4px 12px rgba(20, 15, 10, 0.08), 0 1px 3px rgba(20, 15, 10, 0.06);
    --fg-shadow-lg: 0 12px 32px rgba(20, 15, 10, 0.12), 0 2px 6px rgba(20, 15, 10, 0.06);
    --fg-surface-2: var(--mud-palette-background-gray);
    --fg-transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.fg-dark {
    --fg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --fg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --fg-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* ---------- Base ---------- */
html, body {
    background-color: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
    font-family: var(--mud-typography-default-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* A right-anchored popover (e.g. the user menu) must never push the whole page
       wide and add a horizontal scrollbar. Internal overflow-x:auto containers
       (wide tables, etc.) are unaffected — this only clips page-level overflow. */
    overflow-x: hidden;
}

.fg-shell {
    min-height: 100vh;
    background-color: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
}

.fg-shell a:not(.mud-button-root):not(.mud-nav-link):not(.mud-menu-item):not(.btn) {
    color: var(--mud-palette-primary);
    text-decoration: none;
}

    .fg-shell a:not(.mud-button-root):not(.mud-nav-link):not(.mud-menu-item):not(.btn):hover {
        text-decoration: underline;
    }

/* ---------- App bar ---------- */
.fg-appbar.mud-appbar {
    background-color: var(--mud-palette-appbar-background);
    color: var(--mud-palette-appbar-text);
    border-bottom: var(--fg-border);
    box-shadow: none;
    backdrop-filter: saturate(180%) blur(8px);
}

    .fg-appbar.mud-appbar .mud-toolbar {
        padding-left: var(--fg-space-4);
        padding-right: var(--fg-space-3);
        gap: 2px;
    }

.fg-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit !important;
    text-decoration: none !important;
    margin-right: var(--fg-space-2);
}

.fg-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    box-shadow: var(--fg-shadow-sm);
}

.fg-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.fg-brand-accent {
    color: var(--mud-palette-primary);
}

.fg-appbar-divider {
    height: 24px;
    align-self: center;
}

.fg-org-name {
    color: var(--mud-palette-text-secondary);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fg-user-btn.mud-button-root {
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    text-transform: none;
    gap: 8px;
}

/* MudButton nests its content in .mud-button-label, so the root's gap never
   reaches the avatar/name — space them at the label level. */
.fg-user-btn .mud-button-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.fg-user-name {
    font-weight: 500;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fg-user-avatar {
    font-size: 0.75rem;
    font-weight: 600;
}

.fg-user-menu {
    position: relative;
    display: inline-flex;
}

.fg-user-popover.mud-popover {
    min-width: 240px;
    overflow-x: hidden;
    background: var(--mud-palette-surface);
    border: var(--fg-border);
    border-radius: var(--fg-radius) !important;
    box-shadow: var(--fg-shadow-lg) !important;
    margin-top: 6px;
}

.fg-user-menu-list {
    overflow-x: hidden;
}

.fg-user-menu-list .mud-list-item {
    border-radius: var(--fg-radius-sm);
    margin: 0 6px;
}

.fg-give-btn.mud-button-root {
    border-radius: 999px;
    padding-left: 14px;
    padding-right: 14px;
}

/* ---------- Main content ---------- */
.fg-main.mud-main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--mud-palette-background);
}

.fg-body {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* ---------- Member/admin shell (MemberMain) ---------- */
.fg-app {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.fg-app-container.mud-drawer-container {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--mud-appbar-height));
}

.fg-content.mud-main-content {
    padding-top: 0;
    min-height: calc(100vh - var(--mud-appbar-height));
    display: flex;
    flex-direction: column;
    transition: margin-left var(--fg-transition);
}

/* The desktop drawer is position:fixed (see .fg-drawer rule below), so it's out of flow and
   MudBlazor does not auto-offset the content for it. Push the content over by the drawer's own
   width — mini rail when collapsed, full width when expanded — keyed on the SAME IsSmallScreen /
   _drawerOpen state that drives the drawer (set as fg-drawer-mini / fg-drawer-expanded on .fg-app).
   Small screens use a Temporary overlay drawer and get no offset. */
.fg-app.fg-drawer-mini .fg-content.mud-main-content {
    margin-left: var(--mud-drawer-width-mini-left, 56px) !important;
}

.fg-app.fg-drawer-expanded .fg-content.mud-main-content {
    margin-left: var(--mud-drawer-width-left, 240px) !important;
}

    .fg-content.mud-main-content > .d-flex {
        padding: var(--fg-space-4);
        max-width: var(--fg-content-max);
        width: 100%;
        margin: 0 auto;
    }

@media (min-width: 960px) {
    .fg-content.mud-main-content > .d-flex {
        padding: var(--fg-space-5) var(--fg-space-6);
    }
}

@media (max-width: 599.98px) {
    .fg-content.mud-main-content > .d-flex {
        padding: var(--fg-space-3);
    }
}

.fg-drawer.mud-drawer {
    border-right: var(--fg-border);
    background-color: var(--mud-palette-drawer-background);
}

/* Desktop drawer: pin it to the viewport (MudDrawerContainer renders it absolute, which
   stretches it to the full document height and lets it run under the footer). */
.fg-drawer.mud-drawer:not(.mud-drawer-temporary) {
    position: fixed;
    top: var(--mud-appbar-height);
    height: calc(100vh - var(--mud-appbar-height));
    overflow-y: auto;
    overflow-x: hidden;
}

/* On shell pages MemberMain renders its own AppFooter inside the drawer container, so hide
   the layout-level copy. */
.fg-main:has(.fg-app) > .fg-footer {
    display: none;
}

.fg-content .fg-footer {
    margin-top: auto;
}

    .fg-drawer.mud-drawer.mud-drawer-fixed.mud-drawer-clipped-always {
        top: var(--mud-appbar-height);
        height: calc(100% - var(--mud-appbar-height));
    }

    .fg-drawer .mud-nav-link {
        border-radius: var(--fg-radius-sm);
        margin: 1px 8px;
        padding-left: 12px;
        min-height: 40px;
        transition: background-color var(--fg-transition), color var(--fg-transition);
    }

    .fg-drawer .mud-nav-group .mud-nav-link {
        padding-left: 12px;
    }

    .fg-drawer .mud-nav-group > .mud-nav-link {
        font-weight: 600;
    }

    .fg-drawer .mud-nav-link.active,
    .fg-drawer .mud-nav-link:hover {
        background-color: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
        color: var(--mud-palette-primary);
    }

        .fg-drawer .mud-nav-link.active .mud-nav-link-icon,
        .fg-drawer .mud-nav-link:hover .mud-nav-link-icon {
            color: var(--mud-palette-primary);
        }

    .fg-drawer .mud-navmenu > .mud-icon-button {
        margin: 6px 12px 4px;
    }

.mud-drawer-mini .fg-drawer .mud-nav-link,
.fg-drawer.mud-drawer-mini .mud-nav-link {
    margin-left: 12px;
    margin-right: 12px;
}

.fg-mobile-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--mud-palette-surface);
    border-bottom: var(--fg-border);
    position: sticky;
    top: var(--mud-appbar-height);
    z-index: 5;
}

.fg-mobile-title {
    font-weight: 600;
}

/* ---------- Footer ---------- */
.fg-footer {
    flex-shrink: 0;
    border-top: var(--fg-border);
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-secondary);
    padding: var(--fg-space-4);
    margin-top: var(--fg-space-5);
}

.fg-footer-inner {
    max-width: var(--fg-content-max);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--fg-space-2) var(--fg-space-5);
    text-align: center;
}

.fg-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--fg-space-4);
    justify-content: center;
}

    .fg-footer-links a,
    .fg-footer-legal a {
        color: var(--mud-palette-text-secondary) !important;
        font-size: 0.75rem;
    }

.fg-footer-legal {
    flex-basis: 100%;
    color: var(--mud-palette-text-disabled) !important;
}

.fg-footer-uid {
    opacity: 0.7;
}

/* ---------- Component polish (global) ---------- */
.mud-paper:not(.mud-appbar):not(.mud-drawer):not(.mud-popover):not(.mud-dialog):not(.mud-menu-list):not(.mud-alert),
.mud-card {
    border-radius: var(--fg-radius);
}

.mud-card.mud-paper:not(.mud-elevation-0):not([class*="mud-elevation-"]) {
    box-shadow: var(--fg-shadow-sm);
}

.mud-dialog {
    border-radius: var(--fg-radius-lg) !important;
}

.mud-popover, .mud-menu-list, .mud-list.mud-list-padding {
    border-radius: var(--fg-radius) !important;
}

.mud-popover {
    box-shadow: var(--fg-shadow-lg) !important;
    border: var(--fg-border);
}

.mud-button-root {
    border-radius: 8px;
}

.mud-chip {
    border-radius: 999px;
}

.mud-tabs .mud-tabs-toolbar {
    border-bottom: var(--fg-border);
}

.mud-table, .mud-table-container {
    border-radius: var(--fg-radius);
}

.mud-table-root .mud-table-head .mud-table-cell {
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    background: var(--fg-surface-2);
}

.mud-input-outlined .mud-input-outlined-border {
    border-radius: 8px;
}

.mud-alert {
    border-radius: var(--fg-radius);
}

/* ---------- Bootstrap-era pages under the new shell ---------- */
.fg-shell .bg-light,
.fg-shell .bg-body-tertiary {
    background-color: var(--mud-palette-background) !important;
}

.fg-shell .text-muted {
    color: var(--mud-palette-text-secondary) !important;
}

.fg-shell .card {
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: var(--fg-border);
    border-radius: var(--fg-radius);
}

.fg-shell .page-section-less {
    padding: var(--fg-space-4) 0;
}

/* Bootstrap-template mastheads: styles.css forces height:100vh at >=992px, so pages that put
   real content (e.g. the ContactUs form card) inside the header overflow into the footer.
   Let the header size to its content instead. */
.fg-shell header.masthead-3,
.fg-shell header.masthead-2,
.fg-shell header.masthead {
    border-radius: 0;
    height: auto;
    min-height: 0;
    padding-bottom: var(--fg-space-6);
}

.fg-dark .table {
    color: var(--mud-palette-text-primary);
    --bs-table-bg: transparent;
}

.fg-dark .form-control, .fg-dark .form-select {
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-color: var(--mud-palette-lines-inputs);
}

/* Cookie-consent backdrop + environment ribbon (moved out of MainLayout <style>) */
.my-custom-class {
    backdrop-filter: blur(10px);
}

.env-ribbon {
    position: fixed;
    top: 12px;
    left: -34px;
    z-index: 99999;
    background: #e65100;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 4px 40px;
    transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}

.env-ribbon-beta {
    background: #1565c0;
}

.fg-env-chip {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border-radius: 999px;
    background: #e65100;
    color: #fff;
    margin-right: var(--fg-space-2);
    line-height: 1.4;
}

.fg-env-chip-beta {
    background: #1565c0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .fg-drawer .mud-nav-link {
        transition: none;
    }
}

/* ===== Guided onboarding stepper ===== */
.fg-tour-dim {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.55);
}
.fg-tour-modal {
    position: fixed;
    z-index: 3001;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    max-width: calc(100vw - 24px);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
    padding: 24px;
}
.fg-tour-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
}
.fg-tour-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--mud-palette-lines-default);
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.fg-tour-dot.done {
    background: var(--mud-palette-primary-lighten);
}
.fg-tour-dot.active {
    background: var(--mud-palette-primary);
    transform: scale(1.35);
}
.fg-tour-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}
.fg-tour-icon .mud-icon-root {
    width: 56px;
    height: 56px;
    font-size: 56px;
    color: var(--mud-palette-primary);
    background: var(--mud-palette-primary-hover);
    border-radius: 16px;
    padding: 10px;
}

/* ===== Page-smart help overlay ===== */
.fg-help-modal {
    position: fixed;
    z-index: 3001;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 460px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
    padding: 22px;
}
.fg-help-icon .mud-icon-root {
    color: var(--mud-palette-primary);
    background: var(--mud-palette-primary-hover);
    border-radius: 10px;
    padding: 6px;
    width: 36px;
    height: 36px;
    font-size: 24px;
}
.fg-help-tips {
    margin: 4px 0 0;
    padding-left: 20px;
}
.fg-help-tips li {
    margin: 4px 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.9rem;
}
