#scan-result-block {
    width: 100%;
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, opacity 0.3s ease;
    border-radius: 30px;
    margin: 0 auto 2rem auto;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.scan-result-success {
    background: linear-gradient(135deg, #19ff63 0%, #0de147 100%) !important;
    color: #000 !important;
}

.scan-result-error {
    background: linear-gradient(135deg, #ff2222 0%, #e01e1e 100%) !important;
    color: #fff !important;
}

.scan-result-inner {
    width: 100%;
    max-width: 800px;
    text-align: center;
    padding: 2.5rem 1rem;
    margin: auto;
}

.scan-result-header {
    margin-bottom: 1rem;
}

.scan-result-code {
    font-size: 3rem;
    font-weight: bold;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.6em;
    background: rgba(255,255,255,0.2);
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.scan-result-code .parcel-code {
    flex: 1;
    text-align: center;
}

.scan-result-code .icon-success {
    margin-left: 1rem;
    font-size: 2.5rem;
    color: #19ff63;
    background: #fff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.scan-result-code .icon-error {
    margin-left: 1rem;
    font-size: 2.5rem;
    color: #ff2222;
    background: #fff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.scan-result-meta {
    font-size: 1.15rem;
    margin-bottom: 1.5em;
    display: flex;
    justify-content: center;
    gap: 2em;
    opacity: 0.8;
}

.scan-result-type {
    font-size: 2.3rem;
    font-weight: bold;
    margin-bottom: 0.3em;
}

.scan-result-client {
    font-size: 1.1rem;
    margin-bottom: 1.8em;
}

.scan-result-action {
    margin-top: 2.5em;
}

.scan-result-action-content {
    background: #fff;
    color: #222;
    border-radius: 16px;
    padding: 0.8em 1.8em;
    display: inline-flex;
    align-items: center;
    font-size: 2.2rem;
    font-weight: bold;
    box-shadow: 0 4px 16px rgba(0,0,0,0.05);
}

.scan-result-action-content .icon-success,
.scan-result-action-content .icon-error {
    margin-left: 1em;
    font-size: 2.2rem;
}

.scan-result-buttons {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-problem {
    background: #444 !important;
    color: #fff !important;
    border: none;
    padding: 1rem 2rem;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.btn-problem:hover {
    background: #555 !important;
    transform: translateY(-2px);
}

.btn-retry {
    background: #fff !important;
    color: #ff2222 !important;
    border: 2px solid #fff;
    padding: 1rem 2rem;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.btn-retry:hover {
    background: #f8f8f8 !important;
    transform: translateY(-2px);
}

@media (max-width: 600px) {
    .scan-result-inner {
        padding: 1.2rem 0.1rem;
        max-width: 98vw;
    }
    .scan-result-type {
        font-size: 1.4rem;
    }
    .scan-result-action-content {
        font-size: 1.3rem;
        padding: 0.6em 1em;
    }
    .scan-result-code {
        font-size: 2rem;
    }
    .scan-result-buttons {
        flex-direction: column;
        align-items: center;
    }
    .btn-problem, .btn-retry {
        width: 100%;
        max-width: 280px;
    }
}

/* Enhanced UI Components for Optimistic Scanner */

/* Optimistic UI states */
.scan-result-block.optimistic {
    position: relative;
    overflow: visible;
}

.scan-result-block.optimistic::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #00ff88, #0099ff, #00ff88, #0099ff);
    background-size: 400% 400%;
    border-radius: 32px;
    z-index: -1;
    animation: optimisticGlow 2s ease-in-out infinite;
}

@keyframes optimisticGlow {
    0%, 100% {
        background-position: 0% 50%;
        opacity: 0.6;
    }
    50% {
        background-position: 100% 50%;
        opacity: 0.8;
    }
}

/* Processing indicator in action content */
.scan-result-action-content.processing {
    position: relative;
}

.scan-result-action-content.processing::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, #fff 50%, transparent 100%);
    animation: processingBar 1.5s ease-in-out infinite;
}

@keyframes processingBar {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Floating Action Button for "Bag Problème" */
.bag-probleme-fab {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.bag-probleme-fab:hover {
    background: #c82333;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.6);
}

.bag-probleme-fab:active {
    transform: scale(0.95);
}

/* Rollback notification */
.rollback-notification {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 193, 7, 0.9);
    color: #000;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: rollbackSlide 0.3s ease-out;
    z-index: 15;
}

@keyframes rollbackSlide {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* History table optimistic states */
#scanned-table tbody tr.optimistic {
    background: rgba(0, 255, 136, 0.1);
    position: relative;
}

#scanned-table tbody tr.optimistic::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #00ff88, #0099ff);
    animation: optimisticPulse 2s ease-in-out infinite;
}

@keyframes optimisticPulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Enhanced input states */
.scanner-detected {
    border-color: #0099ff !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 153, 255, 0.25) !important;
    background: linear-gradient(90deg, rgba(0, 153, 255, 0.05) 0%, rgba(0, 255, 136, 0.05) 100%) !important;
    position: relative;
}

.scanner-detected::after {
    content: '📷 Scanning...';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #0099ff;
    font-weight: 500;
    animation: scannerBlink 1s ease-in-out infinite;
}

@keyframes scannerBlink {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Enhanced button animations */
.btn-retry {
    position: relative;
    overflow: hidden;
}

.btn-retry::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn-retry:hover::before {
    width: 300px;
    height: 300px;
}

/* Connection status indicator */
.connection-status {
    position: fixed;
    top: 70px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.connection-status.connected {
    background: rgba(40, 167, 69, 0.8);
}

.connection-status.disconnected {
    background: rgba(220, 53, 69, 0.8);
}

.connection-status.reconnecting {
    background: rgba(255, 193, 7, 0.8);
    color: #000;
}

.connection-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: connectionPulse 2s ease-in-out infinite;
}

@keyframes connectionPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Performance stats display (development) */
.performance-stats {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #00ff88;
    padding: 10px 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    line-height: 1.3;
    z-index: 1000;
    display: none;
}

.performance-stats.visible {
    display: block;
}

/* Sound loading indicator */
.sound-loading-indicator {
    animation: slideInFromRight 0.3s ease-out;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced modal animations */
.modal.fade .modal-dialog {
    transform: scale(0.8) translateY(-50px);
    transition: all 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .scan-result-action-content {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .bag-probleme-fab {
        box-shadow: 0 4px 16px rgba(220, 53, 69, 0.6);
    }
    
    .rollback-notification {
        background: rgba(251, 191, 36, 0.9);
        color: #1a202c;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .optimistic::before,
    .optimistic-pulse::before,
    .scanner-detected::after,
    .connection-status-dot {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .bag-probleme-fab {
        border: 2px solid #fff;
    }
    
    .scan-result-code .icon-success,
    .scan-result-code .icon-error {
        border: 2px solid currentColor;
    }
}

/* Mobile enhancements */
@media (max-width: 600px) {
    .bag-probleme-fab {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
        top: 12px;
        right: 12px;
    }
    
    .connection-status {
        top: 60px;
        right: 15px;
        font-size: 0.7rem;
        padding: 6px 12px;
    }
    
    .performance-stats {
        bottom: 15px;
        left: 15px;
        font-size: 0.65rem;
        padding: 8px 12px;
    }
}
