:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #64748b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    --surface-glass: rgba(30, 41, 59, 0.7);
    --border-color: rgba(148, 163, 184, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 20%);
}

.container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

header p {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Upload Section */
.upload-section {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.file-drop-area {
    position: relative;
    border: 2px dashed var(--secondary);
    border-radius: 16px;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-drop-area:hover,
.file-drop-area.dragover {
    background: rgba(139, 92, 246, 0.05);
    border-color: var(--primary);
}

.icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.file-msg {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.cta-btn {
    margin-top: 2rem;
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 1rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 100px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.cta-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

.cta-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mode Toggle / Navigation */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
    background: var(--surface-glass);
    padding: 0.8rem 1rem;
    border-radius: 100px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--border-color);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 2.5rem;
    border-radius: 100px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1.05rem;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.toggle-btn:hover:not(.active) {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Tab Views */
.tab-view {
    animation: fadeInUp 0.5s ease-out;
}

/* Upload Section */
.upload-section {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 4rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    margin: 0 auto;
}

/* Camera Section */
.camera-section {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem;
    text-align: center;
    max-width: 900px;
    margin: 0 auto 3rem auto;
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 720px;
    margin: 0 auto 2rem;
    border-radius: 24px;
    overflow: hidden;
    background: black;
    aspect-ratio: 4/3;
    border: 3px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.hint-text {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Results Section */
.results-container {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 3rem;
    margin-top: 3rem;
    animation: fadeInUp 0.6s ease-out;
    padding: 2rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 32px;
}

.image-preview-wrapper {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    max-height: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.data-panel {
    background: var(--surface-glass);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.data-panel h2 {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.emotions-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.emotion-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.emotion-name {
    width: 100px;
    font-weight: 500;
    text-transform: capitalize;
}

.progress-bar-bg {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    width: 0%;
    transition: width 1s ease-out;
}

.emotion-val {
    width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--primary);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.8rem 2rem;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

/* Dashboard */
.dashboard-section {
    background: var(--surface-glass);
    border-radius: 32px;
    /* Smoother corners */
    padding: 3rem;
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.5s ease-out;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    /* Increased gap */
    margin-bottom: 3rem;
}

.card {
    background: rgba(30, 41, 59, 0.6);
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
    background: rgba(30, 41, 59, 0.8);
}

.chart-container {
    margin: 3rem 0;
    padding: 2rem;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    height: 400px;
    display: flex;
    justify-content: center;
}

.users-table-wrapper {
    overflow-x: auto;
    border-radius: 16px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
}

.users-table th,
.users-table td {
    padding: 1.5rem;
    /* More padding */
}

/* Button variants */
.secondary-btn.small {
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

.hidden {
    display: none !important;
}

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .results-container {
        grid-template-columns: 1fr;
    }
}