@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a0e27;
    background-image: 
        radial-gradient(at 0% 0%, rgba(88, 28, 135, 0.3) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(30, 58, 138, 0.3) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(15, 23, 42, 0.3) 0px, transparent 50%);
    min-height: 100vh;
    padding: 20px;
    color: #e2e8f0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(139, 92, 246, 0.1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Header */
header {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
    backdrop-filter: blur(10px);
    color: white;
    padding: 40px 30px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

header h1 {
    font-size: 2.8em;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #a78bfa 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    text-shadow: 0 0 30px rgba(167, 139, 250, 0.3);
}

header p {
    font-size: 1.1em;
    color: #cbd5e1;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Main Content */
.main-content {
    padding: 40px 30px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 40px;
    padding: 6px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    flex: 1;
    padding: 16px 24px;
    border: none;
    background: transparent;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
}

.tab-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(59, 130, 246, 0.3) 100%);
    box-shadow: 
        0 0 20px rgba(139, 92, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(20px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 30px;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 60px rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#webcam, #canvas {
    width: 100%;
    height: auto;
    display: block;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2em;
    z-index: 10;
    font-weight: 500;
}

.status-overlay.hidden {
    display: none;
}

/* Controls */
.controls, .upload-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn:disabled:hover::before {
    width: 0;
    height: 0;
}

.btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

.btn-secondary {
    background: rgba(71, 85, 105, 0.5);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(71, 85, 105, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}

/* Prediction Box */
.prediction-box {
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    margin-top: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.prediction-box h3 {
    color: #e2e8f0;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.prediction-result {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.prediction-label, .prediction-confidence {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition: transform 0.3s, box-shadow 0.3s;
}

.prediction-label:hover, .prediction-confidence:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.label-title, .conf-title {
    display: block;
    font-size: 0.85em;
    color: #94a3b8;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.label-value {
    display: block;
    font-size: 2.2em;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.conf-value {
    display: block;
    font-size: 2.2em;
    font-weight: 800;
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

/* Confidence Bar */
.confidence-bar {
    width: 100%;
    height: 36px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 18px;
    overflow: hidden;
    margin-top: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #3b82f6 50%, #10b981 100%);
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 15px;
    color: white;
    font-weight: 700;
    font-size: 0.95em;
    box-shadow: 
        0 0 20px rgba(139, 92, 246, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Upload Section */
.upload-area {
    width: 100%;
    max-width: 640px;
    height: 400px;
    margin: 0 auto 30px;
    border: 2px dashed rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    background: rgba(30, 41, 59, 0.3);
    backdrop-filter: blur(10px);
}

.upload-area:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
    box-shadow: 
        0 0 40px rgba(139, 92, 246, 0.2),
        inset 0 0 20px rgba(139, 92, 246, 0.05);
}

.upload-area.drag-over {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 
        0 0 40px rgba(59, 130, 246, 0.3),
        inset 0 0 30px rgba(59, 130, 246, 0.1);
}

.upload-placeholder {
    text-align: center;
    color: #94a3b8;
}

.upload-icon {
    font-size: 4.5em;
    margin-bottom: 20px;
    opacity: 0.8;
}

.upload-placeholder p {
    font-size: 1.1em;
    margin: 8px 0;
    font-weight: 500;
    color: #cbd5e1;
}

.upload-hint {
    font-size: 0.9em;
    color: #64748b;
    font-weight: 400;
}

.uploaded-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 16px;
}

/* Top Predictions */
.top-predictions {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.top-predictions h4 {
    color: #e2e8f0;
    margin-bottom: 18px;
    font-weight: 700;
    font-size: 1.1em;
}

.prediction-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
}

.prediction-item:hover {
    background: rgba(30, 41, 59, 0.6);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.prediction-item-label {
    flex: 1;
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.95em;
}

.prediction-item-bar {
    flex: 2;
    height: 28px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 14px;
    overflow: hidden;
    margin: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.prediction-item-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #3b82f6 100%);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 0 15px rgba(139, 92, 246, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.prediction-item-confidence {
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 55px;
    text-align: right;
    font-size: 0.95em;
}

/* Footer */
footer {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    color: #94a3b8;
    padding: 25px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

footer p {
    margin: 6px 0;
    font-size: 0.95em;
    font-weight: 400;
}

#modelStatus {
    color: #fbbf24;
    font-weight: 600;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.5);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.7);
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }
    
    .prediction-result {
        grid-template-columns: 1fr;
    }
    
    .controls, .upload-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .main-content {
        padding: 30px 20px;
    }
    
    .label-value, .conf-value {
        font-size: 1.8em;
    }
}