/*
  Rivens design system. One stylesheet for the member PWA and the admin app.
  Derived from the BJJAA prototype (rivens.me/bjjaa): deep blue, frosted glass, Manrope.
  Club branding overrides the --rv-club-* tokens at runtime (see ClubTheme).
*/

:root {
    color-scheme: dark;

    /* club tokens (overridden per club) */
    --rv-club-bg: #0a1830;
    --rv-club-surface: #13294b;
    --rv-club-accent: #e9f2ff;
    --rv-club-text: #f6f8fa;

    /* palette */
    --rv-bg: var(--rv-club-bg);
    --rv-bg-deep: color-mix(in srgb, var(--rv-club-bg) 72%, #000);
    --rv-surface: var(--rv-club-surface);
    --rv-text: var(--rv-club-text);
    --rv-muted: #b7c7de;
    --rv-faint: #8ea4bd;
    --rv-accent: var(--rv-club-accent);
    --rv-on-accent: #102139;
    --rv-line: rgba(219, 235, 255, .21);
    --rv-line-soft: rgba(219, 235, 255, .11);
    --rv-glass: linear-gradient(125deg, rgba(198, 220, 252, .19), rgba(128, 165, 214, .07) 76%);
    --rv-field-bg: rgba(12, 35, 59, .4);

    --rv-success: #b7e6da;
    --rv-success-bg: rgba(184, 238, 219, .1);
    --rv-warning: #ffe3a3;
    --rv-warning-bg: rgba(255, 214, 120, .12);
    --rv-danger: #ffbaa9;
    --rv-danger-bg: rgba(255, 150, 125, .12);

    /* shape and type */
    --rv-radius-xl: 29px;
    --rv-radius-lg: 22px;
    --rv-radius: 15px;
    --rv-radius-pill: 999px;
    --rv-font: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --rv-shadow: 0 15px 35px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(233, 250, 255, .05);
    --rv-focus: #b1d0ff;
    --rv-ease: cubic-bezier(.18, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--rv-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--rv-text);
    background: var(--rv-bg-deep);
    -webkit-font-smoothing: antialiased;
    font-synthesis: none;
    -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.18; letter-spacing: -.04em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 750; }
h3 { font-size: 18px; font-weight: 700; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }

:focus-visible { outline: 2px solid var(--rv-focus); outline-offset: 3px; }

/* ---------- backgrounds ---------- */

.rv-ambient {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse at 74% 12%, color-mix(in srgb, var(--rv-club-surface) 90%, #4a8fb8 10%), transparent 52%),
        radial-gradient(ellipse at 12% 82%, color-mix(in srgb, var(--rv-club-bg) 70%, #1d4a66 30%), transparent 55%),
        var(--rv-bg-deep);
}

/* ---------- text helpers ---------- */

.rv-eyebrow { font-size: 11px; font-weight: 750; letter-spacing: .19em; text-transform: uppercase; color: var(--rv-muted); }
.rv-muted { color: var(--rv-muted); }
.rv-small { font-size: 13px; color: var(--rv-muted); }
.rv-tiny { font-size: 11px; color: var(--rv-faint); }
.rv-mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .08em; }
.rv-num { font-variant-numeric: tabular-nums; }

/* ---------- layout helpers ---------- */

.rv-stack { display: grid; gap: 12px; }
.rv-stack-lg { display: grid; gap: 22px; }
.rv-row { display: flex; align-items: center; gap: 12px; }
.rv-between { justify-content: space-between; }
.rv-wrap { flex-wrap: wrap; }
.rv-grow { flex: 1; min-width: 0; }
.rv-center { text-align: center; }

/* ---------- surfaces ---------- */

.rv-glass {
    position: relative;
    border-radius: var(--rv-radius-xl);
    border: 1px solid var(--rv-line);
    background: var(--rv-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: var(--rv-shadow);
    overflow: hidden;
}

.rv-pad { padding: 21px; }
.rv-pad-lg { padding: 28px; }

.rv-section { margin-top: 26px; }
.rv-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rv-section-title h2 { font-size: 18px; }

/* ---------- buttons ---------- */

.rv-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 49px;
    padding: 13px 19px;
    border-radius: var(--rv-radius-lg);
    border: 1px solid var(--rv-line);
    background: rgba(190, 217, 233, .08);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s, transform .2s, box-shadow .2s, opacity .2s;
}
.rv-button:hover { background: rgba(190, 217, 233, .15); }
.rv-button:active { transform: scale(.97); }
.rv-button:disabled, .rv-button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.rv-button.rv-primary {
    color: var(--rv-on-accent);
    border-color: rgba(255, 255, 255, .33);
    background: linear-gradient(130deg, #fff, var(--rv-accent));
    box-shadow: 0 6px 24px rgba(1, 17, 38, .13), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.rv-button.rv-primary:hover { box-shadow: 0 6px 28px rgba(188, 220, 255, .14); }
.rv-button.rv-danger { color: var(--rv-danger); border-color: rgba(255, 176, 155, .19); }
.rv-button.rv-ghost { background: transparent; border-color: transparent; }
.rv-button.rv-small { min-height: 36px; padding: 7px 14px; font-size: 12px; border-radius: var(--rv-radius); }
.rv-button.rv-full { width: 100%; }
.rv-button[aria-busy="true"] { color: transparent; }
.rv-button[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-color: var(--rv-on-accent) transparent var(--rv-on-accent) transparent;
    animation: rv-spin .8s linear infinite;
}
.rv-button:not(.rv-primary)[aria-busy="true"]::after { border-color: var(--rv-text) transparent var(--rv-text) transparent; }

.rv-text-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 0 8px 8px;
    border: 0;
    background: none;
    font-size: 12px;
    font-weight: 600;
    color: #bcd0dc;
    cursor: pointer;
    text-decoration: none;
}

/* ---------- forms ---------- */

.rv-field { display: grid; gap: 7px; text-align: left; }
.rv-field label, .rv-field .rv-label { font-size: 12px; color: #bdcfd9; }
.rv-input, .rv-field input, .rv-field select, .rv-field textarea {
    width: 100%;
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid rgba(215, 234, 247, .17);
    border-radius: var(--rv-radius);
    background: var(--rv-field-bg);
    color: #f0f5f9;
    font-size: 15px;
    outline-offset: 1px;
}
.rv-field input.invalid, .rv-field input[aria-invalid="true"] { border-color: rgba(255, 176, 155, .55); }
.rv-field .validation-message, .rv-error-text { font-size: 12px; color: var(--rv-danger); }
.rv-check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--rv-muted); }
.rv-check input { width: 18px; height: 18px; accent-color: var(--rv-accent); }

/* ---------- feedback ---------- */

.rv-alert {
    padding: 13px 15px;
    border-radius: var(--rv-radius);
    border: 1px solid var(--rv-line-soft);
    background: rgba(199, 222, 235, .06);
    font-size: 13px;
}
.rv-alert.rv-error { color: var(--rv-danger); background: var(--rv-danger-bg); border-color: rgba(255, 176, 155, .2); }
.rv-alert.rv-success { color: var(--rv-success); background: var(--rv-success-bg); border-color: rgba(184, 238, 219, .2); }
.rv-alert.rv-warning { color: var(--rv-warning); background: var(--rv-warning-bg); border-color: rgba(255, 214, 120, .2); }

.rv-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--rv-radius-pill);
    border: 1px solid rgba(215, 240, 255, .08);
    background: rgba(204, 229, 243, .09);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.rv-pill.rv-success { color: var(--rv-success); background: var(--rv-success-bg); }
.rv-pill.rv-warning { color: var(--rv-warning); background: var(--rv-warning-bg); }
.rv-pill.rv-danger { color: var(--rv-danger); background: var(--rv-danger-bg); }
.rv-pill.rv-outline { background: transparent; border-color: rgba(167, 200, 213, .16); color: #9cb7c5; }

.rv-spinner {
    width: 28px;
    height: 28px;
    margin: 32px auto;
    border-radius: 50%;
    border: 2.5px solid var(--rv-line);
    border-top-color: var(--rv-accent);
    animation: rv-spin .9s linear infinite;
}

/* ---------- lists and tables ---------- */

.rv-list { display: grid; }
.rv-list-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--rv-line-soft); }
.rv-list-item:first-child { border-top: 0; }

.rv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rv-table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--rv-faint); padding: 10px 12px; border-bottom: 1px solid var(--rv-line); }
.rv-table td { padding: 12px; border-bottom: 1px solid var(--rv-line-soft); vertical-align: middle; }
.rv-table tr:last-child td { border-bottom: 0; }
.rv-table .rv-right { text-align: right; }

/* ---------- member card ---------- */

.rv-card-code { font-size: 22px; font-weight: 700; letter-spacing: .14em; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ---------- blazor chrome ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 12px 12px;
    z-index: 1000;
    padding: 12px 16px;
    border-radius: var(--rv-radius);
    background: #3b1720;
    color: #ffd5cc;
    font-size: 13px;
}
#blazor-error-ui .reload { margin-left: 8px; font-weight: 700; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

.rv-boot { min-height: 100vh; display: grid; place-items: center; }

@keyframes rv-spin { to { transform: rotate(360deg); } }
@keyframes rv-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rv-page { animation: rv-in .38s var(--rv-ease); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- stage 2: icons, round buttons, stacks ---------- */

.rv-icon { width: 18px; height: 18px; flex: none; }
.rv-stack-xs { display: grid; gap: 4px; }
.rv-stack-sm { display: grid; gap: 8px; }
.rv-gap-sm { gap: 8px; }
.rv-end { justify-content: flex-end; }
.rv-top { align-items: flex-start; }
.rv-hidden { display: none !important; }

.rv-round {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--rv-line);
    background: rgba(190, 217, 233, .08);
    cursor: pointer;
    flex: none;
}
.rv-round:hover { background: rgba(190, 217, 233, .16); }
.rv-round.rv-small-round { width: 36px; height: 36px; }
.rv-round:disabled { opacity: .4; cursor: not-allowed; }

.rv-grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rv-grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .rv-grid-2, .rv-grid-3 { grid-template-columns: 1fr; } }

.rv-field textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.rv-field-hint { font-size: 11px; color: var(--rv-faint); }
.rv-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.rv-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: var(--rv-radius-pill);
    border: 1px solid var(--rv-line-soft);
    background: rgba(204, 229, 243, .06);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.rv-chip.rv-selected { background: var(--rv-accent); color: var(--rv-on-accent); border-color: transparent; }

/* ---------- segmented control ---------- */

.rv-segmented {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: var(--rv-radius-lg);
    border: 1px solid var(--rv-line-soft);
    background: rgba(8, 26, 44, .35);
}
.rv-segmented button {
    padding: 8px 16px;
    border: 0;
    border-radius: 17px;
    background: transparent;
    font-size: 13px;
    font-weight: 700;
    color: var(--rv-muted);
    cursor: pointer;
    white-space: nowrap;
}
.rv-segmented button.rv-selected { background: rgba(233, 244, 255, .92); color: var(--rv-on-accent); }

/* ---------- dialog ---------- */

.rv-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(2, 10, 20, .62);
    backdrop-filter: blur(6px);
    animation: rv-fade .18s ease-out;
}
.rv-dialog {
    width: min(560px, 100%);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    border-radius: var(--rv-radius-xl);
    border: 1px solid var(--rv-line);
    background: linear-gradient(160deg, color-mix(in srgb, var(--rv-club-surface) 92%, #fff 8%), var(--rv-club-bg));
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
    outline: none;
    animation: rv-in .24s var(--rv-ease);
}
.rv-dialog.rv-dialog-wide { width: min(820px, 100%); }
.rv-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 22px 8px; }
.rv-dialog-body { padding: 10px 22px 22px; overflow-y: auto; display: grid; gap: 14px; }
.rv-dialog-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 22px 20px; border-top: 1px solid var(--rv-line-soft); }
@media (max-width: 640px) {
    .rv-overlay { place-items: end center; padding: 0; }
    .rv-dialog { width: 100%; max-height: 92vh; border-radius: var(--rv-radius-xl) var(--rv-radius-xl) 0 0; }
}

/* ---------- toasts ---------- */

.rv-toasts { position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.rv-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--rv-radius);
    border: 1px solid var(--rv-line);
    background: #13294b;
    color: var(--rv-text);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
    animation: rv-in .25s var(--rv-ease);
    cursor: pointer;
}
.rv-toast-success .rv-icon { color: var(--rv-success); }
.rv-toast-error { background: #3b1720; color: #ffd5cc; }

/* ---------- belts ---------- */

.rv-belt-badge { display: inline-flex; align-items: center; gap: 9px; }
.rv-belt {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 12px;
    border-radius: 3px;
    background: var(--belt, #f1f1ee);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}
.rv-belt-bar {
    position: absolute;
    right: 8px;
    top: 0;
    bottom: 0;
    width: 22px;
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    gap: 2px;
    padding: 0 2px;
    background: #111;
}
.rv-belt-bar i { width: 2px; background: #f5f5f5; }
.rv-belt-white { --belt: #f1f1ee; }
.rv-belt-grey { --belt: #9aa0a6; }
.rv-belt-yellow { --belt: #f2c94c; }
.rv-belt-orange { --belt: #f2994a; }
.rv-belt-green { --belt: #2e9e5b; }
.rv-belt-blue { --belt: #2f6fd6; }
.rv-belt-purple { --belt: #7b4fb3; }
.rv-belt-brown { --belt: #7a4b2a; }
.rv-belt-black { --belt: #141414; }
.rv-belt-black .rv-belt-bar { background: #c62828; }
.rv-belt-label { font-size: 12px; color: var(--rv-muted); white-space: nowrap; }

/* ---------- empty state, search, money ---------- */

.rv-empty { display: grid; justify-items: center; gap: 8px; padding: 34px 18px; text-align: center; color: var(--rv-muted); }
.rv-empty .rv-icon { width: 28px; height: 28px; opacity: .8; }
.rv-empty h3 { color: var(--rv-text); font-size: 16px; }

.rv-member-search { position: relative; }
.rv-search-box { position: relative; display: flex; align-items: center; }
.rv-search-box .rv-icon { position: absolute; left: 13px; color: var(--rv-faint); pointer-events: none; }
.rv-search-box input { padding-left: 40px; }
.rv-search-results {
    position: absolute;
    z-index: 50;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    display: grid;
    max-height: 280px;
    overflow-y: auto;
    border-radius: var(--rv-radius);
    border: 1px solid var(--rv-line);
    background: #10233f;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .4);
}
.rv-search-result { display: grid; gap: 2px; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--rv-line-soft); background: transparent; text-align: left; cursor: pointer; }
.rv-search-result:hover { background: rgba(190, 217, 233, .1); }
.rv-search-none { margin-top: 8px; }

.rv-money-input { position: relative; display: flex; align-items: center; }
.rv-money-symbol { position: absolute; left: 14px; color: var(--rv-faint); font-weight: 700; }
.rv-money-input input { padding-left: 30px; }

.rv-kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 13px; }
.rv-kv dt { color: var(--rv-faint); }
.rv-kv dd { margin: 0; }

@keyframes rv-fade { from { opacity: 0; } to { opacity: 1; } }
