/**
 * Invoice Workflow Animation Styles
 * Scoped and isolated CSS to prevent conflicts with existing Bootstrap styles
 */

/* =================================
   CSS CUSTOM PROPERTIES (VARIABLES) - ROOT LEVEL
   ================================= */
:root {
    /* Invoice Workflow Colors - Available globally for SVG */
    --iwf-bg1: #0f1226;
    --iwf-bg2: #111a3a;
    --iwf-accent: #5ef3d2;
    --iwf-accent2: #7aa0ff;
    --iwf-accent3: #9bff8f;
    --iwf-ink: #000000;
    --iwf-muted: #8fa3ff;
    --iwf-danger: #ff6d7a;
    --iwf-ok: #34d399;
    --iwf-warn: #ffcf5a;
    --iwf-card: #141b36;
    --iwf-line: #2a3568;
    --iwf-shadow: 0 20px 50px rgba(0,0,0,.35);
}

/* =================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ================================= */
.invoice-workflow-container {
    /* Color palette - scoped to avoid global conflicts */
    --iwf-bg1: #0f1226;
    --iwf-bg2: #111a3a;
    --iwf-accent: #5ef3d2;
    --iwf-accent2: #7aa0ff;
    --iwf-accent3: #9bff8f;
    --iwf-ink: #e8ecff;
    --iwf-muted: #8fa3ff;
    --iwf-danger: #ff6d7a;
    --iwf-ok: #34d399;
    --iwf-warn: #ffcf5a;
    --iwf-card: #141b36;
    --iwf-line: #2a3568;
    --iwf-shadow: 0 20px 50px rgba(0,0,0,.35);

    /* Ensure proper box model and isolation */
    box-sizing: border-box;
    position: relative;
    isolation: isolate;
}

/* =================================
   BASE CONTAINER STYLES
   ================================= */
.invoice-workflow-container *,
.invoice-workflow-container *::before,
.invoice-workflow-container *::after {
    box-sizing: border-box;
}

.invoice-workflow-container {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--iwf-ink);
    background: radial-gradient(1200px 600px at 20% 20%, #1a2152 0%, transparent 60%),
    radial-gradient(900px 500px at 80% 10%, #173a46 0%, transparent 60%),
    linear-gradient(160deg, var(--iwf-bg1), var(--iwf-bg2));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* =================================
   LAYOUT COMPONENTS
   ================================= */
.iwf-wrap {
    max-width: 1100px;
    margin: 32px auto;
    padding: 16px;
}

.iwf-container {
    /* Bootstrap-like container functionality without conflicts */
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .iwf-container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .iwf-container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .iwf-container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .iwf-container {
        max-width: 1140px;
    }
}

.iwf-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.iwf-title h1 {
    font-weight: 800;
    margin: 0;
    font-size: clamp(20px, 2.2vw, 28px);
    color: var(--iwf-ink);
}

.iwf-pill {
    border: 1px solid var(--iwf-line);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    opacity: .9;
    color: var(--iwf-muted);
    background: rgba(255,255,255,.02);
}

/* =================================
   MAIN STAGE
   ================================= */
.iwf-stage {
    position: relative;
    margin-top: 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
    box-shadow: var(--iwf-shadow);
    border: 1px solid rgba(255,255,255,.05);
    overflow: hidden;
    min-height: 560px;
}

/* =================================
   HUD (HEADS-UP DISPLAY)
   ================================= */
.iwf-hud {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0,0,0,.3);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255,255,255,.1);
}

.iwf-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.iwf-btn {
    appearance: none;
    border: 1px solid var(--iwf-line);
    background: rgba(255,255,255,.04);
    color: var(--iwf-ink);
    border-radius: 12px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.2s ease;
}

.iwf-btn:hover:not(:disabled) {
    background: rgba(255,255,255,.08);
    transform: translateY(-1px);
}

.iwf-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.iwf-legend {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    opacity: .85;
    flex-wrap: wrap;
}

.iwf-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.iwf-dot.scan { background: var(--iwf-accent); }
.iwf-dot.tx { background: var(--iwf-accent2); }
.iwf-dot.proc { background: var(--iwf-warn); }
.iwf-dot.back { background: var(--iwf-ok); }

/* =================================
   SVG CONTAINER
   ================================= */
.iwf-svg-container {
    width: 100%;
    height: 100%;
    display: block;
    overflow: hidden;
}

.iwf-svg-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* =================================
   KEYFRAME ANIMATIONS - SCOPED
   ================================= */
@keyframes iwf-scanSweep {
    0% { transform: translateY(0px); opacity: 0.3; }
    20% { opacity: 0.8; }
    50% { transform: translateY(110px); opacity: 1; }
    80% { opacity: 0.6; }
    100% { transform: translateY(140px); opacity: 0.2; }
}

@keyframes iwf-rotate {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

@keyframes iwf-rotateReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

@keyframes iwf-flicker {
    0%, 100% { opacity: 1; }
    40% { opacity: .45; }
    60% { opacity: .8; }
}

@keyframes iwf-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes iwf-dataFlow {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.1); }
}

/* =================================
   SVG GEAR ANIMATIONS
   ================================= */
.iwf-stage svg g.rotor {
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.iwf-stage svg g.rotor.forward {
    animation: iwf-rotate 2s linear infinite;
}

.iwf-stage svg g.rotor.reverse {
    animation: iwf-rotateReverse 1.5s linear infinite;
}

/* =================================
   UI OVERLAYS
   ================================= */
.iwf-stepLabel {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(255,255,255,.04);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--iwf-ink);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,.1);
}

.iwf-toast {
    position: absolute;
    top: 18px;
    right: 18px;
    background: rgba(200,200,200,.85);
    border-radius: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,.05);
    opacity: 0;
    transform: translateY(-6px);
    color: var(--iwf-ink);
    font-size: 12px;
    max-width: 280px;
    backdrop-filter: blur(8px);
    z-index: 1000;
}

.iwf-toast.show {
    opacity: 1;
    transform: translateY(0);
    transition: all .28s ease;
}

.iwf-description {
    opacity: .85;
    margin-top: 12px;
    color: var(--iwf-muted);
    line-height: 1.5;
}

/* =================================
   UTILITY CLASSES
   ================================= */
/* Ensure no interference with Bootstrap toast notifications */
.iwf-toast:not(.bootstrap-toast) {
    position: absolute !important;
}

/* Loading state for fallback */
.iwf-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--iwf-muted);
}

/* =================================
   ACCESSIBILITY
   ================================= */
@media (prefers-reduced-motion: reduce) {
    .iwf-stage *,
    .iwf-stage *::before,
    .iwf-stage *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */
@media (max-width: 768px) {
    .iwf-stage {
        min-height: 400px;
    }

    .iwf-wrap {
        padding: 8px;
        margin: 16px auto;
    }

    .iwf-hud {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .iwf-svg-container svg {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .iwf-btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    .iwf-toast {
        right: 8px;
        top: 8px;
        max-width: 200px;
        font-size: 11px;
    }

    .iwf-stepLabel {
        left: 8px;
        top: 8px;
        font-size: 11px;
    }
}

/* =================================
   PRINT STYLES (OPTIONAL)
   ================================= */
@media print {
    .iwf-hud,
    .iwf-toast,
    .iwf-stepLabel {
        display: none !important;
    }

    .invoice-workflow-container {
        background: white !important;
        color: black !important;
    }
}

/* =================================
   HIGH CONTRAST MODE SUPPORT
   ================================= */
@media (prefers-contrast: high) {
    .iwf-stage {
        border: 2px solid currentColor;
    }

    .iwf-btn {
        border: 2px solid currentColor;
    }

    .iwf-toast,
    .iwf-stepLabel {
        border: 1px solid currentColor;
        background: rgba(0,0,0,.9);
    }
}