/* =====================================================
   Document Auto-Capture Overlay
   Stripe-like guide frame with auto detection
   ===================================================== */

/* Main overlay container */
.doc-guide-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 15;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

/* Mask / background darken around guide */
.doc-guide-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The document guide frame */
.doc-guide-frame {
    position: relative;
    width: 82%;
    aspect-ratio: 1.586 / 1; /* Standard ID card ratio */
    border: 2.5px solid rgba(255, 255, 255, 0.45);
    border-radius: 14px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 0 0 2000px rgba(0, 0, 0, 0.45),
        inset 0 0 30px rgba(0, 0, 0, 0.1);
}

/* Corner decorations */
.doc-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: rgba(255, 255, 255, 0.8);
    border-style: solid;
    border-width: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.doc-corner-tl {
    top: -2px;
    left: -2px;
    border-top-width: 3.5px;
    border-left-width: 3.5px;
    border-top-left-radius: 14px;
}

.doc-corner-tr {
    top: -2px;
    right: -2px;
    border-top-width: 3.5px;
    border-right-width: 3.5px;
    border-top-right-radius: 14px;
}

.doc-corner-bl {
    bottom: -2px;
    left: -2px;
    border-bottom-width: 3.5px;
    border-left-width: 3.5px;
    border-bottom-left-radius: 14px;
}

.doc-corner-br {
    bottom: -2px;
    right: -2px;
    border-bottom-width: 3.5px;
    border-right-width: 3.5px;
    border-bottom-right-radius: 14px;
}

/* ===== STATE: Detecting ===== */
.doc-guide-frame.detecting {
    border-color: rgba(76, 175, 80, 0.6);
    box-shadow:
        0 0 0 2000px rgba(0, 0, 0, 0.35),
        inset 0 0 30px rgba(76, 175, 80, 0.08),
        0 0 20px rgba(76, 175, 80, 0.15);
}

.doc-guide-frame.detecting .doc-corner {
    border-color: #4caf50;
    width: 32px;
    height: 32px;
}

/* ===== STATE: Detected / Capturing ===== */
.doc-guide-frame.detected {
    border-color: #4caf50;
    box-shadow:
        0 0 0 2000px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(76, 175, 80, 0.05),
        0 0 30px rgba(76, 175, 80, 0.25),
        0 0 60px rgba(76, 175, 80, 0.1);
    animation: framePulseGreen 1.2s ease-in-out infinite;
}

.doc-guide-frame.detected .doc-corner {
    border-color: #43a047;
    width: 34px;
    height: 34px;
    border-width: 0;
}

.doc-corner-tl { border-top-width: 3.5px; border-left-width: 3.5px; }
.doc-corner-tr { border-top-width: 3.5px; border-right-width: 3.5px; }
.doc-corner-bl { border-bottom-width: 3.5px; border-left-width: 3.5px; }
.doc-corner-br { border-bottom-width: 3.5px; border-right-width: 3.5px; }

.doc-guide-frame.detected .doc-corner-tl { border-top-width: 4px; border-left-width: 4px; }
.doc-guide-frame.detected .doc-corner-tr { border-top-width: 4px; border-right-width: 4px; }
.doc-guide-frame.detected .doc-corner-bl { border-bottom-width: 4px; border-left-width: 4px; }
.doc-guide-frame.detected .doc-corner-br { border-bottom-width: 4px; border-right-width: 4px; }

@keyframes framePulseGreen {
    0%, 100% {
        box-shadow:
            0 0 0 2000px rgba(0, 0, 0, 0.3),
            0 0 30px rgba(76, 175, 80, 0.25),
            0 0 60px rgba(76, 175, 80, 0.1);
    }
    50% {
        box-shadow:
            0 0 0 2000px rgba(0, 0, 0, 0.3),
            0 0 40px rgba(76, 175, 80, 0.35),
            0 0 80px rgba(76, 175, 80, 0.15);
    }
}

/* ===== STATE: Processing ===== */
.doc-guide-frame.processing {
    border-color: #4caf50;
    box-shadow:
        0 0 0 2000px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(76, 175, 80, 0.3);
    animation: processingPulse 1.5s ease-in-out infinite;
}

.doc-guide-frame.processing .doc-corner {
    border-color: #4caf50;
}

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

/* ===== Status Bar (bottom) ===== */
.doc-guide-status {
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 24px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    min-width: 200px;
    transition: all 0.4s ease;
}

.doc-status-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    transition: all 0.3s ease;
}

.doc-status-icon i {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.doc-status-text {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Inter', -apple-system, sans-serif;
    text-align: center;
    letter-spacing: 0.02em;
}

.doc-status-sub {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-family: 'Inter', -apple-system, sans-serif;
    text-align: center;
}

/* Status icon states */
.state-detecting .doc-status-icon {
    background: rgba(76, 175, 80, 0.2);
}

.state-detecting .doc-status-icon i {
    color: #81c784;
}

.state-capturing .doc-status-icon {
    background: rgba(76, 175, 80, 0.3);
    animation: iconCapturePulse 0.6s ease;
}

.state-capturing .doc-status-icon i {
    color: #fff;
}

@keyframes iconCapturePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); background: rgba(76, 175, 80, 0.5); }
    100% { transform: scale(1); }
}

.state-processing .doc-status-icon {
    background: rgba(76, 175, 80, 0.25);
}

.state-processing .doc-status-icon i {
    color: #4caf50;
}

/* ===== Progress Ring ===== */
.doc-progress-ring {
    position: absolute;
    bottom: 85px;
    right: 20px;
    width: 44px;
    height: 44px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 25;
}

.doc-progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.doc-progress-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 3;
}

.doc-progress-fill {
    fill: none;
    stroke: #4caf50;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 0.3s ease;
}

/* ===== Scanning line animation (detecting state) ===== */
.doc-guide-frame.detecting::after {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    width: 90%;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        rgba(76, 175, 80, 0.4),
        rgba(76, 175, 80, 0.8),
        rgba(76, 175, 80, 0.4),
        transparent);
    animation: scanLine 2s ease-in-out infinite;
    border-radius: 1px;
}

@keyframes scanLine {
    0% { top: 5%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 90%; opacity: 0; }
}

/* ===== Flash effect on capture ===== */
.state-capturing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    z-index: 30;
    animation: captureFlash 0.5s ease-out forwards;
    pointer-events: none;
    border-radius: 12px;
}

@keyframes captureFlash {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===== Camera viewport adjustments for document mode ===== */
.camera-viewport {
    position: relative;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .doc-guide-frame {
        width: 88%;
    }

    .doc-corner {
        width: 22px;
        height: 22px;
    }

    .doc-guide-status {
        padding: 12px 18px;
        margin-bottom: 12px;
    }

    .doc-status-text {
        font-size: 0.85rem;
    }

    .doc-progress-ring {
        width: 36px;
        height: 36px;
        bottom: 70px;
        right: 12px;
    }
}

@media (max-width: 360px) {
    .doc-guide-frame {
        width: 92%;
    }

    .doc-guide-status {
        padding: 10px 14px;
        margin-bottom: 8px;
        min-width: 160px;
    }

    .doc-status-icon {
        width: 30px;
        height: 30px;
    }

    .doc-status-icon i {
        font-size: 0.85rem;
    }
}
