/* ============================================
   Receipt OCR Scanning Animation
   Adapted from Invoice OCR animation
   Receipt-specific: narrower, taller, barcode,
   no table header, dashed dividers
   ============================================ */

.receipt-animation-wrapper {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
    perspective: 800px;
}

.receipt-animation-scene {
    position: relative;
    width: 100%;
    padding-bottom: 185%; /* taller ratio for receipt + room for fringes */
    overflow: visible;
}

/* ── Torn Paper Fringes (via pseudo-elements, always visible) ── */
.receipt-animation-scene::before,
.receipt-animation-scene::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    z-index: 20;
    pointer-events: none;
}

.receipt-animation-scene::before {
    bottom: calc(96% - 1px);
    background-repeat: repeat-x;
    background-position: top left;
    background-size: 16px 12px;
    background-image:
        linear-gradient(315deg, #fffdf9 6px, transparent 0),
        linear-gradient(45deg, #fffdf9 6px, transparent 0);
    filter: drop-shadow(0 -1px 1px rgba(0, 0, 0, 0.08));
}

.receipt-animation-scene::after {
    top: calc(96% - 1px);
    background-repeat: repeat-x;
    background-position: bottom left;
    background-size: 16px 12px;
    background-image:
        linear-gradient(225deg, #fffdf9 6px, transparent 0),
        linear-gradient(135deg, #fffdf9 6px, transparent 0);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.08));
}

/* ── Receipt Paper ── */
.receipt-paper {
    position: absolute;
    top: 4%;
    bottom: 4%;
    left: 0;
    right: 0;
    z-index: 1;
    background: #fffdf9;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(0, 0, 0, 0.008) 3px,
            rgba(0, 0, 0, 0.008) 4px
        );
    border-radius: 0;
    box-shadow:
        0 2px 20px rgba(26, 47, 110, 0.10),
        0 8px 40px rgba(0, 0, 0, 0.06),
        inset 0 0 30px rgba(0, 0, 0, 0.015);
    padding: 10% 8% 6%;
    display: flex;
    flex-direction: column;
    gap: 5%;
    overflow: hidden;
}

/* ── Store Header ── */
.rcpt-store-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.rcpt-store-logo {
    width: 60%;
    height: 12px;
    background: #9898a8;
    border-radius: 2px;
    margin: 0 auto;
}

.rcpt-store-lines {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
}

.rcpt-store-line {
    height: 3px;
    background: #d5d5dd;
    border-radius: 1px;
}

/* ── Meta (Date/Time/Receipt #) ── */
.rcpt-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.rcpt-meta-line {
    height: 4px;
    background: #e8e8f0;
    border-radius: 2px;
}

/* ── Dividers ── */
.rcpt-divider {
    height: 1px;
    background: #d8d8e2;
    width: 100%;
}

.rcpt-divider.dashed {
    background: none;
    border-top: 1px dashed #d0d0da;
}

/* ── Line Items ── */
.rcpt-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5px 0;
}

.rcpt-item-name {
    height: 4px;
    background: transparent;
    border-radius: 2px;
    position: relative;
    flex: 1;
    margin-right: 10%;
}

.rcpt-item-name::before {
    content: '';
    display: block;
    width: var(--rw, 100%);
    height: 100%;
    background: #d5d5dd;
    border-radius: 1px;
}

.rcpt-item-price {
    width: 22%;
    height: 4px;
    background: #d5d5dd;
    border-radius: 1px;
    flex-shrink: 0;
}

/* ── Totals Area ── */
.rcpt-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.rcpt-total-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rcpt-total-label {
    height: 4px;
    width: 40px;
    background: #d8d8e2;
    border-radius: 2px;
}

.rcpt-total-value {
    height: 4px;
    width: 48px;
    background: #d0d0da;
    border-radius: 2px;
}

.rcpt-total-row.grand .rcpt-total-label {
    height: 6px;
    width: 50px;
    background: #1a2f6e;
    border-radius: 3px;
}

.rcpt-total-row.grand .rcpt-total-value {
    height: 6px;
    width: 58px;
    background: #1a2f6e;
    border-radius: 3px;
}

/* ── Payment Method ── */
.rcpt-payment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.rcpt-payment-line {
    height: 4px;
    background: #e8e8f0;
    border-radius: 2px;
}

/* ── QR Code (Easter Egg → www.eagle-doc.com) ── */
.rcpt-qr-code {
    display: flex;
    justify-content: center;
    margin-top: auto;
    padding-top: 6px;
}

.rcpt-qr-code a {
    display: block;
    width: 48px;
    height: 48px;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.rcpt-qr-code a:hover {
    opacity: 1;
}

.rcpt-qr-code img {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

/* ── Scanline ── */
.rcpt-scanline {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(26, 47, 110, 0.15) 15%,
        #1a2f6e 50%,
        rgba(26, 47, 110, 0.15) 85%,
        transparent 100%);
    box-shadow:
        0 0 15px rgba(26, 47, 110, 0.4),
        0 0 40px rgba(26, 47, 110, 0.15);
    opacity: 0;
    z-index: 10;
    animation: rcptScanLine 8s ease-in-out infinite;
}

@keyframes rcptScanLine {
    0%  { top: 2%; opacity: 0; }
    3%  { opacity: 1; }
    25% { top: 98%; opacity: 1; }
    28% { opacity: 0; }
    100% { opacity: 0; top: 98%; }
}

/* ── AI Processing Pulse ── */
.rcpt-ai-pulse {
    position: absolute;
    inset: 0;
    border-radius: 0;
    border: 2px solid transparent;
    opacity: 0;
    z-index: 5;
    animation: rcptAiPulse 8s ease-in-out infinite;
}

@keyframes rcptAiPulse {
    0%, 25%  { opacity: 0; border-color: transparent; }
    30% {
        opacity: 1;
        border-color: rgba(26, 47, 110, 0.5);
        box-shadow: inset 0 0 30px rgba(26, 47, 110, 0.05), 0 0 20px rgba(26, 47, 110, 0.1);
    }
    35% {
        opacity: 1;
        border-color: rgba(26, 47, 110, 0.4);
        box-shadow: inset 0 0 30px rgba(26, 47, 110, 0.05), 0 0 20px rgba(26, 47, 110, 0.1);
    }
    40% { opacity: 0; border-color: transparent; box-shadow: none; }
    100% { opacity: 0; }
}

/* ── AI Badge ── */
.rcpt-ai-badge {
    position: absolute;
    top: 3%;
    right: 3%;
    background: linear-gradient(135deg, #1a2f6e, #142252);
    color: #fff;
    font-size: 0.5rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: 0.1em;
    z-index: 15;
    opacity: 0;
    transform: scale(0.7);
    animation: rcptAiBadge 8s ease-in-out infinite;
    box-shadow: 0 2px 10px rgba(26, 47, 110, 0.3);
}

@keyframes rcptAiBadge {
    0%, 28%  { opacity: 0; transform: scale(0.7); }
    33%      { opacity: 1; transform: scale(1); }
    85%      { opacity: 1; transform: scale(1); }
    92%      { opacity: 0; transform: scale(0.7); }
    100%     { opacity: 0; }
}

/* ── Highlighted Fields ── */
.rcpt-field {
    position: relative;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.rcpt-field::before {
    content: '';
    position: absolute;
    inset: -3px -5px;
    border-radius: 4px;
    border: 2px solid transparent;
    background: transparent;
    opacity: 0;
    z-index: 2;
    pointer-events: none;
}

.rcpt-field::after {
    position: absolute;
    font-size: 0.45rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    opacity: 0;
    z-index: 3;
    pointer-events: none;
    letter-spacing: 0.03em;
}

/* Field: Merchant (store name) */
.rcpt-field-merchant::before {
    animation: rcptHighlightField 8s ease-in-out infinite;
    animation-delay: 0s;
    border-color: #1a2f6e;
    background: rgba(26, 47, 110, 0.06);
}
.rcpt-field-merchant::after {
    content: attr(data-label);
    top: -12px;
    left: 50%;
    transform: translateX(-50%) translateY(3px);
    background: #1a2f6e;
    animation: rcptShowLabelCenter 8s ease-in-out infinite;
    animation-delay: 0s;
}

/* Field: Date / Time */
.rcpt-field-date::before {
    animation: rcptHighlightField 8s ease-in-out infinite;
    animation-delay: 0.4s;
    border-color: #1a2f6e;
    background: rgba(26, 47, 110, 0.06);
}
.rcpt-field-date::after {
    content: attr(data-label);
    top: -12px;
    right: -5px;
    background: #1a2f6e;
    animation: rcptShowLabel 8s ease-in-out infinite;
    animation-delay: 0.4s;
}

/* Field: Items */
.rcpt-field-items::before {
    animation: rcptHighlightField 8s ease-in-out infinite;
    animation-delay: 0.8s;
    border-color: #00796B;
    background: rgba(0, 121, 107, 0.05);
}
.rcpt-field-items::after {
    content: attr(data-label);
    top: -12px;
    left: -5px;
    background: #00796B;
    animation: rcptShowLabel 8s ease-in-out infinite;
    animation-delay: 0.8s;
}

/* Field: Tax */
.rcpt-field-tax::before {
    animation: rcptHighlightField 8s ease-in-out infinite;
    animation-delay: 1.2s;
    border-color: #E65100;
    background: rgba(230, 81, 0, 0.05);
}
.rcpt-field-tax::after {
    content: attr(data-label);
    top: -4px;
    right: -5px;
    background: #E65100;
    animation: rcptShowLabel 8s ease-in-out infinite;
    animation-delay: 1.2s;
}

/* Field: Total */
.rcpt-field-total::before {
    animation: rcptHighlightField 8s ease-in-out infinite;
    animation-delay: 1.5s;
    border-color: #1a2f6e;
    background: rgba(26, 47, 110, 0.08);
}
.rcpt-field-total::after {
    content: attr(data-label);
    bottom: -12px;
    right: -5px;
    background: #1a2f6e;
    animation: rcptShowLabel 8s ease-in-out infinite;
    animation-delay: 1.5s;
}

/* Field: Payment */
.rcpt-field-payment::before {
    animation: rcptHighlightField 8s ease-in-out infinite;
    animation-delay: 1.8s;
    border-color: #6A1B9A;
    background: rgba(106, 27, 154, 0.05);
}
.rcpt-field-payment::after {
    content: attr(data-label);
    top: -12px;
    left: 50%;
    transform: translateX(-50%) translateY(3px);
    background: #6A1B9A;
    animation: rcptShowLabelCenter 8s ease-in-out infinite;
    animation-delay: 1.8s;
}

@keyframes rcptHighlightField {
    0%, 32%  { opacity: 0; }
    38%      { opacity: 1; }
    82%      { opacity: 1; }
    90%      { opacity: 0; }
    100%     { opacity: 0; }
}

@keyframes rcptShowLabel {
    0%, 32%  { opacity: 0; transform: translateY(3px); }
    38%      { opacity: 1; transform: translateY(0); }
    82%      { opacity: 1; transform: translateY(0); }
    90%      { opacity: 0; transform: translateY(3px); }
    100%     { opacity: 0; }
}

@keyframes rcptShowLabelCenter {
    0%, 32%  { opacity: 0; transform: translateX(-50%) translateY(3px); }
    38%      { opacity: 1; transform: translateX(-50%) translateY(0); }
    82%      { opacity: 1; transform: translateX(-50%) translateY(0); }
    90%      { opacity: 0; transform: translateX(-50%) translateY(3px); }
    100%     { opacity: 0; }
}

/* ── Responsive ── */
@media (max-width: 991px) {
    .receipt-animation-wrapper {
        max-width: 220px;
        margin-top: 2rem;
    }

    .rcpt-fringe {
        height: 10px;
        background-size: 14px 10px;
    }

    .receipt-animation-scene::before,
    .receipt-animation-scene::after {
        height: 10px;
        background-size: 14px 10px;
    }
}

@media (max-width: 767px) {
    .receipt-animation-wrapper {
        display: none;
    }
}
