* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: radial-gradient(circle at top, #e8f4f8 0%, #d0e8f2 100%);
    min-height: 100vh;
    color: #1a1a1a;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background: linear-gradient(180deg, #ffffff 0%, #f5f9fb 100%);
    box-shadow: 0 0 60px rgba(0, 123, 255, 0.15), 0 0 100px rgba(0, 188, 212, 0.1);
    position: relative;
}

header {
    background: linear-gradient(135deg, #0066ff 0%, #0052cc 50%, #003d99 100%);
    color: white;
    padding: 25px 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 102, 255, 0.4), inset 0 -2px 10px rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid #00d4ff;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 200%; }
}

header h1 {
    font-size: 28px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 10px rgba(0, 212, 255, 0.3);
    letter-spacing: 1px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.95;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

main {
    padding: 20px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Camera View */
.camera-prompt {
    background: linear-gradient(135deg, #ffffff 0%, #f0f8ff 100%);
    padding: 40px 20px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid #00d4ff;
    box-shadow: 0 8px 32px rgba(0, 123, 255, 0.2), inset 0 1px 0 rgba(0, 212, 255, 0.1);
}

.prompt-content h2 {
    margin: 20px 0 10px;
    color: #0066ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.prompt-content p {
    color: #555;
    margin: 10px 0;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 123, 255, 0.3), 0 0 0 2px #e0e0e0, 0 0 20px rgba(0, 212, 255, 0.2);
    background: #000;
}

#video {
    width: 100%;
    max-height: 60vh;
    object-fit: cover;
    display: block;
}

#canvas {
    width: 100%;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25%;
    aspect-ratio: 1;
    border: 2px solid #00d4ff;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6),
                inset 0 0 0 2px rgba(0, 0, 0, 0.3),
                0 0 30px rgba(0, 212, 255, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

.crop-box::before,
.crop-box::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #00d4ff;
}

.crop-box::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
    border-radius: 12px 0 0 0;
}

.crop-box::after {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
    border-radius: 0 12px 0 0;
}

.crop-corners::before,
.crop-corners::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #00d4ff;
}

.crop-corners::before {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 12px;
}

.crop-corners::after {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 12px 0;
}

@keyframes pulse {
    0%, 100% {
        border-color: #00d4ff;
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6),
                    inset 0 0 0 2px rgba(0, 0, 0, 0.3),
                    0 0 30px rgba(0, 212, 255, 0.7);
    }
    50% {
        border-color: #00bfff;
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6),
                    inset 0 0 0 2px rgba(0, 0, 0, 0.3),
                    0 0 40px rgba(0, 191, 255, 0.9);
    }
}

.btn-capture {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
    border: 4px solid #00d4ff;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.5),
                0 0 30px rgba(0, 102, 255, 0.3),
                inset 0 -2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 20px auto;
}

.btn-capture:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 212, 255, 0.7),
                0 0 40px rgba(0, 102, 255, 0.5);
}

.btn-capture:active {
    transform: scale(0.95);
}

.capture-icon {
    font-size: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes flashFade {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.instructions {
    background: linear-gradient(135deg, #ffffff 0%, #f0f8ff 100%);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    text-align: center;
    border: 2px solid #e0e0e0;
    box-shadow: 0 4px 20px rgba(0, 123, 255, 0.15), inset 0 1px 0 rgba(0, 212, 255, 0.05);
}

.instructions p {
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

.example {
    font-weight: bold;
    color: #0066ff;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #0066ff 0%, #0052cc 50%, #003d99 100%);
    color: white;
    border: 2px solid #00d4ff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 102, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 212, 255, 0.5), 0 0 30px rgba(0, 102, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    margin-top: 10px;
    border: 2px solid #00d4ff;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2), inset 0 1px 0 rgba(0, 212, 255, 0.1);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #7d8a93 0%, #6c757d 100%);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.3);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    margin-top: 10px;
    border: 2px solid #00d4ff;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
    background: linear-gradient(135deg, #34ce57 0%, #28a745 100%);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 24px;
}

/* Processing View */
#processingView {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 30px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid #0066ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.processing-text {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #0066ff;
}

.processing-subtext {
    font-size: 14px;
    color: #666;
}

/* Result View */
#resultView {
    text-align: center;
}

.result-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 3px solid #28a745;
}

.result-success .icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.result-success h2 {
    color: #155724;
    margin-bottom: 15px;
    font-size: 24px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.manufacturer-info {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #00d4ff;
}

.manufacturer-info h3 {
    color: #0066ff;
    margin-bottom: 10px;
    font-size: 20px;
}

.manufacturer-info p {
    color: #333;
    font-size: 16px;
    margin: 8px 0;
}

.code-found {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #0066ff;
    font-size: 18px;
    border: 1px solid #00d4ff;
}

.result-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 3px solid #dc3545;
}

.result-error .icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.result-error h2 {
    color: #721c24;
    margin-bottom: 15px;
    font-size: 24px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.result-error p {
    color: #721c24;
    font-size: 16px;
    margin: 10px 0;
}

.extracted-text {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    border: 1px solid #00d4ff;
}

.extracted-text pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
    color: #0066ff;
}

/* Responsive Design */
@media (max-width: 480px) {
    header h1 {
        font-size: 24px;
    }
    
    .btn {
        font-size: 16px;
        padding: 14px 20px;
    }
    
    .instructions p {
        font-size: 14px;
    }
    
    .example {
        font-size: 16px;
    }
}
