/* Receipt scan (js/receiptView.js): the add sheet's "📷 Quét hoá đơn" row, and the scan's screens inside the
   Diary's own #entry-detail-sheet (consent, reading, the review, errors). The rounded journal look of
   css/spend.css — its fields, chips, amount help and sticky Save bar (.fs-foot.xp-foot) are reused as they are;
   this file adds the photo, the unclear-field marks (a yellow tint AND a written reason — never colour alone),
   the totals block and the duplicate notice. Theme tokens only: sheets stay light in every period, the night
   one included. Loaded after css/spend.css. Nothing moves when the motion setting says so. */

/* ---- the add sheet: "Quét hoá đơn" (above the phrase / fields) ---- */
.xp-scan { margin: 0 0 12px; padding: 10px 12px 12px; border-radius: 16px; background: var(--peach-light); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--peach-strong) 18%, transparent); }
.xp-scan .xp-scan-label { margin: 0 0 8px; color: var(--text-primary); font-size: 14.5px; font-weight: 800; }
.xp-scan-btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.xp-scan-btns button.xp-scan-btn { min-height: 44px; margin: 0; padding: 6px 10px; background: var(--surface); font-size: 14.5px; line-height: 1.25; }
.xp-scan .xp-scan-resume { display: block; margin: 8px 0 0; font-size: 14px; }

/* ---- the scan's sheet: a sticky head while it shows (as the journal's own views) ---- */
#entry-detail-sheet:has(> #entry-detail-body > .rc-root) .entry-detail-head { position: sticky; top: -14px; z-index: 3; margin: -14px -16px 0; padding: 14px 16px 6px; background: var(--surface); }
.rc-root { color: var(--text-primary); }
.rc-root p { margin: 6px 0; }
.rc-root .xp-hint { margin: 6px 0 0; }
.rc-msg { font-size: 15px; font-weight: 700; line-height: 1.45; }
.rc-msg.rc-err { color: #A4231B; }
.rc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.rc-actions button { flex: 1 1 140px; min-height: 48px; margin: 0; padding: 8px 12px; font-size: 15px; line-height: 1.25; }
.rc-back { margin: 8px 0 0; }
.rc-back .link-btn { font-size: 14px; }

/* consent: who reads the photo, what is sent, what is kept */
.rc-card { margin: 4px 0 0; padding: 12px 14px; border-radius: 16px; background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--diary-line, var(--line)); font-size: 14.5px; line-height: 1.5; }
.rc-card-title { margin: 0 0 4px !important; font-size: 15.5px; font-weight: 800; }
.rc-points { margin: 6px 0 0; padding: 0 0 0 18px; }
:where(.rc-root) .rc-points li { display: list-item; padding: 2px 0; border-top: 0; font-size: 14px; }

/* preparing / reading */
.rc-busy { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px !important; font-size: 15px; font-weight: 700; }
.rc-thumb-wrap { display: flex; justify-content: center; margin: 4px 0 0; }
.rc-thumb { display: block; max-width: 100%; max-height: 28vh; border-radius: 12px; object-fit: contain; box-shadow: inset 0 0 0 1px var(--line); }

/* ---- the review ---- */
.rc-lead { color: var(--text-secondary); font-size: 13.5px; }
.rc-banner { margin: 0 0 8px !important; padding: 8px 10px; border-radius: 12px; background: var(--yellow-light); color: var(--yellow-ink); font-size: 13.5px; font-weight: 700; line-height: 1.4; }
.rc-banner.rc-warn { background: var(--coral-light); color: var(--diary-ink-coral, #8A3522); }
.rc-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.rc-main.xp-fields { gap: 12px; }
/* The photo stays a small thumbnail beside "Chụp lại" / "Đổi ảnh" (the amount stays near the top of a phone, short
   landscape phones keep the fields and the Save bar in view); a tap enlarges it to the sheet's width. */
.rc-photo-wrap { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 10px; align-items: center; }
button.rc-photo { display: block; max-width: 100%; margin: 0; padding: 0; border-radius: 14px; background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; cursor: zoom-in; }
button.rc-photo:hover { background: var(--surface-soft); }
button.rc-photo img { display: block; max-width: 100%; max-height: 20vh; margin: 0 auto; object-fit: contain; }
button.rc-photo.is-zoomed { grid-column: 1 / -1; width: 100%; cursor: zoom-out; }
button.rc-photo.is-zoomed img { width: 100%; max-height: none; }
button.rc-photo:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
.rc-nophoto { margin: 0 !important; padding: 10px 12px; border-radius: 12px; background: var(--surface-soft); color: var(--text-secondary); font-size: 13px; text-align: center; }
.rc-retake { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rc-retake button { min-width: 0; min-height: 44px; margin: 0; padding: 6px 10px; font-size: 14px; overflow-wrap: anywhere; }
/* No photo kept (a draft reopened after a reload): the note takes the whole width and "Chụp lại" / "Đổi ảnh" sit
   side by side under it — a sentence in an auto-sized column would push the buttons past a 320 px sheet. */
.rc-photo-wrap.is-nophoto { grid-template-columns: minmax(0, 1fr); }
.rc-photo-wrap.is-nophoto .rc-retake { flex-direction: row; flex-wrap: wrap; }
.rc-photo-wrap.is-nophoto .rc-retake button { flex: 1 1 120px; }

/* the fields (the journal's .xp-field, with room for a mark) */
.rc-field { padding: 0; border-radius: 14px; }
.rc-root input[type="text"], .rc-root input[type="date"], .rc-root input[type="time"], .rc-root select { box-sizing: border-box; width: 100%; min-width: 0; margin: 0; font-size: 16px; }
.rc-root .xp-row2 > div { min-width: 0; }
.rc-sub-label { margin-top: 8px !important; }
.rc-f-group .xp-groups { margin: 0; }
.rc-help { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; font-size: 13px; line-height: 1.4; }
.rc-help:empty { display: none; }
.rc-printed { color: var(--text-secondary); font-weight: 600; overflow-wrap: anywhere; }
.rc-note { color: var(--text-secondary); overflow-wrap: anywhere; }
.rc-why { color: var(--yellow-ink); font-weight: 800; }
.rc-ev { color: var(--text-secondary); font-style: italic; overflow-wrap: anywhere; }
/* Unclear (what the scan wasn't sure of): a yellow tint around the field + its reason in words. */
.rc-field.scan-unclear { margin: 0 -8px; padding: 8px; background: var(--yellow-light); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--yellow) 55%, transparent); }
.rc-field.scan-unclear input, .rc-field.scan-unclear select { border-color: color-mix(in srgb, var(--yellow-ink) 45%, var(--line-strong)); }
/* A field that blocks Save (Save was tapped): the journal's red line and message. */
.rc-root [aria-invalid="true"] { border-color: #C0584A; }
.rc-field.is-bad:not(.scan-unclear) { box-shadow: none; }
.rc-prob { flex: 1 1 100%; margin-top: 0; }
.rc-help .xp-readings { flex: 1 1 100%; }

/* the totals block (reference only) */
.rc-totals { padding: 10px 12px; border-radius: 14px; background: var(--surface-soft); }
.rc-totals .fs-label { margin: 0 0 4px; }
.rc-tlist { display: grid; gap: 2px; margin: 0; }
.rc-trow { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; font-size: 13.5px; }
.rc-trow dt { color: var(--text-secondary); font-weight: 700; }
.rc-trow dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.rc-trow.is-total dt, .rc-trow.is-total dd { color: var(--text-primary); font-weight: 800; }
.rc-ptext { white-space: nowrap; }
.rc-tread { color: var(--text-secondary); white-space: nowrap; }
.rc-totals .rc-why { margin: 6px 0 0; font-size: 13px; }

/* the items (reference only, collapsed) */
.rc-items, .xp-items { border-radius: 14px; background: var(--surface-soft); }
.rc-items > summary, .xp-items > summary { min-height: 44px; padding: 10px 12px; font-size: 14px; font-weight: 700; line-height: 1.35; cursor: pointer; }
.rc-items > summary:focus-visible, .xp-items > summary:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; border-radius: 12px; }
.rc-items > .xp-hint { margin: 0; padding: 0 12px 10px; }
.rc-item-list, .xp-item-list { margin: 0; padding: 0 12px 8px; list-style: none; }
:where(.rc-root, #entry-detail-sheet) .rc-item-list li, :where(#entry-detail-sheet) .xp-item-list li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0;
  border-top: 1px solid var(--diary-line, var(--line)); font-size: 13.5px; }
.rc-item-list li span, .xp-item-list li span { min-width: 0; overflow-wrap: anywhere; }
.rc-item-list li b, .xp-item-list li b { flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.xp-items { margin: 10px 0 0; }
.xp-nophoto { font-style: italic; }

/* likely duplicate: what it may be, "Mở khoản đã có" / "Đây là lần mua khác" */
.rc-dup { margin: 0 0 10px; padding: 10px 12px; border-radius: 14px; background: var(--coral-light); color: var(--diary-ink-coral, #8A3522); }
.rc-dup:focus { outline: none; }
.rc-dup:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
.rc-dup-title { margin: 0 0 4px !important; font-size: 14.5px; font-weight: 800; }
.rc-dup-list { margin: 0; padding: 0; list-style: none; }
:where(.rc-root) .rc-dup-list li { display: block; padding: 3px 0; border-top: 0; font-size: 14px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.rc-dup-why { font-weight: 600; }
.rc-dup .link-btn { color: var(--diary-ink-coral, #8A3522); font-size: 14px; }
.rc-dup .rc-actions { margin: 8px 0 0; }
.rc-dup .rc-actions button { background: var(--surface); }
.rc-dup-note { font-size: 13px; font-weight: 700; }

/* the sticky Save bar (css/spend.css #entry-detail-sheet .xp-foot reaches the sheet's bottom edge; here also its
   sides, so a marked field scrolling under it never shows beside it) */
#entry-detail-sheet .rc-foot { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
.rc-foot .editor-actions .rc-save { flex: 2; }
.rc-foot button[aria-disabled="true"], .rc-retake button[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
/* A field focused after a refused Save scrolls clear of the sticky head and the Save bar. */
#entry-detail-sheet .rc-root [data-focus] { scroll-margin: 72px 0 190px; }

/* Wide and landscape (a rotated tablet, a desktop, a phone on its side): the photo beside the fields. */
@media (min-width: 700px) and (orientation: landscape) {
  .rc-review .rc-grid { grid-template-columns: minmax(150px, 34%) minmax(0, 1fr); align-items: start; }
  .rc-review .rc-side { position: sticky; top: 52px; }
  .rc-review .rc-photo-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .rc-review .rc-retake { width: 100%; }
  .rc-review button.rc-photo img { max-height: 46vh; }
  .rc-review button.rc-photo.is-zoomed img { max-height: none; }
}
@media (max-width: 340px) {
  .xp-scan-btns { grid-template-columns: minmax(0, 1fr); }
  .rc-actions button { flex-basis: 100%; }
}
/* Touch: 44 px targets */
@media (pointer: coarse) { .rc-root .chip, .rc-root .link-btn, .xp-scan .link-btn { min-height: 44px; } }
/* Motion */
html[data-motion="reduced"] .rc-root .progress-dot, html[data-motion="off"] .rc-root .progress-dot { animation: none; }
@media (prefers-reduced-motion: reduce) { .rc-root .progress-dot { animation: none; } }
