/* receipt_detail.css
 * ============================================================
 * Session 12 Pillar B — receipt-style rendering.
 *
 * Used by:
 *   - /receipts/<id> standalone route (commit 9)
 *   - /receipts/<id>/pdf WeasyPrint render source (commit 13)
 *   - Dashboard receipt modal re-skin (commit 10) — design tokens
 *     shared so the modal and the page look like the same artefact
 *
 * Design intent (per brief Pillar B): looks like a real-world
 * receipt but elevated. Mobile-first. Stripe-receipt / Monzo-
 * transaction / Apple-Wallet-pass reference.
 * ============================================================ */

:root {
    --receipt-bg: #ffffff;
    --receipt-text: #1a1a1a;
    --receipt-muted: #6b7280;
    --receipt-divider: #e5e7eb;
    --receipt-accent: #14b86a;
    --receipt-card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.04);
    --receipt-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    --receipt-sans: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
}

/* Page wrapper — standalone /receipts/<id> route */
.receipt-page {
    max-width: 480px;
    margin: 32px auto;
    padding: 0 16px;
    font-family: var(--receipt-sans);
    color: var(--receipt-text);
}

.receipt-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--receipt-sans);
    font-size: 13px;
    color: var(--receipt-muted);
    text-decoration: none;
    margin-bottom: 16px;
}
.receipt-back:hover { color: var(--receipt-text); }

/* The card itself — drop-shadow + rounded; PDF mode strips shadow */
.receipt-card {
    background: var(--receipt-bg);
    border-radius: 16px;
    box-shadow: var(--receipt-card-shadow);
    padding: 32px 24px;
}

.receipt-header { text-align: center; }
.merchant-logo, .merchant-initial {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 12px;
    object-fit: contain;
    display: flex;
    align-items: center;
    justify-content: center;
}
.merchant-initial {
    background: var(--receipt-accent);
    color: white;
    font-size: 22px;
    font-weight: 600;
    font-family: var(--receipt-sans);
}
.merchant-name {
    font-family: var(--receipt-sans);
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--receipt-text);
}
.merchant-meta {
    font-family: var(--receipt-sans);
    font-size: 12px;
    color: var(--receipt-muted);
    line-height: 1.55;
}
.merchant-meta > div { margin-top: 2px; }

.receipt-divider {
    border: none;
    border-top: 1px dashed var(--receipt-divider);
    margin: 20px 0;
}

.receipt-items {
    width: 100%;
    font-family: var(--receipt-mono);
    font-size: 13px;
    border-collapse: collapse;
}
.receipt-items td {
    padding: 6px 0;
    vertical-align: top;
}
.item-qty { width: 32px; color: var(--receipt-muted); }
.item-name { padding-right: 12px; }
.item-modifiers {
    font-size: 11px;
    color: var(--receipt-muted);
    margin-top: 2px;
    font-family: var(--receipt-mono);
}
.item-price {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.receipt-totals {
    font-family: var(--receipt-mono);
    font-variant-numeric: tabular-nums;
}
.total-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}
.total-final {
    font-size: 17px;
    font-weight: 600;
    padding-top: 8px;
    border-top: 1px solid var(--receipt-divider);
    margin-top: 6px;
}

.receipt-payment {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    justify-content: center;
    font-family: var(--receipt-sans);
    color: var(--receipt-text);
}
.receipt-payment .wallet-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: #000;
    color: #fff;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: var(--receipt-sans);
}
.receipt-payment .wallet-badge.google {
    background: #4285F4;
}
.receipt-payment .card-brand {
    font-weight: 500;
    color: var(--receipt-text);
}
.receipt-payment .card-last4 {
    font-family: var(--receipt-mono);
    color: var(--receipt-muted);
    font-variant-numeric: tabular-nums;
}

.receipt-footer {
    text-align: center;
    font-family: var(--receipt-sans);
    font-size: 11px;
    color: var(--receipt-muted);
    margin-top: 16px;
}
.receipt-footer .timestamp { margin-bottom: 2px; }
.receipt-footer .reference {
    font-family: var(--receipt-mono);
    margin-bottom: 14px;
}
.receipt-footer .ezeet-mark {
    margin-top: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--receipt-text);
    font-family: var(--receipt-sans);
}

/* Action bar — used by the dashboard modal re-skin (commit 10).
   Hidden by default on the standalone page; the route layer adds
   .with-actions to expose it. */
.receipt-actions {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 16px;
}
.receipt-actions.active { display: grid; }
.action-btn {
    padding: 13px;
    border-radius: 12px;
    border: 1px solid var(--receipt-divider);
    background: white;
    font-family: var(--receipt-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--receipt-text);
    cursor: pointer;
    text-align: center;
    /* Anchor variant (used when the backend returns provider_url —
       the success button is rendered as <a class="action-btn pushed">
       so the user can click straight through to the Xero/QB record). */
    text-decoration: none;
    display: block;
}
.action-btn:hover { background: #f9fafb; border-color: #d4d8de; }
.action-btn.pushed,
a.action-btn.pushed,
a.action-btn.pushed:hover {
    /* S12.5 commit 5 — WCAG AA contrast fix.
       Previous: rgba(20,184,106,0.08) bg + #14b86a text → 2.30:1 (fails AA 4.5:1).
       Now:     #0f7e4a bg + #ffffff text → 6.04:1 (passes AA 4.5:1). */
    background: #0f7e4a;
    border-color: #0f7e4a;
    color: #ffffff;
    cursor: default;
}
.action-btn.failed {
    /* S12.5 commit 5 — distinct failure state with verbatim error
       detail surfaced as a second line inside the button. Contrast
       #991b1b text on #fef2f2 bg → 9.31:1 (passes AA easily). */
    background: #fef2f2;
    border-color: #dc2626;
    color: #991b1b;
    cursor: pointer;
}
.action-btn.failed:hover {
    background: #fee2e2;
    border-color: #b91c1c;
}
.action-btn .action-btn-label {
    display: block;
    font-weight: 500;
}
.action-btn .action-btn-error-detail {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 10px;
    font-weight: 400;
    color: #7f1d1d;
    margin-top: 6px;
    line-height: 1.35;
    text-align: center;
    word-break: break-word;
}
.action-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile tightening */
@media (max-width: 480px) {
    .receipt-page { padding: 0 8px; }
    .receipt-card { padding: 24px 18px; }
    .receipt-actions { grid-template-columns: 1fr; }
}

/* Print / PDF — strip shadow + tighten the page for paper-style render */
@media print {
    body { background: #fff; }
    .receipt-back, .receipt-actions { display: none !important; }
    .receipt-card {
        box-shadow: none;
        border: 1px solid var(--receipt-divider);
        padding: 24px 20px;
    }
    .receipt-page { margin: 0 auto; }
}
