/* ---------------------------------------------------------------------------
   NonprofitBod design system — shared component classes (global).
   Modern SaaS language: generous whitespace, elevated rounded cards,
   coral accent, strong type hierarchy, clear primary actions.
   --------------------------------------------------------------------------- */

/* Page scaffold — full width; the sidebar already frames the app, so content fills the rest. */
.page { width: 100%; margin: 0; padding: 30px 40px 64px; }
/* Opt-in narrow wrapper for genuinely form-centric screens (login, wizard). */
.page.narrow { max-width: 720px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.025em; margin: 0; color: var(--ink); }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 5px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crumb-link { color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; }
.crumb-link:hover { color: var(--ink); text-decoration: none; }

/* Buttons (named .button to avoid clashing with Bootstrap's .btn) */
.button {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid transparent; border-radius: 12px;
    padding: 10px 17px; font-size: 14px; font-weight: 600; line-height: 1;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.button:hover { text-decoration: none; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(255,106,69,.28); }
.button.primary:hover { background: var(--brand-ink); color: #fff; }
.button.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.button.ghost:hover { background: #f3f4f6; color: var(--ink); }
.button.subtle { background: var(--brand-050); color: var(--brand-ink); }
.button.subtle:hover { background: #fbe0d8; color: var(--brand-ink); }
.button.danger { background: #fff; border-color: #f3d0d0; color: var(--red); }
.button.danger:hover { background: #fdecec; }
.button.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.button.lg { padding: 12px 22px; font-size: 15px; border-radius: 14px; }

.linklike { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--brand-ink); cursor: pointer; }
.linklike:hover { text-decoration: underline; }
.linklike.danger { color: var(--red); }

/* Cards */
.card {
    display: block;   /* override Bootstrap's .card (display:flex;column), which stretches buttons full-width */
    background: var(--card);
    border: 1px solid #f0f1f4;
    border-radius: 18px;
    padding: 22px 24px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
/* Action buttons placed directly in a card need breathing room from the content above.
   (Buttons grouped in .page-actions get their own gap between each other.) */
.card > .button,
.card > .linklike,
.card > .page-actions { margin-top: 18px; }
.card > .button + .button { margin-left: 10px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 14px; letter-spacing: -0.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
/* One-line explanation under a card title/head — what the card is and why it matters. */
.card-sub { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: -6px 0 14px; }
.card-head + .card-sub { margin-top: -4px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.dash { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }

/* Masonry — laid out by /masonry.js (cards are placed into the shortest column,
   absolutely positioned, never split). Fallback with JS off: cards stack full-width. */
.mosaic { position: relative; }
.mosaic > .card { margin: 0 0 18px; box-sizing: border-box; }

/* Stat tiles */
.stat { background: var(--card); border: 1px solid #f0f1f4; border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat__label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat__value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); margin-top: 6px; line-height: 1.1; }
.stat__meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* Avatars */
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-050); color: var(--brand-ink); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

/* Rows (roster, lists) */
.row-item { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-top: 1px solid #f2f3f5; }
.row-item:first-child { border-top: none; }
.row-item .grow { flex: 1; min-width: 0; }
.row-name { font-weight: 600; color: var(--ink); font-size: 14px; }
.row-sub { font-size: 12.5px; color: var(--muted); }

/* Chips / badges */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #f1f2f4; color: var(--muted); }
.chip.brand { background: var(--brand-050); color: var(--brand-ink); }
.chip.green { background: #e9f6ee; color: var(--green); }
.chip.amber { background: #fdf1e3; color: var(--amber); }
.chip.red { background: #fdecec; color: var(--red); }
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Key/value list */
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 7px 0; }
.kv + .kv { border-top: 1px solid #f2f3f5; }
.kv span { color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }

/* Empty states */
.empty { border: 1px dashed #e3e5ea; border-radius: 16px; padding: 30px; text-align: center; color: var(--muted); background: #fbfbfc; }
.empty .empty-emoji { font-size: 26px; display: block; margin-bottom: 8px; }
.empty .button { margin-top: 12px; }

/* Banners */
.banner { border-radius: 12px; padding: 12px 15px; font-size: 14px; }
.banner.success { background: #e9f6ee; border: 1px solid #bfe3cc; color: var(--green); }
.banner.warn { background: #fdf1e3; border: 1px solid #f3dcbc; color: var(--amber); }
.banner.info { background: #f1f5f9; border: 1px solid #dbe3ec; color: var(--ink); }

/* Slim progress bar (checklists, onboarding) */
.progress { height: 8px; border-radius: 999px; background: #eef0f3; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .2s ease; }

.muted { color: var(--muted); }

/* Forms */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
    width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 12px;
    padding: 11px 13px; font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); }
.textarea { min-height: 100px; resize: vertical; }
/* Horizontal stack (own utility — avoids colliding with Bootstrap's grid .row). */
.hstack { display: flex; align-items: center; gap: 10px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 180px; }
.form-error { color: var(--red); font-size: 13px; margin-top: 6px; }
.field-error { color: var(--red); font-size: 12.5px; margin-top: 6px; font-weight: 600; }
.req { color: var(--red); }
.input-error { border-color: var(--red) !important; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.check input { margin-top: 3px; }

/* Dropzone (reusable upload control) */
.dropzone {
    position: relative; overflow: hidden;
    border: 1.5px dashed #d7dae0; border-radius: 14px;
    background: #fbfbfc; text-align: center;
    padding: 26px 20px; min-height: 132px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.dropzone:hover { border-color: var(--brand); background: #fff; }
.dropzone.is-drag { border-color: var(--brand); background: var(--brand-050); box-shadow: 0 0 0 3px var(--brand-050); }
.dropzone.is-busy { border-style: solid; border-color: var(--line); background: #fff; }
.dropzone.is-disabled { opacity: .55; background: #f4f5f7; }
.dropzone.is-disabled .dropzone__file { pointer-events: none; cursor: not-allowed; }
/* The real file input overlays the whole zone so drag-drop AND click both work. */
.dropzone__file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone.is-busy .dropzone__file { pointer-events: none; }
.dropzone__body { position: relative; pointer-events: none; }
.dropzone__icon { font-size: 26px; color: var(--brand-ink); margin-bottom: 8px; }
.dropzone__title { font-size: 14px; font-weight: 600; color: var(--ink); }
.dropzone__hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.dropzone__pct { font-size: 22px; font-weight: 800; color: var(--brand-ink); margin-top: 6px; letter-spacing: -.02em; }
.dropzone__error { font-size: 12.5px; color: var(--red); margin-top: 8px; font-weight: 600; }
.dropzone__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: #eef0f3; }
.dropzone__bar > span { display: block; height: 100%; background: var(--brand); border-radius: 0 3px 3px 0; transition: width .15s ease; }
.dropzone__spinner {
    width: 26px; height: 26px; margin: 0 auto 8px; border-radius: 50%;
    border: 3px solid var(--brand-050); border-top-color: var(--brand);
    animation: dz-spin .7s linear infinite;
}
@keyframes dz-spin { to { transform: rotate(360deg); } }

/* Avatar photo overlay — <img> fills the .avatar circle; falls back to initials on error. */
.avatar { position: relative; overflow: hidden; }
.avatar .avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar.xl { width: 96px; height: 96px; font-size: 30px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

/* Data tables inside cards */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-top: 1px solid #f2f3f5; color: var(--ink); }
.table tr:first-child td { border-top: none; }

@media (max-width: 860px) {
    .dash { grid-template-columns: 1fr; }
    .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
    .page { padding: 22px 16px 48px; }
}

/* ---- Modal ---------------------------------------------------------------- */
.modal-backdrop-c {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(17,24,39,.44);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 8vh 16px 16px;
    animation: modal-fade .12s ease;
}
.modal-card {
    background: var(--card); border-radius: 18px; width: 100%; max-width: 520px;
    box-shadow: 0 24px 60px rgba(17,24,39,.28); overflow: hidden;
    animation: modal-rise .16s cubic-bezier(.2,.8,.25,1);
}
.modal-card.wide { max-width: 760px; }
.modal-body { max-height: 72vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.modal-x { background: none; border: none; font-size: 15px; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 8px; line-height: 1; }
.modal-x:hover { background: #f3f4f6; color: var(--ink); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fbfbfc; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- Document folder tree ------------------------------------------------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 14px; border-left: 1px solid var(--line); padding-left: 6px; }
.tree-row { display: flex; align-items: center; gap: 6px; width: 100%; border: none; background: none;
    padding: 7px 9px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink); text-align: left; }
.tree-row:hover { background: #f3f4f6; }
.tree-row.active { background: var(--brand-050); color: var(--brand-ink); font-weight: 700; }
.tree-row .tw-icon { font-size: 14px; }
.tree-row .tw-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .tw-count { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tree-caret { width: 14px; text-align: center; color: var(--muted); font-size: 10px; flex: none; }

/* Folder cards shown inside the current folder */
.folder-card { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--line);
    border-radius: 12px; background: #fff; cursor: pointer; text-align: left; width: 100%; transition: border-color .12s, box-shadow .12s; }
.folder-card:hover { border-color: #d7dae0; box-shadow: var(--shadow); }
.folder-card .fc-emoji { font-size: 20px; }
.folder-card .fc-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.folder-card .fc-sub { font-size: 12px; color: var(--muted); }

/* Small category tag on a document row */
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .01em;
    color: var(--brand-ink); background: var(--brand-050); border-radius: 999px; padding: 2px 9px; }

.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13px; margin-bottom: 14px; }
.breadcrumbs .crumb { background: none; border: none; padding: 2px 4px; cursor: pointer; color: var(--muted); font: inherit; font-weight: 600; border-radius: 6px; }
.breadcrumbs .crumb:hover { color: var(--ink); background: #f3f4f6; }
.breadcrumbs .crumb.current { color: var(--ink); cursor: default; }
.breadcrumbs .sep { color: #c7cbd1; }

/* ---- Article editor ------------------------------------------------------- */
.editor-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; align-items: start; }
.editor-grid .field { margin-bottom: 14px; }
.editor-grid textarea.mono { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px; line-height: 1.6; resize: vertical; }
.hint-inline { font-weight: 500; color: var(--muted); font-size: 12px; }
.preview-pane { position: sticky; top: 16px; }
.preview-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin-bottom: 12px; }
.preview-pane .mkt { max-height: 70vh; overflow-y: auto; }
@media (max-width: 980px) { .editor-grid { grid-template-columns: 1fr; } .preview-pane { position: static; } }

/* ---- Cover image picker (article editor) ---------------------------------- */
.cover-preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cover-preview img { width: 100%; height: 180px; object-fit: cover; display: block; }
.cover-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.cover-credit { font-size: 12.5px; color: var(--ink); }
.cover-credit.muted { color: var(--muted); }
.cover-empty { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.unsplash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.unsplash-item { position: relative; border: none; padding: 0; border-radius: 10px; overflow: hidden; cursor: pointer;
    aspect-ratio: 3 / 2; background-size: cover; transition: transform .1s ease, box-shadow .1s ease; }
.unsplash-item:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(17,24,39,.22); }
.unsplash-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.unsplash-by { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 8px 5px; font-size: 11px; color: #fff;
    text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.6)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unsplash-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin-top: 14px; font-size: 13px; color: var(--muted); }
.unsplash-foot a { color: var(--muted); text-decoration: underline; }
.unsplash-foot a:hover { color: var(--ink); }
@media (max-width: 560px) { .unsplash-grid { grid-template-columns: repeat(2, 1fr); } }
