/*
 * Serepok — document view (invoice, donation receipt).
 * Built on the serepok-variables.css tokens so light and dark both follow the
 * theme, and so an operator's colour choices in the Content Manager carry over.
 * Print rules live at the bottom: on paper the document is the only thing that
 * should survive - no navigation, no breadcrumb, no sidebar.
 */

.sp-doc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: var(--ui-gutter-base, 24px);
}

@media (max-width: 991px) {
    .sp-doc-layout { grid-template-columns: minmax(0, 1fr); }
}

.sp-card {
    background: var(--ui-block-bg, #fff);
    border: var(--ui-block-border, 1px solid rgba(15, 23, 42, .08));
    border-radius: var(--ui-block-border-radius-lg, 18px);
    box-shadow: var(--ui-block-shadow, 0 6px 18px rgba(15, 23, 42, .05));
}

.sp-doc { padding: clamp(24px, 3vw, 40px); }
.sp-doc + .sp-doc { margin-top: var(--ui-block-spacing-base, 20px); }

/* head ------------------------------------------------------------------ */
.sp-doc__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.sp-doc__brand { display: block; margin-bottom: 18px; }
.sp-doc__brand img { max-height: 46px; width: auto; }
.sp-doc__brand .logo-dark { display: none; }
body.dark-mode .sp-doc__brand .logo-light { display: none; }
body.dark-mode .sp-doc__brand .logo-dark { display: inline-block; }
.sp-doc__brand-name { margin: 0; font-size: var(--font-size-h4, 20px); font-weight: 700; }

.sp-doc__eyebrow {
    display: block;
    margin-bottom: 4px;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}

.sp-doc__title {
    margin: 0;
    font-size: clamp(24px, 3vw, var(--font-size-h2, 32px));
    font-weight: var(--font-weight-black, 900);
    line-height: 1.15;
}

.sp-doc__headside { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.sp-doc__amount { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; font-variant-numeric: tabular-nums; }

/* status pill ----------------------------------------------------------- */
.sp-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1.5px solid currentColor;
    font-size: var(--font-size-md, 14px);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.sp-pill i { font-size: 1em; }
.sp-pill[data-status="paid"], .sp-pill[data-status="received"], .sp-pill[data-status="active"] { color: var(--text-success-color, #27b85a); }
.sp-pill[data-status="unpaid"], .sp-pill[data-status="pending"], .sp-pill[data-status="processing"] { color: var(--text-warning-color, #f59f00); }
.sp-pill[data-status="canceled"], .sp-pill[data-status="declined"], .sp-pill[data-status="collections"] { color: var(--text-danger-color, #e5484d); }
.sp-pill[data-status="refunded"], .sp-pill[data-status="draft"], .sp-pill[data-status="payment-pending"] { color: var(--text-info-color, #0ea5e9); }

/* facts ----------------------------------------------------------------- */
.sp-doc__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
}

.sp-doc__facts > div { min-width: 0; }
.sp-doc__facts small {
    display: block;
    margin-bottom: 2px;
    font-size: var(--font-size-sm, 12px);
    font-weight: 600;
    color: var(--text-secondary-lighter-color, #6b7280);
}
.sp-doc__facts strong { font-size: var(--font-size-md, 14px); font-weight: 700; }

/* note ------------------------------------------------------------------ */
.sp-note {
    display: flex;
    gap: 14px;
    margin-top: 24px;
    padding: 16px 18px;
    border-radius: var(--ui-block-border-radius, 12px);
    border: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    background: var(--ui-block-bg-form, #fff);
    line-height: var(--line-height-md, 1.55);
}

.sp-note > i { margin-top: 3px; font-size: 18px; color: var(--text-secondary-lighter-color, #6b7280); }
.sp-note--ok { border-color: color-mix(in srgb, var(--text-success-color, #27b85a) 40%, transparent); }
.sp-note--ok > i { color: var(--text-success-color, #27b85a); }
.sp-note--bad { border-color: color-mix(in srgb, var(--text-danger-color, #e5484d) 40%, transparent); }
.sp-note--bad > i { color: var(--text-danger-color, #e5484d); }
.sp-note--info { border-color: color-mix(in srgb, var(--text-info-color, #0ea5e9) 40%, transparent); }
.sp-note--info > i { color: var(--text-info-color, #0ea5e9); }

/* parties --------------------------------------------------------------- */
.sp-doc__parties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    margin-top: 28px;
}

@media (max-width: 575px) { .sp-doc__parties { grid-template-columns: minmax(0, 1fr); } }

.sp-doc__party > strong {
    display: block;
    margin-bottom: 8px;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}

.sp-doc__party address {
    margin: 0;
    font-style: normal;
    line-height: var(--line-height-md, 1.55);
}

/* sections and tables ---------------------------------------------------- */
.sp-doc__section-title {
    margin: 32px 0 12px;
    font-size: var(--font-size-sm, 12px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}

.sp-table-shell {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    border-radius: var(--ui-block-border-radius, 12px);
}

.sp-table { width: 100%; margin: 0; border-collapse: collapse; }
.sp-table th, .sp-table td { padding: 14px 18px; text-align: left; vertical-align: top; }
.sp-table thead th {
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
    border-bottom: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    white-space: nowrap;
}
.sp-table tbody tr + tr td { border-top: 1px solid var(--ui-block-secondary-divider-border-color, rgba(15, 23, 42, .06)); }
.sp-table th.sp-table__num,
.sp-table td.sp-table__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-table tfoot th {
    border-top: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    font-size: var(--font-size-md, 14px);
    font-weight: 800;
    color: inherit;
    letter-spacing: 0;
    text-transform: none;
}

/* totals: one right edge, a single rule above the total ------------------- */
.sp-doc__totals {
    margin: 18px 0 0 auto;
    width: min(360px, 100%);
}

.sp-doc__totals > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    padding: 8px 18px;
}

.sp-doc__totals > div > span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.sp-doc__totals .is-total {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 2px solid var(--ui-block-border-color, rgba(15, 23, 42, .12));
    font-size: var(--font-size-lg, 16px);
}
.sp-doc__totals .is-total > span { font-weight: 800; }

.sp-doc__taxnote { margin: 10px 0 0; font-size: var(--font-size-sm, 12px); color: var(--text-secondary-lighter-color, #6b7280); }

/* side ------------------------------------------------------------------- */
.sp-doc-side { display: grid; gap: var(--ui-block-spacing-base, 20px); }
.sp-side-card { padding: var(--ui-block-padding-lg, 24px); }
.sp-side-card__eyebrow {
    display: block;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary-lighter-color, #6b7280);
}
.sp-side-card__amount { margin: 6px 0 16px; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sp-side-card__amount--sm { font-size: 22px; }
.sp-side-card__label { display: block; margin-bottom: 6px; font-weight: 600; }
.sp-side-card .form-control { width: 100%; }
.sp-side-card .payment-form { margin-top: 14px; }
.sp-side-card .payment-form .btn { width: 100%; }
.sp-side-card__hint { margin: 6px 0 0; font-size: var(--font-size-sm, 12px); color: var(--text-secondary-lighter-color, #6b7280); }

.sp-actions { padding: 0; overflow: hidden; }
.sp-actions__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px var(--ui-block-padding-lg, 24px);
    border-bottom: 1px solid var(--ui-block-border-color, rgba(15, 23, 42, .08));
    font-weight: 700;
}
.sp-actions__head i { color: var(--primary, #4f56d9); }
.sp-actions__list { display: flex; flex-direction: column; }
.sp-actions__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px var(--ui-block-padding-lg, 24px);
    color: inherit;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.sp-actions__link + .sp-actions__link { border-top: 1px solid var(--ui-block-secondary-divider-border-color, rgba(15, 23, 42, .06)); }
.sp-actions__link i { width: 18px; text-align: center; color: var(--ui-icon-color, #6b7280); }
.sp-actions__link:hover, .sp-actions__link:focus {
    background: var(--ui-nav-link-active-bg, rgba(79, 86, 217, .1));
    color: var(--primary, #4f56d9);
    text-decoration: none;
}
.sp-actions__link:hover i, .sp-actions__link:focus i { color: inherit; }

/* print ------------------------------------------------------------------ */
@media print {
    body { background: #fff !important; }
    .sp-print-hide,
    .mtd-breadcrumb,
    .mtd-global-page-header,
    .sp-doc-side,
    header.header,
    .header-main,
    .navbar,
    #header,
    #footer,
    .footer,
    .mtd-footer,
    .cc-window,
    .partners,
    .mtd-partners,
    .wbams-powered-by,
    .back-to-top { display: none !important; }
    .sp-doc-layout { display: block; }
    .sp-card { box-shadow: none !important; border-color: #ddd !important; }
    .sp-doc { padding: 0; border: 0; }
    .sp-pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sp-table-shell { overflow: visible; }
    .sp-doc__section-title { break-after: avoid; }
    .sp-table { break-inside: auto; }
    .sp-table tr { break-inside: avoid; }

    /* Paper is white whatever the screen was: a dark-mode document printed as
       light text on an unprinted background comes out blank. */
    body.dark-mode {
        --ui-block-bg: #ffffff;
        --ui-block-bg-form: #ffffff;
        --ui-block-border-color: #dddddd;
        --ui-block-secondary-divider-border-color: #eeeeee;
        --text-secondary-body-color: #333333;
        --text-secondary-lighter-color: #555555;
        --text-secondary-faded-color: #666666;
        --ui-icon-color: #555555;
        background: #ffffff !important;
        color: #111111 !important;
    }
    body.dark-mode .sp-doc,
    body.dark-mode .sp-doc h1,
    body.dark-mode .sp-doc h2,
    body.dark-mode .sp-doc a,
    body.dark-mode .sp-doc address,
    body.dark-mode .sp-doc strong,
    body.dark-mode .sp-doc th,
    body.dark-mode .sp-doc td,
    body.dark-mode .sp-doc span:not(.sp-pill):not(.sp-pill *) { color: #111111 !important; }
    body.dark-mode .sp-doc__eyebrow,
    body.dark-mode .sp-doc__facts small,
    body.dark-mode .sp-doc__party > strong,
    body.dark-mode .sp-doc__section-title,
    body.dark-mode .sp-table thead th { color: #555555 !important; }
    body.dark-mode .sp-doc__brand .logo-light { display: inline-block !important; }
    body.dark-mode .sp-doc__brand .logo-dark { display: none !important; }
    body.dark-mode.gray_logos .sp-doc__brand img { filter: none !important; }
}
