/* ============================================
   Invoice OCR Scanning Animation
   Colors matched to Eagle Doc brand palette
   ============================================ */

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

.invoice-animation-scene {
    position: relative;
    width: 100%;
    padding-bottom: 130%;
    /* 10:13 aspect ratio for invoice */
}

/* ── Invoice Paper ── */
.invoice-paper {
    position: absolute;
    inset: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow:
        0 2px 20px rgba(26, 47, 110, 0.10),
        0 8px 40px rgba(0, 0, 0, 0.06);
    padding: 14% 8% 8%;
    display: flex;
    flex-direction: column;
    gap: 5%;
    overflow: hidden;
    animation: invoiceFadeIn 0.8s ease-out both;
}

@keyframes invoiceFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Invoice Header Area ── */
.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.inv-logo-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inv-logo {
    width: 50%;
    height: 10px;
    background: #d0d0d8;
    border-radius: 3px;
}

.inv-company-lines {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
}

.inv-company-line {
    height: 5px;
    background: #e2e2ea;
    border-radius: 2px;
}

.inv-company-line:nth-child(1) { width: 70px; }
.inv-company-line:nth-child(2) { width: 55px; }
.inv-company-line:nth-child(3) { width: 60px; }

.inv-title-block {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.inv-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: #1A2F6E;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
}

.inv-meta-lines {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
}

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

.inv-meta-line:nth-child(1) { width: 80px; }
.inv-meta-line:nth-child(2) { width: 65px; }
.inv-meta-line:nth-child(3) { width: 70px; }

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

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

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

@keyframes aiPulse {
    0%, 25% { opacity: 0; border-color: transparent; }
    30% {
        opacity: 1;
        border-color: rgba(163, 3, 1, 0.5);
        box-shadow: inset 0 0 30px rgba(163, 3, 1, 0.05), 0 0 20px rgba(163, 3, 1, 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 ── */
.inv-ai-badge {
    position: absolute;
    top: 3%;
    right: 3%;
    background: linear-gradient(135deg, #A30301, #C51311);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.1em;
    z-index: 15;
    opacity: 0;
    transform: scale(0.7);
    animation: aiBadge 8s ease-in-out infinite;
    box-shadow: 0 2px 10px rgba(163, 3, 1, 0.3);
}

@keyframes aiBadge {
    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 ── */
.inv-field {
    position: relative;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* Highlight overlay pseudo-element */
.inv-field::before {
    content: '';
    position: absolute;
    inset: -3px -5px;
    border-radius: 5px;
    border: 2px solid transparent;
    background: transparent;
    opacity: 0;
    z-index: 2;
    pointer-events: none;
}

/* Field label tooltip */
.inv-field::after {
    position: absolute;
    font-size: 0.5rem;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
    color: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    opacity: 0;
    z-index: 3;
    pointer-events: none;
    letter-spacing: 0.03em;
}

/* ── Field: Vendor (company name area) ── */
.inv-field-vendor::before {
    animation: highlightField 8s ease-in-out infinite;
    animation-delay: 0s;
    border-color: #A30301;
    background: rgba(163, 3, 1, 0.06);
}
.inv-field-vendor::after {
    content: attr(data-label);
    top: -12px;
    left: -5px;
    background: #A30301;
    animation: showLabel 8s ease-in-out infinite;
    animation-delay: 0s;
}

/* ── Field: Invoice Number + Date ── */
.inv-field-meta::before {
    animation: highlightField 8s ease-in-out infinite;
    animation-delay: 0.4s;
    border-color: #1A2F6E;
    background: rgba(26, 47, 110, 0.06);
}
.inv-field-meta::after {
    content: attr(data-label);
    top: -12px;
    right: -5px;
    background: #1A2F6E;
    animation: showLabel 8s ease-in-out infinite;
    animation-delay: 0.4s;
}

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

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

/* ── Field: Total Amount ── */
.inv-field-total::before {
    animation: highlightField 8s ease-in-out infinite;
    animation-delay: 1.5s;
    border-color: #A30301;
    background: rgba(163, 3, 1, 0.08);
}
.inv-field-total::after {
    content: attr(data-label);
    bottom: -12px;
    right: -5px;
    background: #A30301;
    animation: showLabel 8s ease-in-out infinite;
    animation-delay: 1.5s;
}

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

@keyframes showLabel {
    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; }
}

/* ── Line Items Table ── */
.inv-table-header {
    display: flex;
    gap: 4%;
    padding-bottom: 4px;
    border-bottom: 1.5px solid #1A2F6E;
    margin-bottom: 6px;
}

.inv-table-header span {
    font-size: 0.45rem;
    font-weight: 700;
    color: #1A2F6E;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: 'Roboto', sans-serif;
    flex-shrink: 0;
}

.inv-table-header span:nth-child(1) { width: 42%; }
.inv-table-header span:nth-child(2) { width: 8%; }
.inv-table-header span:nth-child(3) { width: 12%; }
.inv-table-header span:nth-child(4) { width: 12%; }

.inv-table-row {
    display: flex;
    gap: 4%;
    align-items: center;
    padding: 2px 0;
    border-bottom: 1px solid #f0f0f5;
}

.inv-table-cell {
    height: 4px;
    background: #e2e2ea;
    border-radius: 2px;
    flex-shrink: 0;
}

.inv-table-cell.desc {
    width: 42%;
    background: transparent;
    position: relative;
}

.inv-table-cell.desc::before {
    content: '';
    display: block;
    width: var(--bw, 100%);
    height: 100%;
    background: #e2e2ea;
    border-radius: 2px;
}

.inv-table-cell.qty { width: 8%; }
.inv-table-cell.price { width: 12%; }
.inv-table-cell.amt { width: 12%; }

/* ── Totals Area ── */
.inv-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-top: auto;
}

.inv-total-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.inv-total-label {
    height: 5px;
    width: 45px;
    background: #d8d8e2;
    border-radius: 2px;
}

.inv-total-value {
    height: 5px;
    width: 55px;
    background: #d0d0da;
    border-radius: 2px;
}

.inv-total-row.grand .inv-total-label {
    height: 7px;
    width: 55px;
    background: #1A2F6E;
    border-radius: 3px;
}

.inv-total-row.grand .inv-total-value {
    height: 7px;
    width: 65px;
    background: #A30301;
    border-radius: 3px;
}

/* ── Floating Data Particles ── */
.inv-particles {
    display: none;
    z-index: 4;
    overflow: hidden;
    border-radius: 12px;
}

.inv-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    opacity: 0;
}

.inv-particle:nth-child(1) {
    background: #A30301;
    top: 20%;
    left: 15%;
    animation: particleFloat 8s ease-in-out infinite 2.5s;
}
.inv-particle:nth-child(2) {
    background: #1A2F6E;
    top: 40%;
    right: 20%;
    animation: particleFloat 8s ease-in-out infinite 2.7s;
}
.inv-particle:nth-child(3) {
    background: #00796B;
    top: 60%;
    left: 30%;
    animation: particleFloat 8s ease-in-out infinite 2.9s;
}
.inv-particle:nth-child(4) {
    background: #E65100;
    bottom: 25%;
    right: 25%;
    animation: particleFloat 8s ease-in-out infinite 3.1s;
}
.inv-particle:nth-child(5) {
    background: #A30301;
    top: 35%;
    left: 60%;
    animation: particleFloat 8s ease-in-out infinite 3.3s;
}
.inv-particle:nth-child(6) {
    background: #1A2F6E;
    bottom: 40%;
    left: 45%;
    animation: particleFloat 8s ease-in-out infinite 3.0s;
}

@keyframes particleFloat {
    0%, 28% { opacity: 0; transform: scale(0) translateY(0); }
    32% { opacity: 0.7; transform: scale(1) translateY(0); }
    36% { opacity: 0; transform: scale(0.5) translateY(-20px); }
    100% { opacity: 0; }
}

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

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