/* QR Scanner Feria - Estilos Optimizados */

.qr-scanner-feria-container {
    font-family: 'Ropa Sans', sans-serif;
    background: linear-gradient(135deg, #000f9f 0%, #1e3c72 100%);
    min-height: 100vh;
    margin: 0;
    transition: background 0.3s ease;
    position: relative;
}

.main-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.scanner-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 900px;
    width: 100%;
    max-height: 95vh;
    min-height: 700px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header-section {
    text-align: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.event-title {
    background: linear-gradient(135deg, #000f9f 0%, #1e3c72 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.event-subtitle {
    color: #6c757d;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 500;
    border: 1px solid rgba(40, 167, 69, 0.2);
    font-size: 1rem;
}

.scanner-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.loading-container {
    text-align: center;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 450px;
}

.loading-icon {
    font-size: 3rem;
    color: #000f9f;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.loading-text {
    font-size: 1.3rem;
    color: #495057;
    font-weight: 500;
}

video[id*="qr-video"] {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 600px;
    min-height: 600px;
    border-radius: 15px;
    object-fit: cover;
    background: #000;
}

.qr-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border: none;
    pointer-events: none;
    z-index: 10;
}

.corner {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 6px solid white;
}

.corner-tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 10px 0 0 0;
}

.corner-tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 10px 0 0;
}

.corner-bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 10px;
}

.corner-br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 10px 0;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00ff00, transparent);
    animation: scanner 3s infinite linear;
    box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.4);
}

@keyframes scanner {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* Sección de información del usuario */
.user-info-section {
    text-align: center;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(108, 117, 125, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(108, 117, 125, 0.2);
    flex-shrink: 0;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.waiting-state h5 {
    color: #495057;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.waiting-state p {
    color: #6c757d;
    font-size: 0.95rem;
    margin: 0;
}

/* Estados de usuario */
.user-success-state,
.user-error-state,
.delivery-success-state,
.delivery-error-state {
    text-align: left;
    animation: slideInFromRight 0.4s ease-out;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.user-success-state h5,
.user-error-state h5,
.delivery-success-state h5,
.delivery-error-state h5 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.delivery-success-state h5 {
    color: #155724;
    text-shadow: 0 1px 2px rgba(21, 87, 36, 0.1);
}

.delivery-error-state h5 {
    color: #721c24;
    text-shadow: 0 1px 2px rgba(114, 28, 36, 0.1);
}

/* Transición de salida */
.fade-out-transition {
    animation: fadeOutDown 0.3s ease-in forwards;
}

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

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

/* Elementos de información */
.user-info-section .info-item {
    background: rgba(248, 249, 250, 0.8);
    border-left: 4px solid #007bff;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0 8px 8px 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.delivery-success-state .info-item,
.delivery-error-state .info-item {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.delivery-success-state .info-item:hover,
.delivery-error-state .info-item:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.user-info-section .info-item:hover {
    background: rgba(233, 236, 239, 0.9);
    transform: translateX(5px);
}

.user-info-section .info-label {
    font-weight: bold;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.delivery-success-state .info-label,
.delivery-error-state .info-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.user-info-section .info-value {
    font-size: 1.2rem;
    color: #212529;
    font-weight: 600;
}

.delivery-success-state .info-value,
.delivery-error-state .info-value {
    font-weight: 600;
    font-size: 15px;
}

.user-info-section .info-icon {
    font-size: 1.6rem;
    width: 35px;
    text-align: center;
    flex-shrink: 0;
}

.delivery-success-state .info-icon,
.delivery-error-state .info-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* Estados específicos */
.user-success-state .info-item {
    border-left-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.user-success-state .info-item:hover {
    background: rgba(76, 175, 80, 0.15);
}

.user-error-state .info-item {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

.user-error-state .info-item:hover {
    background: rgba(244, 67, 54, 0.15);
}

/* Estados de fondo */
.success-bg {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%) !important;
}

.error-bg {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%) !important;
}

.processing-bg {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%) !important;
    border-color: #ffc107;
    transition: all 0.3s ease;
}

/* Controles de cámara */
.camera-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.processing-bg .camera-controls .control-btn {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.footer-info {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(108, 117, 125, 0.2);
    color: #6c757d;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Estados de procesamiento */
.processing-state {
    text-align: center;
    padding: 20px;
    animation: fadeInUp 0.3s ease-out;
}

.processing-container {
    max-width: 400px;
    margin: 0 auto;
}

.processing-title {
    color: #856404;
    font-weight: 600;
    margin-bottom: 20px;
}

.processing-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(1) {
    border-top-color: #ffc107;
    animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
    border-right-color: #fd7e14;
    animation-delay: 0.3s;
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
}

.spinner-ring:nth-child(3) {
    border-bottom-color: #28a745;
    animation-delay: 0.6s;
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
}

.processing-steps {
    text-align: left;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    padding: 15px;
}

.step-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    transition: all 0.3s ease;
    opacity: 0.5;
    transform: translateX(-10px);
}

.step-item.active {
    opacity: 1;
    transform: translateX(0);
    color: #856404;
    font-weight: 500;
}

.step-item.completed {
    opacity: 0.8;
    color: #28a745;
}

.step-item.completed .step-icon {
    color: #28a745;
}

.step-item.completed .step-spinner {
    display: none;
}

.step-item.completed .step-icon::before {
    content: "\f00c";
}

.step-icon {
    width: 20px;
    margin-right: 10px;
    color: #6c757d;
    transition: color 0.3s ease;
}

.step-text {
    flex-grow: 1;
    font-size: 14px;
}

.step-spinner {
    margin-left: 10px;
    color: #ffc107;
    display: none;
}

.step-item.active .step-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.step-item.active .step-icon {
    color: #ffc107;
}

.processing-message {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 5px;
    padding: 10px;
    margin-top: 15px;
}

/* Efectos de procesamiento */
.processing-bg .scanner-container {
    animation: processingPulse 2s ease-in-out infinite;
}

@keyframes processingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
}

.processing-bg .qr-overlay::after {
    content: 'PROCESANDO...';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 193, 7, 0.2);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #856404;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.processing-bg .status-indicator {
    animation: statusBlink 1.5s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Efecto de éxito */
.success-pulse {
    animation: successPulse 1s ease-out;
}

@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    25% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0.4);
    }
    50% {
        transform: scale(1.01);
        box-shadow: 0 0 0 20px rgba(40, 167, 69, 0.2);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 30px rgba(40, 167, 69, 0);
    }
}

/* Alertas */
.alert {
    border-radius: 8px;
    border: none !important;
    font-size: 13px;
    padding: 12px 15px;
    margin-top: 10px;
}

.alert .fas {
    margin-right: 6px;
}

.badge {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.badge .fas {
    font-size: 10px;
}

/* Animaciones */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Estilos para plugin deshabilitado */
.qr-scanner-feria-container .qr-scanner-disabled {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    text-align: center;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container {
        padding: 0.5rem;
    }
    
    .scanner-wrapper {
        padding: 1rem;
        border-radius: 15px;
        margin-top: 10px;
        min-height: 550px;
        max-height: 90vh;
    }
    
    .event-title {
        font-size: 1.75rem;
    }
    
    .event-subtitle {
        font-size: 1rem;
    }
    
    .status-indicator {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }
    
    .user-info-section {
        padding: 1rem;
        margin-top: 1rem;
        min-height: 150px;
    }
    
    .user-info-section .info-label {
        font-size: 0.8rem;
    }
    
    .user-info-section .info-value {
        font-size: 1.1rem;
    }
    
    .user-info-section .info-icon {
        font-size: 1.4rem;
        width: 30px;
    }
    
    .user-info-section .info-item {
        padding: 0.8rem;
        margin-bottom: 0.8rem;
    }
    
    .waiting-state h5 {
        font-size: 1rem;
    }
    
    .waiting-state p {
        font-size: 0.9rem;
    }
    
    .user-success-state h5,
    .user-error-state h5,
    .delivery-success-state h5,
    .delivery-error-state h5 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .qr-overlay {
        width: 220px;
        height: 220px;
    }
    
    .corner {
        width: 50px;
        height: 50px;
        border: 5px solid white;
    }
    
    video[id*="qr-video"] {
        min-height: 400px;
        max-height: 400px;
    }
    
    .loading-container {
        min-height: 350px;
        padding: 2rem;
    }
    
    .loading-icon {
        font-size: 2.5rem;
    }
    
    .loading-text {
        font-size: 1.1rem;
    }
    
    .footer-info {
        font-size: 0.9rem;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .processing-spinner {
        width: 60px;
        height: 60px;
    }
    
    .processing-steps {
        padding: 10px;
    }
    
    .step-item {
        padding: 6px 0;
    }
    
    .step-text {
        font-size: 13px;
    }
    
    .processing-title {
        font-size: 16px;
    }
}

@media (max-height: 700px) {
    .scanner-wrapper {
        padding: 1rem;
        max-height: 95vh;
        min-height: 500px;
        margin-top: 10px;
    }
    
    .event-title {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .event-subtitle {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    .status-indicator {
        font-size: 0.85rem;
        padding: 0.4rem 0.7rem;
    }
    
    .user-info-section {
        padding: 1rem;
        margin-top: 1rem;
        min-height: 120px;
    }
    
    .user-info-section .info-item {
        padding: 0.7rem;
        margin-bottom: 0.7rem;
    }
    
    .user-info-section .info-label {
        font-size: 0.8rem;
    }
    
    .user-info-section .info-value {
        font-size: 1rem;
    }
    
    .user-info-section .info-icon {
        font-size: 1.3rem;
        width: 28px;
    }
    
    .waiting-state h5 {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    .waiting-state p {
        font-size: 0.85rem;
    }
    
    .user-success-state h5,
    .user-error-state h5,
    .delivery-success-state h5,
    .delivery-error-state h5 {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }
    
    .footer-info {
        margin-top: 1rem;
        padding-top: 1rem;
        font-size: 0.85rem;
    }
    
    .scanner-container {
        min-height: 300px;
    }
    
    video[id*="qr-video"] {
        min-height: 350px;
        max-height: 350px;
    }
    
    .loading-container {
        min-height: 250px;
        padding: 1.5rem;
    }
    
    .loading-icon {
        font-size: 2.2rem;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .control-btn {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }
}

/* Mejoras para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .spinner-ring,
    .step-spinner,
    .processing-bg .scanner-container,
    .processing-bg .status-indicator,
    .scan-line {
        animation: none;
    }
    
    .processing-bg .qr-overlay::after {
        backdrop-filter: none;
    }
}