/* ============================================================================
   tzuchi-module.css — shared chrome for the module workspace and public form pages.
   Load AFTER /css/tzuchi.css:   <link rel="stylesheet" href="/css/tzuchi-module.css">

   ── Why this file exists ───────────────────────────────────────────────────
   It holds the components the module and public-form pages share, so that no
   page needs to redefine them in an inline <style> block of its own.

   public/js/theme.js ships eight themes, including a white one, and applies
   them by setting CSS variables on documentElement at runtime. A hardcoded
   colour cannot follow that, so a page carrying its own colours is correct on
   the theme its author used and wrong on the rest.

   ── The rule this file follows ─────────────────────────────────────────────
   NO HARDCODED COLOURS. Every colour is a var() from tzuchi.css's token set, or a
   colour-mix against one. A page that needs a colour the tokens do not have
   should get a new token in tzuchi.css rather than a hex here — otherwise the next
   theme breaks it again.

   Status colours use the semantic tokens (--success/--danger/--warning) rather
   than a literal green/red, so "enabled" means the same thing, and looks the
   same, on every page and every theme.
   ============================================================================ */

/***********************************************************************************
    Page Chrome
***********************************************************************************/

.fmc-topbar
{
    align-items: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    padding: 12px 18px;
}
.fmc-topbar h1
{
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}
.fmc-wrap
{
    margin: 0 auto;
    max-width: 1400px;
    padding: 18px;
}
/* CRM07 Volunteer Path only (id, not the shared class default): its Members list can carry a
   column per Custom Field, unbounded and opt-out rather than opt-in, so the shared 1400px cap
   wastes real width on a wide monitor for a page this data-heavy specifically. Scoped to this
   page's own wrap id so every OTHER page using plain .fmc-wrap keeps its existing 1400px layout
   untouched. */
#crm07-wrap
{
    max-width: calc(100vw - 2%);
}

/***********************************************************************************
    Tabs and Sub-Tabs
***********************************************************************************/

.tab-bar
{
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    padding-bottom: 8px;
}
.tab-btn
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab-btn:hover:not(.active)
{
    border-color: var(--accent-light);
    color: var(--text);
}
.tab-btn.active
{
    background: var(--accent);
    border-color: var(--accent);
    color: rgb(255 255 255);
}
/* The show/hide half of the tab pattern — every page pairs .tab-bar/.tab-btn with a .tab-pane per
   panel, toggled by switchTab() adding/removing .active. Defined here so that a page with no
   inline <style> of its own still gets a working switch. */
.tab-pane
{
    display: none;
}
.tab-pane.active
{
    display: block;
}
.subtab-bar
{
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 14px;
    padding-bottom: 8px;
}
.subtab-btn
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.subtab-btn:hover:not(.active)
{
    color: var(--text);
}
.subtab-btn.active
{
    background: var(--accent);
    border-color: var(--accent);
    color: rgb(255 255 255);
}

/***********************************************************************************
    Toolbar
***********************************************************************************/

.toolbar
{
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.toolbar .ml-auto,
.ml-auto
{
    margin-left: auto;
}

/***********************************************************************************
    Tables
***********************************************************************************/

/* overflow-x on the wrapper, never on the page body — a wide table must scroll
   inside its own box rather than making the whole screen scroll sideways. */
.tbl-wrap
{
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
}
.tbl-wrap table
{
    border-collapse: collapse;
    font-size: 13px;
    width: 100%;
}
.tbl-wrap thead th
{
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 9px 10px;
    position: sticky;
    text-align: left;
    top: 0;
    white-space: nowrap;
    z-index: 1;
}
.tbl-wrap tbody td
{
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
}
.tbl-wrap tbody tr:last-child td
{
    border-bottom: none;
}
.tbl-wrap tbody tr:hover
{
    background: var(--accent-glow);
}
.empty
{
    color: var(--text-muted);
    padding: 18px;
    text-align: center;
}
.muted
{
    color: var(--text-muted);
}
/* CRM07 Member list only (id, not the shared class default): its explicit per-column ch/px
   widths (Name 30ch, Tel 15ch, etc. - see members.js#_mbRenderHead) are a hard requirement, not a
   suggestion the browser may shrink to fit - width:100% on the shared rule above would otherwise
   let the table compress those columns instead of honouring them. width:max-content lets the table size to its
   own content/explicit widths; min-width:100% keeps it at least as wide as the wrapper on a roomy
   screen; the wrapper's own overflow:auto (the shared .tbl-wrap rule above) supplies the
   horizontal scrollbar once the table is wider than that. */
#mb-tbl-wrap table
{
    min-width: 100%;
    width: max-content;
}

/***********************************************************************************
    Checkbox-Dropdown Filter
***********************************************************************************/

/* Same widget as admin-dashboard.html's Project Type/Status filters (that page's own inline
   <style>) - duplicated here since this is a shared stylesheet other pages use too and this
   module ships no inline <style> of its own. A native <select multiple> can't render
   closed-by-default, which is the reason this exists instead of one. */
.chk-dd
{
    display: inline-block;
    position: relative;
}
.chk-dd-btn
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    line-height: 1.4;
    padding: 5px 10px;
    white-space: nowrap;
}
.chk-dd-btn:hover
{
    border-color: var(--accent);
}
.chk-dd-panel
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
    left: 0;
    max-height: 260px;
    min-width: 170px;
    overflow-y: auto;
    padding: 6px 0;
    position: absolute;
    top: calc(100% + 4px);
    z-index: 200;
}
.chk-dd-panel label
{
    align-items: center;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 12px;
    gap: 7px;
    padding: 4px 12px;
    white-space: nowrap;
}
.chk-dd-panel label:hover
{
    background: var(--accent-glow);
    color: var(--accent);
}
.chk-dd-actions
{
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 4px;
    margin-bottom: 2px;
    padding: 4px 8px 6px;
}
.chk-dd-actions button
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    cursor: pointer;
    flex: 1;
    font-size: 11px;
    padding: 3px 0;
}
.chk-dd-actions button:hover
{
    border-color: var(--accent);
    color: var(--accent);
}
/* Static checkbox list — the same row shape as .chk-dd-panel above, but sitting IN the form
   instead of in a dropdown.

   It exists because of a trap: `.form-group input` in tzuchi.css is `width:100%; padding:10px 14px`,
   which stretches a bare checkbox across the whole field and pushes its own text onto the next
   line — so a hand-rolled list of checkboxes inside a .form-group renders as a column of wide
   empty boxes with orphaned labels beneath them. Both overrides below are load-bearing.

   Each rule is written TWICE, plain and under .form-group, because several pages carry their own
   inline `.form-group label{display:block;...}` in a <style> block that loads after this file;
   at equal specificity that page rule would win and the labels would go back to being uppercase
   grey block captions. */
.chk-list
{
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding: 4px 0;
}
.chk-list label,
.form-group .chk-list label
{
    align-items: center;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 13px;
    font-weight: 400;
    gap: 8px;
    letter-spacing: 0;
    margin: 0;
    padding: 5px 10px;
    text-transform: none;
}
.chk-list label:hover,
.form-group .chk-list label:hover
{
    background: var(--accent-glow);
    color: var(--accent);
}
.chk-list input[type="checkbox"],
.form-group .chk-list input[type="checkbox"]
{
    flex: none;
    margin: 0;
    padding: 0;
    width: auto;
}
.chk-list-empty
{
    color: var(--text-muted);
    font-size: 12px;
    padding: 6px 10px;
}

/***********************************************************************************
    Stat Cards
***********************************************************************************/

.stat-grid
{
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 18px;
}
.stat-card
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}
.stat-card .val
{
    color: var(--accent-light);
    font-size: 24px;
    font-weight: 700;
}
.stat-card .lbl
{
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
}
.stat-card .sub
{
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 2px;
    min-height: 12px;
}

/***********************************************************************************
    Breakdown Cards and Bars
***********************************************************************************/

.bd-grid
{
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.bd-card
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}
.bd-card h3
{
    font-size: 13px;
    margin: 0 0 8px;
}
.bar
{
    background: var(--border);
    border-radius: 2px;
    height: 3px;
    margin-top: 3px;
}
.bar span
{
    background: var(--accent);
    border-radius: 2px;
    display: block;
    height: 100%;
}

/***********************************************************************************
    Modals
***********************************************************************************/

/* align-items:flex-start + overflow:auto, deliberately: a modal taller than the
   viewport must scroll from its top rather than being centred with its head cut
   off — the same reason the public forms use block flow instead of centred flex. */
.modal-bg
{
    align-items: flex-start;
    background: rgb(0 0 0 / 0.6);
    display: none;
    inset: 0;
    justify-content: center;
    overflow: auto;
    padding: 40px 12px;
    position: fixed;
    z-index: 50;
}
/* TWO state classes, deliberately. Pages open a modal with either classList.add('show') or
   classList.add('open'). Supporting both is correct here: this file exists to unify
   presentation, and rewriting a working page's JS to match a stylesheet would be the tail
   wagging the dog. With only one defined, the other page's modals could not open at all. */
.modal-bg.show,
.modal-bg.open
{
    display: flex;
}
.modal-bg .modal
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
}
.modal-bg .modal.wide
{
    max-width: 720px;
}
.modal-header
{
    align-items: center;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
}
.modal-header h3
{
    font-size: 15px;
    margin: 0;
}
.modal-close
{
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.modal-close:hover
{
    color: var(--text);
}
.modal-body
{
    padding: 16px;
}
.modal-footer
{
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
}

/***********************************************************************************
    Forms
***********************************************************************************/

.form-row
{
    margin-bottom: 12px;
}
.form-row label
{
    color: var(--text-muted);
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}
.form-row .inp,
.form-row .sel,
.form-row textarea,
.form-row input
{
    box-sizing: border-box;
    width: 100%;
}
.form-row.half
{
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 560px)
{
    .form-row.half
    {
        grid-template-columns: 1fr;
    }
}
.inp,
.sel,
.modal-body textarea
{
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    padding: 7px 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-body textarea
{
    min-height: 56px;
    resize: vertical;
}
.inp:focus,
.sel:focus,
.modal-body textarea:focus
{
    border-color: var(--accent);
}
/* Accessibility: the inline blocks set outline:none and signalled focus with a
   border colour alone, which is invisible to anyone navigating by keyboard on a
   theme where the border and accent are close. A ring restores it without
   changing the resting appearance. */
.inp:focus-visible,
.sel:focus-visible,
.btn:focus-visible,
.tab-btn:focus-visible,
.subtab-btn:focus-visible,
.modal-body textarea:focus-visible
{
    outline: 2px solid var(--accent-light);
    outline-offset: 1px;
}
.hint
{
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}
.warn
{
    color: var(--warning);
    font-size: 12px;
    margin-top: 4px;
}

/***********************************************************************************
    Status Badges
***********************************************************************************/

/* Semantic tokens, not literal colours. "Enabled" is the same green everywhere,
   and follows the theme instead of assuming a dark background. */
.badge
{
    border-radius: 20px;
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    white-space: nowrap;
}
.badge-green
{
    background: color-mix(in srgb, var(--success) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
    color: var(--success);
}
.badge-red
{
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
}
.badge-yellow
{
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
    color: var(--warning);
}
.badge-blue
{
    background: var(--accent-glow);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--accent-light);
}
.badge-gray
{
    background: color-mix(in srgb, var(--text-muted) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--text-muted) 25%, transparent);
    color: var(--text-muted);
}

/***********************************************************************************
    Buttons
***********************************************************************************/

/* tzuchi.css already owns .btn, .btn-primary, .btn-secondary, .btn-danger and .btn-block, and they
   are good — nothing here redefines them. These are only the variants the markup uses that
   tzuchi.css does not define: .btn-outline, .btn-ghost and .btn-success.

   The full-width public-form button is .btn + .btn-block (tzuchi.css: width:100%, centred), NOT a
   redefinition of .btn, so an admin .btn and a form .btn stay the same size. */
/* A default look for a button carrying NO colour variant. tzuchi.css's .btn sets border:none with
   no background, so without this such a button would render as transparent text.
   The :not() chain is load-bearing: this file loads AFTER tzuchi.css, so a plain `.btn{background}`
   would have equal specificity to tzuchi.css's .btn-primary and beat it — turning every primary
   button grey. Listing the variants keeps this rule off any button that already has one. The
   four Projects-row variants (tzuchi.css) must be listed too: anything missing from the chain gets
   repainted grey and the variant silently does nothing. */
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger):not(.btn-outline):not(.btn-ghost):not(.btn-success):not(.btn-navy):not(.btn-tiffany):not(.btn-brown):not(.btn-blue)
{
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline
{
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover:not(:disabled)
{
    background: var(--bg-panel);
    border-color: var(--accent-light);
}
.btn-ghost
{
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled)
{
    background: var(--bg-panel);
    color: var(--text);
}
.btn-success
{
    background: var(--success);
    color: rgb(255 255 255);
}
.btn-success:hover:not(:disabled)
{
    filter: brightness(1.08);
}

/***********************************************************************************
    The Centred Public-Form Card
***********************************************************************************/

/* Scoped to `body > .card` deliberately. tzuchi.css's .card is a different component — the admin
   panel with .card-header/.card-body — which the workspace pages nest inside .app-layout. The
   public forms instead use .card as a standalone centred container and place it as a DIRECT
   child of <body>. That structural difference separates the two archetypes exactly, with no
   markup change and no risk of one restyling the other. */
body > .card
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgb(0 0 0 / 0.4);
    box-sizing: border-box;
    margin: 0 auto;
    max-width: 480px;
    padding: 32px 28px;
    width: 100%;
}
/* Full-bleed on a phone, folded in here so each page stops carrying its own copy of this media
   query. --fmc-zoom-inv is theme.js's zoom compensation; without it the card is short of the
   viewport when the user has zoomed. */
@media (max-width: 480px)
{
    body:has(> .card)
    {
        padding: 0;
    }
    body > .card
    {
        border: none;
        border-radius: 0;
        max-width: 100%;
        min-height: calc(100vh * var(--fmc-zoom-inv, 1));
        padding: 28px 18px;
    }
}

/***********************************************************************************
    Alerts
***********************************************************************************/

/* NO `display` property here, on purpose. tzuchi.css sets .alert{display:none} with an .alert.show
   to reveal it. Pages reveal alerts either by adding that class or by setting
   element.style.display, and some carry always-visible banners (.alert-info/.alert-ok) with
   neither. Leaving display alone keeps every existing page correct: the class and the inline
   style still work for the hide-then-show ones, and the static banners stay visible. */
.alert
{
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
    padding: 10px 12px;
}
/* .alert-err is the public forms' spelling; .alert-error is tzuchi.css's. Both exist in markup, so
   both are defined rather than renaming pages' HTML to suit a stylesheet. */
.alert-err,
.alert-error
{
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
}
.alert-ok,
.alert-success
{
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
    color: var(--success);
}
.alert-info
{
    background: var(--accent-glow);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--accent-light);
}

/***********************************************************************************
    Public-Form Controls
***********************************************************************************/

/* font-size 16px is not a style choice: iOS Safari zooms the page when a focused input is smaller
   than 16px, which on these public forms throws the layout off mid-entry. The workspace pages use
   the smaller .inp/.sel above, where that trade-off does not apply. */
.form-control
{
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
    color: var(--text);
    font-size: 16px;
    max-width: 100%;
    outline: none;
    padding: 9px 12px;
    transition: border-color 0.15s;
    width: 100%;
}
.form-control:focus
{
    border-color: var(--accent);
}
.form-control:focus-visible
{
    outline: 2px solid var(--accent-light);
    outline-offset: 1px;
}
textarea.form-control
{
    min-height: 60px;
    resize: vertical;
}

/***********************************************************************************
    Toasts
***********************************************************************************/

#toast-wrap
{
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: fixed;
    right: 16px;
    z-index: 100;
}
.toast
{
    animation: fmc-toast-in 0.18s ease-out;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
    color: rgb(255 255 255);
    font-size: 13px;
    padding: 9px 14px;
}
.toast.ok
{
    background: var(--success);
}
.toast.err
{
    background: var(--danger);
}
@keyframes fmc-toast-in
{
    from
    {
        opacity: 0;
        transform: translateY(6px);
    }
    to
    {
        opacity: 1;
        transform: none;
    }
}
/* Respect a reader who has asked for less motion — the toast still appears, it
   just does not slide. */
@media (prefers-reduced-motion: reduce)
{
    .toast
    {
        animation: none;
    }
    .tab-btn,
    .subtab-btn,
    .inp,
    .sel
    {
        transition: none;
    }
}
