:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #8b5cf6;
    --accent: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --danger: #ef4444;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 900px) {
    .main-content {
        grid-template-columns: 3fr 2fr;
        align-items: start;
    }
}

/* Video Section */
.video-container {
    position: relative;
    background: var(--bg-card);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    padding: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    min-height: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

video {
    width: 100%;
    border-radius: 1rem;
    display: block;
    transform: scaleX(-1); /* Mirror effect */
}

.output_canvas {
    position: absolute;
    left: 1rem;
    top: 1rem;
    width: calc(100% - 2rem);
    height: calc(100% - 2rem);
    pointer-events: none;
    transform: scaleX(-1); /* Match video mirror */
    z-index: 10;
}

/* Button */
#webcamButton {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px var(--primary-glow);
    z-index: 20;
}

#webcamButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 20px -3px var(--primary-glow);
}

.removed {
    display: none !important;
}

.invisible {
    opacity: 0.2;
}

/* Loading */
#loading-indicator {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 30;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Results Section */
.results-container {
    background: var(--bg-card);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    width: fit-content;
    border: 1px solid rgba(16, 185, 129, 0.2);
    transition: all 0.3s ease;
}

.status-badge.idle {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border-color: rgba(148, 163, 184, 0.2);
}

.dot {
    width: 10px;
    height: 10px;
    background-color: currentColor;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
}

.status-badge:not(.idle) .dot {
    animation: pulseObj 1.5s infinite;
}

@keyframes pulseObj {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.translation-box {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 1rem;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.translation-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 1rem;
    padding: 2px;
    background: linear-gradient(135deg, var(--border), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.gesture-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.gesture-icon.active {
    opacity: 1;
    transform: scale(1.1) translateY(-5px);
}

#gesture_output {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    min-height: 3.5rem;
    transition: all 0.3s ease;
}

.pop-in {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); color: var(--primary); }
    100% { opacity: 1; transform: scale(1); color: var(--text-main); }
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
}

.control-btn {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-btn.active {
    background: var(--primary);
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.control-btn.muted {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}
.control-btn.muted:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Footer / Legend */
footer {
    background: var(--bg-card);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.legend h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.badge:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}
