/* ===== DESIGN TOKENS ===== */
:root {
    --bg-base: #121212;
    --bg-card: #1E1E1E;
    --bg-elevated: #252525;
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-light: rgba(255, 255, 255, 0.08);

    --accent-blue: #4285F4;
    --accent-green: #34A853;
    --accent-amber: #FBBC05;
    --accent-red: #EA4335;

    --text-primary: #EAEAEA;
    --text-secondary: #8A8A8A;
    --text-tertiary: #555555;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow-blue: 0 0 20px rgba(66, 133, 244, 0.15);
    --shadow-glow-green: 0 0 20px rgba(52, 168, 83, 0.15);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

/* ===== HEADER ===== */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 18px;
}

.app-title {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1.8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    white-space: nowrap;
}

.app-title .accent {
    color: var(--accent-blue);
    font-weight: 700;
}

.app-title .version {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 0.7rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(52, 168, 83, 0.08);
    border: 1px solid rgba(52, 168, 83, 0.2);
    border-radius: var(--radius-pill);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 6px var(--accent-green);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.status-text {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--accent-green);
    text-transform: uppercase;
}

/* Model Navigation */
.model-nav {
    display: flex;
    background: var(--bg-base);
    border-radius: var(--radius-pill);
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border-light);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 22px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.nav-tab .tab-icon {
    width: 16px;
    height: 16px;
    transition: all var(--transition-normal);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
    background: var(--accent-blue);
    color: #ffffff;
    box-shadow: var(--shadow-glow-blue);
}

.nav-tab.active .tab-icon {
    filter: brightness(2);
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
}

.import-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.import-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(66, 133, 244, 0.06);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 20px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loader-text {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.loader-bar {
    width: 200px;
    height: 3px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.loader-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ===== MAIN WORKSPACE ===== */
#workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    padding: 20px 28px;
    max-width: 100%;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-normal);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.card-badge {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent-blue);
    padding: 3px 10px;
    background: rgba(66, 133, 244, 0.1);
    border: 1px solid rgba(66, 133, 244, 0.2);
    border-radius: var(--radius-pill);
}

/* ===== INPUT CARD ===== */
.input-card {
    display: flex;
    flex-direction: column;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0A0A0A;
    overflow: hidden;
    flex-shrink: 0;
}

.canvas-wrapper video,
.canvas-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#mainCanvas {
    z-index: 2;
    display: none;
}

#poseOverlay {
    z-index: 3;
    display: none;
    pointer-events: none;
}

#audioVisualizer {
    z-index: 2;
    display: none;
    object-fit: fill;
}

#webcamVideo {
    z-index: 1;
    display: none;
}

.canvas-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 5;
    color: var(--text-tertiary);
    transition: opacity var(--transition-smooth);
}

.canvas-placeholder p {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 2px;
}

.canvas-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Input Controls */
.input-controls {
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cam-controls {
    display: flex;
    gap: 12px;
}

.ctrl-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.ctrl-btn:hover {
    background: rgba(66, 133, 244, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.ctrl-btn.active {
    background: rgba(251, 188, 5, 0.12);
    border-color: var(--accent-amber);
    color: var(--accent-amber);
}

.hidden { display: none !important; }

/* Audio Controls */
.audio-controls {
    display: flex;
    justify-content: center;
    width: 100%;
}

.listen-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.15), rgba(66, 133, 244, 0.05));
    border: 2px solid var(--accent-blue);
    border-radius: var(--radius-pill);
    color: var(--accent-blue);
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all var(--transition-normal);
    overflow: hidden;
}

.listen-btn:hover {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.25), rgba(66, 133, 244, 0.1));
    box-shadow: var(--shadow-glow-blue);
}

.listen-btn.active {
    background: linear-gradient(135deg, rgba(52, 168, 83, 0.2), rgba(52, 168, 83, 0.05));
    border-color: var(--accent-green);
    color: var(--accent-green);
    box-shadow: var(--shadow-glow-green);
}

.listen-pulse {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle, rgba(66, 133, 244, 0.2) 0%, transparent 70%);
    opacity: 0;
    animation: listenPulse 2s ease-in-out infinite;
}

@keyframes listenPulse {
    0%, 100% { opacity: 0; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); }
}

.listen-btn.active .listen-pulse {
    background: radial-gradient(circle, rgba(52, 168, 83, 0.2) 0%, transparent 70%);
}

/* ===== ANALYSIS CARD ===== */
.analysis-card {
    display: flex;
    flex-direction: column;
}

.predictions-container {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

/* Prediction Row */
.prediction-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.38fr) 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    transition: all var(--transition-normal);
}

.prediction-row.top-prediction .pred-label {
    color: var(--text-primary);
    font-weight: 700;
}

.pred-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color var(--transition-fast);
}

.pred-bar-wrapper {
    height: 10px;
    background: var(--bg-base);
    border-radius: var(--radius-pill);
    overflow: hidden;
    position: relative;
}

.pred-bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background var(--transition-fast);
    background: var(--text-tertiary);
    position: relative;
}

.pred-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15));
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}

.pred-bar-fill.low {
    background: var(--text-tertiary);
}

.pred-bar-fill.mid {
    background: var(--accent-amber);
    box-shadow: 0 0 8px rgba(251, 188, 5, 0.2);
}

.pred-bar-fill.high {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(52, 168, 83, 0.2);
}

.pred-value {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    transition: color var(--transition-fast);
}

.prediction-row.top-prediction .pred-value {
    color: var(--text-primary);
}

/* Greyed out state for audio when not listening */
.predictions-container.greyed-out .pred-bar-fill {
    background: var(--text-tertiary) !important;
    box-shadow: none !important;
}
.predictions-container.greyed-out .pred-label,
.predictions-container.greyed-out .pred-value {
    color: var(--text-tertiary) !important;
}

/* Analysis Footer */
.analysis-footer {
    padding: 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-prediction {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.top-label {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-tertiary);
}

.top-class {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-primary);
    text-transform: uppercase;
}

/* Confidence Ring */
.confidence-ring {
    position: relative;
    width: 80px;
    height: 80px;
}

.confidence-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--bg-base);
    stroke-width: 6;
}

.ring-fill {
    fill: none;
    stroke: var(--accent-blue);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke var(--transition-fast);
}

.ring-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ===== FOOTER ===== */
#app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 28px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 1px;
    color: var(--text-tertiary);
}

#app-footer strong {
    color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    #workspace {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    #app-header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    .model-nav {
        width: 100%;
        justify-content: center;
    }

    .header-right {
        width: 100%;
        justify-content: flex-end;
    }

    #app-footer {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .nav-tab span {
        display: none;
    }
    .nav-tab {
        padding: 10px 16px;
    }
    .app-title {
        font-size: 0.7rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.6s ease forwards;
}

.analysis-card {
    animation-delay: 0.1s;
}

/* Scan line effect on canvas */
.canvas-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
    z-index: 10;
    animation: scanLine 4s linear infinite;
    opacity: 0.3;
}

@keyframes scanLine {
    0% { top: 0; }
    100% { top: 100%; }
}

/* Grid pattern background on canvas */
.canvas-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 4;
    pointer-events: none;
}
