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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    padding: 2rem 1rem;
    color: white;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1rem;
    opacity: 0.9;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 0.75rem;
}

/* When results are shown, hide header and expand results */
body.showing-results header {
    display: none;
}
body.showing-results main {
    justify-content: flex-start;
    padding-top: 0;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    pointer-events: none;
}

.scan-frame::before,
.scan-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #34c759;
}

.scan-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.scan-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

.scan-line {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #34c759, transparent);
    animation: scan 2s linear infinite;
    pointer-events: none;
}

@keyframes scan {
    0% { transform: translate(-50%, -100px); }
    100% { transform: translate(-50%, 100px); }
}

.scan-status {
    max-width: 400px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    min-height: 1.5em;
}

.results {
    background: white;
    border-radius: 20px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
}

.results.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    animation: none !important;
}

body.showing-results .results {
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
    padding: 1.5rem 1rem;
}

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

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.result-header h2 {
    font-size: 1.5rem;
    color: #333;
}

#confidence {
    font-size: 0.8rem;
    color: #666;
    background: #f0f0f0;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
}

.result-content {
    margin-bottom: 2rem;
}

.data-display {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.data-type-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.25rem;
}

.data-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.data-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.data-info {
    flex: 1;
}

.data-info h3 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 0.15rem;
}

.data-info p {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0;
}

.data-value {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0.6rem;
    max-height: 80px;
    overflow-y: auto;
    margin-top: 0.75rem;
}

.data-value code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    color: #333;
    word-break: break-all;
    white-space: pre-wrap;
}

.parsed-data {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
}

.parsed-data h4 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 0.75rem;
}

.parsed-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

.parsed-item:last-child {
    border-bottom: none;
}

.parsed-label {
    font-weight: 500;
    color: #666;
}

.parsed-value {
    color: #333;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.parsed-link {
    color: #007AFF;
    text-decoration: none;
    border-bottom: 1px dotted #007AFF;
    transition: all 0.2s ease;
}

.parsed-link:hover {
    color: #0056CC;
    border-bottom-style: solid;
}

.actions {
    display: flex;
    gap: 1rem;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn svg {
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #34c759;
    color: white;
}

.btn-secondary:hover {
    background: #2da54a;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(52, 199, 89, 0.3);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.manual-input-section {
    max-width: 400px;
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.manual-input-section h3 {
    font-size: 1.1rem;
    color: white;
    margin-bottom: 0.5rem;
}

.manual-input-section p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

#qr-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 1rem;
}

#qr-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#qr-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
}

.manual-input-actions {
    display: flex;
    gap: 0.5rem;
}

.manual-input-actions .btn {
    flex: 1;
}

.loading {
    text-align: center;
    color: white;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.error-icon {
    margin-bottom: 1rem;
}

.error h3 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.error p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .camera-container {
        max-width: 320px;
    }

    .scan-frame {
        width: 160px;
        height: 160px;
    }

    .scan-line {
        width: 160px;
    }

    .results {
        padding: 1.5rem;
    }

    .actions {
        flex-direction: column;
    }

    .data-display {
        flex-direction: column;
        text-align: center;
    }

    .data-icon {
        margin: 0 auto;
    }
}
