/*
 * Volunteer self-service app shell (App\Controllers\Volunteer\*, /v/*).
 *
 * Built to feel like an installed native app rather than a website —
 * fixed bottom tab bar, safe-area-aware top/bottom insets (so content never
 * sits under the iOS notch or Android gesture bar once installed as a PWA),
 * large touch targets, tap/press feedback instead of hover states, and a
 * short launch fade so navigating between pages doesn't feel like a
 * document reload. Reuses this app's own design tokens (--color-primary
 * etc. — see assets/css/app.css) so it stays on-brand, but every layout
 * class here is its own (`v-*`), deliberately not Bootstrap's grid/card
 * components, which read as "admin dashboard" rather than "mobile app".
 */

* {
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overscroll-behavior-y: contain; /* no browser "pull to refresh" flash inside an installed app */
}

body.v-body {
    margin: 0;
    background: var(--color-background);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    /* Fade only. NEVER put a transform (or filter/will-change/contain) on <body> or on .v-shell:
       any of them makes that element the containing block for position:fixed children, and the
       bottom tab bar then scrolls away with the page instead of staying pinned to the screen. */
    animation: vLaunch .28s ease backwards;
}

@keyframes vLaunch {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* The slide-up lives on the content only (the tab bar is a sibling, so it is unaffected), and
   "backwards" fill means no transform is left behind once it has finished. */
.v-content { animation: vContentIn .3s cubic-bezier(.2, .7, .2, 1) backwards; }
@keyframes vContentIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    body.v-body, .v-content { animation: none; }
}

:root { --v-tabbar-h: 63px; }

.v-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ------------------------------------------------------------------ */
/* Top bar                                                             */
/* ------------------------------------------------------------------ */

.v-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
    background: var(--color-surface); /* fallback for browsers without color-mix() */
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--color-border);
}

.v-topbar-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.v-topbar-sub {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin: 0;
}

.v-topbar-action {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    font-size: var(--fs-lg);
    text-decoration: none;
    transition: transform .1s ease;
}

.v-topbar-action:active {
    transform: scale(.9);
}

/* ------------------------------------------------------------------ */
/* Content                                                             */
/* ------------------------------------------------------------------ */

.v-content {
    flex: 1;
    padding: 16px 16px calc(var(--v-tabbar-h) + env(safe-area-inset-bottom, 0px) + 20px);
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.v-section-title {
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
    margin: 22px 4px 10px;
}

.v-section-title:first-child {
    margin-top: 4px;
}

/* ------------------------------------------------------------------ */
/* Cards                                                                */
/* ------------------------------------------------------------------ */

.v-card {
    background: var(--color-surface);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    padding: 16px;
    margin-bottom: 12px;
}

a.v-card, button.v-card {
    display: block;
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: inherit;
    border: none;
    transition: transform .1s ease, box-shadow .1s ease;
}

a.v-card:active, button.v-card:active, .v-tap:active {
    transform: scale(.98);
}

.v-card-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.v-card-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: var(--fs-lg);
}

.v-card-body {
    flex: 1;
    min-width: 0;
}

.v-card-title {
    font-weight: 600;
    font-size: var(--fs-md);
    margin: 0 0 2px;
}

.v-card-meta {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v-card-chevron {
    flex: 0 0 auto;
    color: var(--color-text-muted);
    font-size: var(--fs-lg);
}

/* Stat tiles on the home screen */
.v-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.v-stat {
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    padding: 14px 16px;
}

.v-stat-value {
    font-size: var(--fs-2xl);
    font-weight: 800;
    line-height: 1;
    color: var(--color-primary);
}

.v-stat-label {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: 4px;
}

.v-empty {
    text-align: center;
    padding: 34px 16px;
    color: var(--color-text-muted);
}

.v-empty i {
    font-size: 1.8rem;
    display: block;
    margin-bottom: 8px;
    opacity: .55;
}

/* Status chip, deliberately its own (smaller, pill-shaped) rather than
   reusing app.css's .status-pill, which is sized for a dense admin table. */
.v-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-2xs);
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
}

.v-chip--primary { background: var(--color-primary-soft); color: var(--color-primary); }
.v-chip--success  { background: var(--color-success-soft); color: var(--color-success); }
.v-chip--warning  { background: var(--color-warning-soft); color: var(--color-warning); }
.v-chip--danger   { background: var(--color-danger-soft); color: var(--color-danger); }

/* ------------------------------------------------------------------ */
/* Bottom tab bar                                                       */
/* ------------------------------------------------------------------ */

.v-tabbar {
    /* Docked bottom navigation, like a native app: pinned flush to the bottom edge of the
       screen at all times (scrolling never moves it, nothing shows beneath it), sitting above
       the gesture bar / home indicator via the safe-area padding. Solid colour, no gradient. */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-sizing: border-box;
    min-height: var(--v-tabbar-h);
    padding: 7px max(10px, calc((100% - 560px) / 2)) calc(7px + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 10px rgba(15, 23, 42, .06);
}

.v-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 48px;
    padding: 0 6px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    border-radius: 22px;
    white-space: nowrap;
    transition: flex-grow .28s cubic-bezier(.4, 0, .2, 1), background .2s ease, color .2s ease, transform .1s ease;
}

.v-tab i {
    font-size: 1.3rem;
    line-height: 1;
    flex: 0 0 auto;
}

/* Only the selected tab shows its label, in a tinted pill that grows to fit it. */
.v-tab span {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease;
}

.v-tab:active {
    transform: scale(.92);
}

.v-tab.is-active {
    flex-grow: 2.1;
    color: var(--color-primary);
    background: var(--color-primary-soft);
}

.v-tab.is-active span {
    max-width: 100px;
    opacity: 1;
}

.v-tab:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
    .v-tab, .v-tab span { transition: none; }
}


/* ------------------------------------------------------------------ */
/* Install banner (beforeinstallprompt) — see assets/js/volunteer-app.js */
/* ------------------------------------------------------------------ */

.v-install-banner {
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 16px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-pop);
}

.v-install-banner.is-visible {
    display: flex;
}

.v-install-banner-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-lg);
    flex: 0 0 auto;
}

.v-install-banner-body {
    flex: 1;
    min-width: 0;
}

.v-install-banner-title {
    font-weight: 700;
    font-size: var(--fs-sm);
    margin: 0;
}

.v-install-banner-sub {
    font-size: var(--fs-xs);
    opacity: .85;
    margin: 0;
}

.v-install-banner-btn {
    background: #fff;
    color: var(--color-primary);
    border: none;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: var(--fs-xs);
    font-weight: 700;
    flex: 0 0 auto;
}

.v-install-banner-dismiss {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .8);
    font-size: var(--fs-lg);
    padding: 4px;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------------ */
/* Auth (login) screen — full-bleed, brand-forward, native "sign in" feel */
/* ------------------------------------------------------------------ */

.v-auth-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px calc(env(safe-area-inset-bottom, 0px) + 28px);
    background: var(--color-background);
    box-sizing: border-box;
}

.v-auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 34px;
}

.v-auth-mark {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-2xl);
    font-weight: 800;
    box-shadow: var(--shadow-pop);
    margin-bottom: 12px;
}

.v-auth-name {
    font-weight: 800;
    font-size: var(--fs-lg);
    text-align: center;
}

.v-auth-tag {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 2px;
}

.v-auth-card {
    background: var(--color-surface);
    border-radius: 22px;
    padding: 22px 20px;
    box-shadow: var(--shadow-pop);
}

.v-field {
    margin-bottom: 14px;
}

.v-field label {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.v-field input {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-alt);
    border-radius: 14px;
    padding: 13px 14px;
    font-size: var(--fs-lg);
    color: var(--color-text);
    letter-spacing: .02em;
}

.v-field input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
}

.v-btn-primary {
    display: block;
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 14px;
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
    font-weight: 700;
    font-size: var(--fs-md);
    transition: transform .1s ease, background .15s ease;
}

.v-btn-primary:active {
    transform: scale(.98);
    background: var(--color-primary-hover);
}

.v-alert {
    border-radius: 14px;
    padding: 11px 14px;
    font-size: var(--fs-sm);
    margin-bottom: 14px;
}

.v-alert--danger  { background: var(--color-danger-soft); color: var(--color-danger); }
.v-alert--success { background: var(--color-success-soft); color: var(--color-success); }

.v-auth-help {
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: 16px;
}

/* ---- Canvasser self-registration (/v/register) ---- */
.v-field select {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-alt);
    border-radius: 14px;
    padding: 13px 14px;
    font-size: var(--fs-md);
    color: var(--color-text);
}
.v-field select:focus { outline: none; border-color: var(--color-primary); background: var(--color-surface); }
.v-field select:disabled { opacity: .55; }
.v-field .v-hint { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 5px; }
.v-section-title { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); margin: 20px 0 10px; }
.v-check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); margin: 6px 0 16px; }
.v-check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.v-alert ul { margin: 0; padding-left: 18px; }
.v-auth-help a { color: var(--color-primary); font-weight: 700; }

/* ------------------------------------------------------------------ */
/* Home hero header (native-app style) + quick actions                  */
/* ------------------------------------------------------------------ */

.v-hero {
    position: relative;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 64px;
    background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: var(--color-on-primary, #fff);
    border-radius: 0 0 30px 30px;
    overflow: hidden;
}

.v-hero::before, .v-hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .09);
    pointer-events: none;
}

.v-hero::before { width: 220px; height: 220px; top: -90px; right: -70px; }
.v-hero::after  { width: 150px; height: 150px; bottom: -70px; left: -40px; }

.v-hero-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
}

.v-hero-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: var(--fs-sm);
    min-width: 0;
}

.v-hero-brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.v-hero-logo {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: rgba(255, 255, 255, .95);
    color: var(--color-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    overflow: hidden;
}

.v-hero-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; box-sizing: border-box; }

.v-hero-action {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .18);
    color: inherit;
    text-decoration: none;
    font-size: var(--fs-lg);
    transition: transform .1s ease;
}

.v-hero-action:active { transform: scale(.9); }

.v-hero-who {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 14px;
}

.v-avatar {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    border: 2px solid rgba(255, 255, 255, .55);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xl, 1.4rem);
    font-weight: 800;
}

.v-hero-hello { margin: 0; font-size: var(--fs-xs); opacity: .85; }
.v-hero-name  { margin: 1px 0 2px; font-size: var(--fs-xl, 1.4rem); font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.v-hero-sub   { margin: 0; font-size: var(--fs-xs); opacity: .85; }

/* Stat strip that overlaps the hero, like the balance cards in banking apps */
.v-hero-stats {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: -44px 16px 6px;
    max-width: 528px;
}

@media (min-width: 592px) { .v-hero-stats { margin-left: auto; margin-right: auto; width: calc(100% - 32px); } }

.v-hero-stat {
    background: var(--color-surface);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    padding: 12px 8px;
    text-align: center;
}

.v-hero-stat b { display: block; font-size: var(--fs-xl, 1.4rem); font-weight: 800; color: var(--color-primary); line-height: 1.1; }
.v-hero-stat small { display: block; margin-top: 3px; font-size: var(--fs-2xs); color: var(--color-text-muted); font-weight: 600; }

.v-quick {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}

.v-quick a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--color-text);
    font-size: var(--fs-2xs);
    font-weight: 700;
    transition: transform .1s ease;
}

.v-quick a:active { transform: scale(.92); }

.v-quick a i {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 1.35rem;
}

.v-auth-mark--logo { background: var(--color-surface); padding: 8px; box-sizing: border-box; overflow: hidden; }
.v-auth-mark--logo img { width: 100%; height: 100%; object-fit: contain; }

/* Dark themes: the light brand tint would wash out white text, so the hero becomes a deep, brand-tinted panel. */
:root[data-theme="dark"] .v-hero { background: linear-gradient(160deg, color-mix(in srgb, var(--color-primary) 38%, #0b1220), #0b1220); color: #fff; }
:root[data-theme="dark"] .v-hero-logo { color: #0b1220; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .v-hero { background: linear-gradient(160deg, color-mix(in srgb, var(--color-primary) 38%, #0b1220), #0b1220); color: #fff; }
    :root:not([data-theme="light"]) .v-hero-logo { color: #0b1220; }
}

/* ------------------------------------------------------------------ */
/* Volunteer login: a NORMAL page, responsive down to phones.          */
/* Desktop / tablet landscape: photo slideshow left, form right (the    */
/* .auth-split* rules come from app.css, shared with the staff login).  */
/* <= 991px the photo panel is hidden by app.css and the form fills the */
/* screen; <= 575px the card loses its frame so nothing is cramped.      */
/* The form fields keep the shared .v-field look used by registration.   */
/* ------------------------------------------------------------------ */

body.v-login-body { animation: none; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; color: var(--color-text); background: var(--color-background); }

.v-login { min-height: 100vh; min-height: 100dvh; }

.v-login-main { padding: 2rem 1.5rem; }

.v-login-inner { width: 100%; max-width: 420px; margin: 0 auto; }

.v-login .v-auth-brand { margin-bottom: 1.5rem; }
.v-login .v-auth-mark { width: 72px; height: 72px; border-radius: 50%; font-size: var(--fs-2xl); }
.v-login .v-auth-mark--logo { border-radius: 50%; }
.v-login .v-auth-name { font-size: var(--fs-xl, 1.35rem); }

/* the form card: normal proportions, not the oversized phone treatment */
.v-login .v-auth-card {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 2rem;
}

.v-login .v-field { margin-bottom: 1.1rem; }
.v-login .v-field label { font-size: var(--fs-sm); color: var(--color-text); font-weight: 600; margin-bottom: .4rem; }
.v-login .v-field input {
    border-width: 1px;
    border-radius: 8px;
    padding: .65rem .8rem;
    font-size: var(--fs-base, 1rem);
    background: var(--color-surface);
}
.v-login .v-field input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }

.v-login .v-btn-primary {
    border-radius: 8px;
    padding: .7rem 1rem;
    font-size: var(--fs-base, 1rem);
    cursor: pointer;
}
.v-login .v-btn-primary:hover { background: var(--color-primary-hover); }
.v-login .v-btn-primary:active { transform: none; }

.v-login .v-alert { border-radius: 8px; }
.v-login .v-auth-help { font-size: var(--fs-sm); line-height: 1.5; }

.v-login-tools { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; }

/* tablets and below: single column (the photo panel is hidden by app.css at this width) */
@media (max-width: 991.98px) {
    .v-login-main { min-width: 0; align-items: flex-start; padding-top: 3rem; }
}

/* phones: let the form use the full width; drop the card frame, keep comfortable touch targets */
@media (max-width: 575.98px) {
    .v-login-main { padding: calc(env(safe-area-inset-top, 0px) + 1.5rem) 1.1rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem); }
    .v-login-inner { max-width: none; }
    .v-login .v-auth-card { padding: 1.4rem 1.1rem; border-radius: 12px; }
    .v-login .v-field input { padding: .8rem .85rem; font-size: 16px; }   /* 16px stops iOS zooming into the field */
    .v-login .v-btn-primary { padding: .85rem 1rem; }
    .v-login-tools { right: .6rem; bottom: .6rem; }
}

/* short landscape phones: don't vertically centre a form taller than the screen */
@media (max-height: 520px) {
    .v-login-main { align-items: flex-start; }
}
