/* Scanner Section */
.scanner-section {
    padding: 140px 0 80px;
    min-height: 100vh;
}

.scanner-header {
    text-align: center;
    margin-bottom: 60px;
}

.scanner-title {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.scanner-description {
    font-size: 20px;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Scanner Container */
.scanner-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 80px;
}

/* Scanner Wrapper */
.scanner-wrapper {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.scanner-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
}

/* QR Reader */
#reader {
    width: 100%;
    height: 100%;
}

#reader video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}

/* Scanner Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-frame {
    position: relative;
    width: 70%;
    aspect-ratio: 1;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 16px;
}

.corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid #667eea;
    border-radius: 4px;
}

.corner-tl {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.corner-tr {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
}

.corner-bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
}

.corner-br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

.scanner-line {
    position: absolute;
    top: 15%;
    left: 15%;
    right: 15%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    animation: scan 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.8);
}

@keyframes scan {
    0%, 100% {
        top: 15%;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        top: 85%;
    }
}

/* Scanner Instruction */
.scanner-instruction {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 5;
}

.scanner-instruction svg {
    margin-bottom: 16px;
    opacity: 0.7;
}

.scanner-instruction p {
    font-size: 16px;
    opacity: 0.9;
    max-width: 200px;
}

.scanner-instruction.hidden {
    display: none;
}

/* Scanner Controls */
.scanner-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.scanner-btn {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.file-upload-btn {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 32px;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Camera Selector */
.camera-selector {
    margin-top: 20px;
    padding: 16px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.camera-selector label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.camera-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    background: white;
    font-size: 15px;
    color: var(--text-dark);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.camera-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Results Panel */
.results-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    display: flex;
    flex-direction: column;
    max-height: 800px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.results-header h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #ef4444;
}

.btn-icon:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

/* Results List */
.results-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.results-list::-webkit-scrollbar {
    width: 8px;
}

.results-list::-webkit-scrollbar-track {
    background: rgba(102, 126, 234, 0.05);
    border-radius: 4px;
}

.results-list::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
}

.results-list::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state small {
    font-size: 14px;
    opacity: 0.7;
}

/* Result Item */
.result-item {
    background: white;
    border: 2px solid rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease;
}

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

.result-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.result-item.success {
    border-left: 4px solid #10b981;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.result-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.result-time {
    font-size: 12px;
    color: var(--text-light);
}

.result-content {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-dark);
    background: rgba(102, 126, 234, 0.05);
    padding: 12px;
    border-radius: 8px;
    word-break: break-all;
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.result-btn {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    background: white;
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.result-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.result-btn.copied {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

/* Scanner Features */
.scanner-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.feature-item {
    text-align: center;
    padding: 24px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
    border-color: var(--primary-color);
}

.feature-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.feature-item h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.feature-item p {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
}

/* Responsive */
@media (max-width: 1024px) {
    .scanner-container {
        grid-template-columns: 1fr;
    }

    .scanner-features {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .scanner-section {
        padding: 120px 0 60px;
    }

    .scanner-title {
        font-size: 36px;
    }

    .scanner-description {
        font-size: 18px;
    }

    .scanner-controls {
        flex-direction: column;
    }

    .scanner-btn,
    .file-upload-btn {
        min-width: 100%;
    }

    .scanner-features {
        grid-template-columns: 1fr;
    }

    .results-panel {
        max-height: 500px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Success Flash */
@keyframes successFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    100% {
        box-shadow: 0 0 0 20px rgba(16, 185, 129, 0);
    }
}

.scanner-box.success {
    animation: successFlash 0.5s ease;
}

/* Animated QR Code Progress */
.animated-qr-progress {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 20;
    max-width: 90%;
    width: max-content;
    min-width: 280px;
    animation: slideUp 0.3s ease;
    max-height: 35vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
    color: var(--primary-color);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.5);
}

.progress-text {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

/* Frame Indicators Grid */
.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 6px;
    margin-top: 8px;
}

.frame-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 6px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
}

.frame-box.collected {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    animation: frameCollected 0.5s ease;
}

.frame-box.missing {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.3);
}

@keyframes frameCollected {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

.frame-number {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dark);
}

.frame-status {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.frame-box.collected .frame-status svg {
    stroke: #10b981;
}

.frame-box.missing .frame-status svg {
    stroke: #ef4444;
    opacity: 0.5;
}

/* Missing Frames Alert */
.missing-frames {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    border-left: 3px solid #ef4444;
}

.missing-frames small {
    font-size: 11px;
    color: #dc2626;
    font-weight: 600;
}

.missing-frames span {
    font-weight: 700;
    color: #b91c1c;
}

/* Animated QR Result Badge */
.result-type.animated-type {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    color: var(--primary-color);
}

.parts-badge {
    margin-left: 8px;
    padding: 2px 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.result-item.animated-qr-result {
    border-left: 4px solid var(--primary-color);
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.02), transparent);
}

.result-item.animated-qr-result:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05), transparent);
}

/* Responsive updates for animated QR */
@media (max-width: 768px) {
    .animated-qr-progress {
        bottom: 8px;
        left: 8px;
        right: 8px;
        transform: none;
        min-width: auto;
        max-width: calc(100% - 16px);
        width: auto;
        max-height: 40vh;
        overflow-y: auto;
        padding: 8px 12px;
    }

    .frames-grid {
        grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
        gap: 5px;
    }

    .frame-box {
        padding: 5px;
    }

    .frame-number {
        font-size: 10px;
    }

    .frame-status {
        width: 12px;
        height: 12px;
    }

    .progress-header {
        font-size: 12px;
    }

    .progress-text {
        font-size: 11px;
    }

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