:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --error: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.background-orbs {
    position: absolute;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 10s infinite alternate ease-in-out;
}

.orb-1 { width: 400px; height: 400px; background: #6366f1; top: -10%; left: -10%; }
.orb-2 { width: 500px; height: 500px; background: #c026d3; bottom: -20%; right: -10%; animation-delay: -5s; }
.orb-3 { width: 300px; height: 300px; background: #3b82f6; top: 40%; left: 40%; animation-duration: 15s; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

.glass-panel {
    position: relative;
    z-index: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header {
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 20px;
}

.tabs {
    display: flex;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 4px;
}

.tab {
    flex: 1;
    background: transparent;
    color: #94a3b8;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    box-shadow: none;
}

.tab.active {
    background: var(--glass-bg);
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.view-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}

.view-content.active {
    display: flex;
}

/* Upload UI */
.upload-container {
    width: 100%;
    aspect-ratio: 1;
    border: 2px dashed #475569;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    background: rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.upload-container:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #94a3b8;
}

.upload-prompt .icon {
    font-size: 3rem;
}

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

.hidden {
    display: none !important;
}

/* Camera UI */
.camera-container {
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    background: #000;
    box-shadow: 0 0 0 1px var(--glass-border);
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.output-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: scaleX(-1); /* match video */
}

.realtime-status {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    z-index: 10;
    white-space: nowrap;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.realtime-status.perfect {
    background: rgba(16, 185, 129, 0.8);
    border-color: var(--success);
}

.realtime-status.error {
    background: rgba(239, 68, 68, 0.8);
    border-color: var(--error);
}

.scanner-overlay {
    position: absolute;
    inset: 10%;
    pointer-events: none;
    transition: all 0.3s ease;
}

.scanner-overlay.perfect .corner {
    border-color: var(--success);
}

.scanner-overlay.perfect .scan-line {
    background: var(--success);
    box-shadow: 0 0 10px var(--success), 0 0 20px var(--success);
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 0;
    transition: all 0.3s ease;
}

.top-left { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 12px; }
.top-right { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 12px; }
.bottom-left { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 12px; }
.bottom-right { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 12px; }

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary);
    animation: scan 2.5s infinite linear;
    opacity: 0.7;
}

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

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.8rem;
    color: #94a3b8;
}

.input-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: #64748b;
    padding: 10px 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.8rem;
    outline: none;
    text-overflow: ellipsis;
}

button.glow-on-hover {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--primary-glow);
}

button.glow-on-hover:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
    background: #4f46e5;
}

button.glow-on-hover:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    background: #475569;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Result Box */
.result-box {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(0,0,0,0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.result-box.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.result-box.success h3 { color: var(--success); }

.result-box.error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.result-box.error h3 { color: var(--error); }

.status-icon {
    font-size: 2rem;
}

p#status-desc {
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
    word-break: break-all;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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