/**
 * Magic Loader - Dopamine Engineering
 * The hypnotic loading experience that builds perceived value
 */

/* ===== Magic Loader Container ===== */
.magic-loader {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.98);
    backdrop-filter: blur(20px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.magic-loader.active {
    opacity: 1;
    visibility: visible;
}

.magic-loader-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    max-width: 1000px;
    padding: 40px;
    align-items: center;
}

@media (max-width: 900px) {
    .magic-loader-content {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }
}

/* ===== Image Analysis Panel ===== */
.analysis-panel {
    position: relative;
}

.image-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 80px rgba(0, 212, 255, 0.3);
}

.uploaded-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== Scan Effects ===== */
.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
            transparent 0%,
            #00d4ff 20%,
            #7c3aed 50%,
            #00d4ff 80%,
            transparent 100%);
    box-shadow:
        0 0 20px #00d4ff,
        0 0 40px #00d4ff,
        0 0 60px rgba(0, 212, 255, 0.5);
    animation: scanVertical 2s ease-in-out infinite;
    z-index: 10;
}

@keyframes scanVertical {

    0%,
    100% {
        top: 0;
        opacity: 1;
    }

    50% {
        top: calc(100% - 3px);
        opacity: 0.8;
    }
}

.scan-line-horizontal {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg,
            transparent 0%,
            #00d4ff 20%,
            #7c3aed 50%,
            #00d4ff 80%,
            transparent 100%);
    box-shadow:
        0 0 20px #00d4ff,
        0 0 40px #00d4ff;
    animation: scanHorizontal 2.5s ease-in-out infinite;
    animation-delay: 0.5s;
    z-index: 10;
}

@keyframes scanHorizontal {

    0%,
    100% {
        left: 0;
        opacity: 0.8;
    }

    50% {
        left: calc(100% - 3px);
        opacity: 1;
    }
}

/* ===== Glow Aura Effect ===== */
.glow-aura {
    position: absolute;
    inset: -20px;
    border-radius: 30px;
    background: radial-gradient(ellipse at center,
            transparent 50%,
            rgba(0, 212, 255, 0.3) 70%,
            rgba(124, 58, 237, 0.2) 85%,
            transparent 100%);
    animation: pulseGlow 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulseGlow {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

/* ===== Corner Markers ===== */
.corner-marker {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 20;
}

.corner-marker::before,
.corner-marker::after {
    content: '';
    position: absolute;
    background: #00d4ff;
    box-shadow: 0 0 10px #00d4ff;
}

.corner-marker.top-left {
    top: 10px;
    left: 10px;
}

.corner-marker.top-left::before {
    width: 20px;
    height: 3px;
    top: 0;
    left: 0;
}

.corner-marker.top-left::after {
    width: 3px;
    height: 20px;
    top: 0;
    left: 0;
}

.corner-marker.top-right {
    top: 10px;
    right: 10px;
}

.corner-marker.top-right::before {
    width: 20px;
    height: 3px;
    top: 0;
    right: 0;
}

.corner-marker.top-right::after {
    width: 3px;
    height: 20px;
    top: 0;
    right: 0;
}

.corner-marker.bottom-left {
    bottom: 10px;
    left: 10px;
}

.corner-marker.bottom-left::before {
    width: 20px;
    height: 3px;
    bottom: 0;
    left: 0;
}

.corner-marker.bottom-left::after {
    width: 3px;
    height: 20px;
    bottom: 0;
    left: 0;
}

.corner-marker.bottom-right {
    bottom: 10px;
    right: 10px;
}

.corner-marker.bottom-right::before {
    width: 20px;
    height: 3px;
    bottom: 0;
    right: 0;
}

.corner-marker.bottom-right::after {
    width: 3px;
    height: 20px;
    bottom: 0;
    right: 0;
}

/* ===== Face Detection Grid ===== */
.face-grid {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(0, 212, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    animation: fadeInOut 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 0.2;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== Face Points Animation ===== */
.face-points {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 15;
}

.face-point {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #00d4ff;
    border-radius: 50%;
    box-shadow: 0 0 10px #00d4ff;
    animation: pointPulse 1.5s ease-in-out infinite;
    opacity: 0;
}

@keyframes pointPulse {

    0%,
    100% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Staggered point animations */
.face-point:nth-child(1) {
    animation-delay: 0s;
}

.face-point:nth-child(2) {
    animation-delay: 0.1s;
}

.face-point:nth-child(3) {
    animation-delay: 0.2s;
}

.face-point:nth-child(4) {
    animation-delay: 0.3s;
}

.face-point:nth-child(5) {
    animation-delay: 0.4s;
}

.face-point:nth-child(6) {
    animation-delay: 0.5s;
}

.face-point:nth-child(7) {
    animation-delay: 0.6s;
}

.face-point:nth-child(8) {
    animation-delay: 0.7s;
}

/* ===== Status Panel ===== */
.status-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.status-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-title::before {
    content: '';
    width: 12px;
    height: 12px;
    background: #00d4ff;
    border-radius: 50%;
    animation: statusBlink 1s ease-in-out infinite;
}

@keyframes statusBlink {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 10px #00d4ff;
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 5px #00d4ff;
    }
}

/* ===== Technical Logs ===== */
.tech-logs {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    max-height: 250px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    opacity: 0;
    transform: translateX(-10px);
    animation: logSlideIn 0.3s ease-out forwards;
}

@keyframes logSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-time {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    white-space: nowrap;
}

.log-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.log-status.pending {
    background: #f59e0b;
}

.log-status.processing {
    background: #00d4ff;
    animation: statusBlink 0.5s infinite;
}

.log-status.complete {
    background: #10b981;
}

.log-status.error {
    background: #ef4444;
}

.log-message {
    color: rgba(255, 255, 255, 0.8);
}

.log-message.highlight {
    color: #00d4ff;
}

/* ===== Progress Bar ===== */
.progress-section {
    margin-top: 20px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.progress-text {
    color: rgba(255, 255, 255, 0.7);
}

.progress-percent {
    color: #00d4ff;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00d4ff, #7c3aed);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
    animation: progressShine 1.5s infinite;
}

@keyframes progressShine {
    0% {
        transform: translateX(-40px);
    }

    100% {
        transform: translateX(40px);
    }
}

/* ===== Current Stage Display ===== */
.current-stage {
    text-align: center;
    padding: 20px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 12px;
}

.stage-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    animation: stageBounce 1s ease-in-out infinite;
}

@keyframes stageBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.stage-text {
    font-size: 1rem;
    color: #00d4ff;
    font-weight: 500;
}

/* ===== Cancel Button ===== */
.cancel-btn {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.cancel-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

/* ===== Result Reveal Transition ===== */
.magic-loader.revealing {
    animation: revealFlash 0.8s ease-out forwards;
}

@keyframes revealFlash {
    0% {
        opacity: 1;
        background: rgba(10, 10, 15, 0.98);
    }

    30% {
        background: rgba(0, 212, 255, 0.3);
    }

    100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* ===== Loading Dots ===== */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #00d4ff;
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .magic-loader-content {
        padding: 20px;
    }

    .image-container {
        max-width: 280px;
    }

    .tech-logs {
        font-size: 0.75rem;
        max-height: 180px;
    }

    .status-title {
        font-size: 1.2rem;
        justify-content: center;
    }
}