/* ========================================
   VALORA SCANNER - Minimalista & Moderno
   Cores: Preto e Branco
======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

body {
    position: fixed;
    top: 0;
    left: 0;
    background-color: #000000;
}

/* ========================================
   CAMERA BACKGROUND
======================================== */

#cameraFeed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: opacity 0.3s ease;
}

#cameraFeed.frozen {
    opacity: 0;
}

.frozen-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.frozen-background.active {
    opacity: 1;
    z-index: 3;
}


/* ========================================
   CONTAINER CORPO
======================================== */

.container-corpo {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    pointer-events: none;
}

/* Scanner Frame */
.scanner-frame {
    position: relative;
    width: 280px;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6;
}

/* Cantos do Scanner */
.corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: #ffffff;
    border-style: solid;
    border-width: 0;
}

.corner-tl {
    top: 0;
    left: 0;
    border-top-width: 3px;
    border-left-width: 3px;
    border-top-left-radius: 16px;
}

.corner-tr {
    top: 0;
    right: 0;
    border-top-width: 3px;
    border-right-width: 3px;
    border-top-right-radius: 16px;
}

.corner-bl {
    bottom: 0;
    left: 0;
    border-bottom-width: 3px;
    border-left-width: 3px;
    border-bottom-left-radius: 16px;
}

.corner-br {
    bottom: 0;
    right: 0;
    border-bottom-width: 3px;
    border-right-width: 3px;
    border-bottom-right-radius: 16px;
}

/* Linha de Scan */
.scan-line {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 20%, 
        #ffffff 50%, 
        rgba(255, 255, 255, 0.3) 80%, 
        transparent 100%
    );
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scan-line.active {
    opacity: 1;
    animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
    0%, 100% {
        top: 10px;
    }
    50% {
        top: calc(100% - 12px);
    }
}

/* Texto de Instrução */
.instruction-text {
    margin-top: 40px;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    opacity: 0.9;
    position: relative;
    z-index: 6;
}

/* Loading Indicator */
.loading-indicator {
    margin-top: 24px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 6;
}

.loading-indicator.active {
    opacity: 1;
    transform: translateY(0);
}

.loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffffff;
    opacity: 0.6;
    animation: loadingDot 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingDot {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* ========================================
   CONTAINER RODAPÉ
======================================== */

.container-rodape {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 20px 16px calc(env(safe-area-inset-bottom, 20px) + 20px);
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

/* Texto de instrução acima do Scan */
.scan-instruction-text {
    font-size: 13px;
    font-weight: 400;
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.2px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    opacity: 0.85;
    margin: 0;
    padding: 0 20px;
    max-width: 300px;
    line-height: 1.4;
}

.rodape-container {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 999px;
    height: 64px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    width: auto;
    min-width: 220px;
    max-width: 90%;
    position: relative;
    gap: 8px;
}

/* Botão Upload */
.upload-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-right: auto;
}

.upload-button:active {
    transform: scale(0.92);
    opacity: 0.7;
}

.upload-icon {
    width: 24px;
    height: 24px;
}

/* Botão de Scan */
.scan-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    background: #0066ff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    flex-shrink: 0;
}

.scan-button:active {
    transform: translate(-50%, -50%) scale(0.92);
}

.scan-button.scanning {
    animation: pulse 1.5s ease-in-out infinite;
}

.scan-button.scanning:active {
    animation: none;
    transform: translate(-50%, -50%) scale(0.92);
}

.scan-icon {
    width: 32px;
    height: 32px;
    color: #ffffff;
    stroke-width: 2.5;
}

/* Botão Flash */
.flash-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}

.flash-button:active {
    transform: scale(0.92);
    opacity: 0.7;
}

.flash-button.active {
    color: #ffffff;
}

.flash-button.active .flash-icon {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

.flash-icon,
.flash-icon-off {
    width: 24px;
    height: 24px;
    transition: opacity 0.2s ease;
    position: absolute;
}

.flash-icon {
    display: block;
}

.flash-icon-off {
    display: none;
}

.flash-button:not(.active) .flash-icon {
    display: none;
}

.flash-button:not(.active) .flash-icon-off {
    display: block;
}

/* ========================================
   ESTADOS E ANIMAÇÕES
======================================== */

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%);
        box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4), 0 0 0 0 rgba(0, 102, 255, 0.4);
    }
    50% {
        transform: translate(-50%, -50%);
        box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4), 0 0 0 15px rgba(0, 102, 255, 0);
    }
}

/* Corner Animation quando escaneando */
.scanner-frame.scanning .corner {
    animation: cornerPulse 1.5s ease-in-out infinite;
}

@keyframes cornerPulse {
    0%, 100% {
        border-color: #ffffff;
    }
    50% {
        border-color: rgba(255, 255, 255, 0.5);
    }
}

/* ========================================
   RESPONSIVIDADE
======================================== */

@media (max-width: 360px) {
    .scanner-frame {
        width: 240px;
        height: 240px;
    }
    
    .corner {
        width: 32px;
        height: 32px;
    }
    
    .rodape-container {
        height: 60px;
        padding: 0 8px;
        min-width: 200px;
        gap: 8px;
    }
    
    .scan-button {
        width: 64px;
        height: 64px;
    }
    
    .scan-icon {
        width: 28px;
        height: 28px;
    }
    
    .upload-button,
    .flash-button {
        width: 36px;
        height: 36px;
    }
    
    .upload-icon,
    .flash-icon,
    .flash-icon-off {
        width: 20px;
        height: 20px;
    }
    
    .scan-instruction-text {
        font-size: 12px;
        padding: 0 16px;
        max-width: 280px;
    }
}

@media (min-width: 500px) {
    .scanner-frame {
        width: 320px;
        height: 320px;
    }
    
    .corner {
        width: 48px;
        height: 48px;
    }
}

/* Para telas muito altas */
@media (min-height: 800px) {
    .instruction-text {
        margin-top: 60px;
        font-size: 15px;
    }
}

/* ========================================
   OVERLAY ESCURO NAS BORDAS (VIGNETTE)
======================================== */

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* ========================================
   TELA DE RESULTADO
======================================== */

.result-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.result-screen.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.result-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 32px;
}

.captured-image {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.result-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    padding: 0 20px;
}

.action-button {
    flex: 1;
    height: 52px;
    border-radius: 12px;
    border: 1.5px solid;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    background: transparent;
}

.retake-button {
    background: #000000;
    color: #ffffff;
    border-color: #ffffff;
}

.retake-button:hover {
    background: #1a1a1a;
}

.retake-button:active {
    transform: scale(0.98);
    background: #0a0a0a;
}

.confirm-button {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
}

.confirm-button:hover {
    background: #f5f5f5;
}

.confirm-button:active {
    transform: scale(0.98);
    background: #e5e5e5;
}

.action-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Loading spinner animation */
.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Estado de loading nos botões */
.action-button.loading {
    opacity: 0.7;
    pointer-events: none;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsividade para tela de resultado */
@media (max-width: 360px) {
    .result-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-button {
        height: 50px;
        font-size: 14px;
        border-radius: 10px;
    }
    
    .action-icon {
        width: 16px;
        height: 16px;
    }
    
    .captured-image {
        max-height: calc(100vh - 180px);
    }
}
