/* ==========================================================================
   Immersive Pitch Coach - Design System & Global Styles
   Typography: Outfit (Headings/Body) + JetBrains Mono (Telemetry/Timers)
   Theme: Executive Dark Glassmorphism
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-main: #0a0f1d;
    --bg-darker: #050811;
    --card-bg: rgba(15, 23, 42, 0.78);
    --card-border: rgba(255, 255, 255, 0.12);
    --card-hover-border: rgba(56, 189, 248, 0.45);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #a855f7;

    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.25);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.5;
}

/* 3D Canvas Background Container */
#threeCanvasContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#threeCanvasContainer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Hidden elements */
.hidden {
    display: none !important;
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

/* UI Overlays Root */
.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.interactive-screen {
    pointer-events: auto;
}

/* ==========================================================================
   Buttons & Form Controls
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.55);
    background: linear-gradient(135deg, #0369a1 0%, #1d4ed8 100%);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.85);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-glass {
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

.btn-glass:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: var(--accent-blue);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
}

/* ==========================================================================
   Welcome / Setup Screen
   ========================================================================== */
.setup-wrapper {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 36px 40px;
    margin: 20px;
    animation: fadeInScale 0.4s ease-out;
}

.setup-header {
    text-align: center;
    margin-bottom: 28px;
}

.brand-badge {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent-blue);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-radius: var(--radius-full);
    margin-bottom: 12px;
}

.setup-header h1 {
    font-size: 2.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.setup-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 680px;
    margin: 0 auto;
}

/* Duration Selector */
.setting-section {
    margin-bottom: 24px;
}

.setting-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}

.duration-selector {
    display: flex;
    gap: 12px;
}

.duration-btn {
    flex: 1;
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.duration-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(56, 189, 248, 0.4);
}

.duration-btn.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

/* Modes Grid */
.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.mode-card {
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s ease;
}

.mode-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
}

.mode-card.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: #3b82f6;
    box-shadow: 0 0 18px rgba(37, 99, 235, 0.25);
}

.mode-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.mode-card-icon {
    font-size: 1.3rem;
}

.mode-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.mode-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Setup Actions */
.setup-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 28px;
}

.setup-actions-primary {
    display: flex;
    gap: 14px;
}

.setup-actions-primary .btn {
    flex: 1;
}

.setup-extra-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.web-app-footer {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.web-app-footer a,
.results-page-footer a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

.web-app-footer a:hover,
.results-page-footer a:hover {
    color: #7dd3fc;
    text-decoration: underline;
}

.results-page-footer {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Camera Preview & Live Head Tracking Telemetry Box */
.camera-preview-container {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 150px;
    height: 112px;
    border-radius: var(--radius-sm);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    background: #000000;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
    transition: all 0.3s ease;
}

.camera-preview-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.85;
}

.camera-tracking-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 3px 6px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #38bdf8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tracking-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px #22c55e;
    flex-shrink: 0;
    animation: pulse 1.5s infinite;
}

/* ==========================================================================
   Countdown Screen (3, 2, 1)
   ========================================================================== */
.countdown-box {
    text-align: center;
}

.countdown-number {
    font-family: var(--font-mono);
    font-size: 7rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 35px rgba(56, 189, 248, 0.9);
    animation: pulseCountdown 1s infinite ease-in-out;
}

.countdown-label {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent-blue);
    text-transform: uppercase;
    margin-top: 10px;
}

/* ==========================================================================
   AI Processing & Progress Overlay Screen
   ========================================================================== */
.processing-overlay {
    width: 100%;
    max-width: 580px;
    padding: 44px 36px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: fadeInScale 0.35s ease-out;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.7), 0 0 40px rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.25);
    z-index: 50;
}

.processing-orb-container {
    position: relative;
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.processing-glow-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #38bdf8;
    border-right-color: #818cf8;
    border-bottom-color: #34d399;
    animation: spinSlow 1.5s linear infinite;
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.4);
}

.processing-ai-icon {
    font-size: 2.2rem;
    animation: pulse 1.8s infinite ease-in-out;
}

.processing-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #ffffff 40%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.processing-status {
    font-size: 1rem;
    color: #cbd5e1;
    max-width: 440px;
    margin: 0;
    min-height: 28px;
    transition: all 0.25s ease;
}

.processing-progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.processing-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #818cf8, #34d399);
    border-radius: var(--radius-full);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.7);
}

.processing-percent {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.5px;
}

.processing-subtext {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================================================
   Toasts Container
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    padding: 12px 20px;
    font-size: 0.9rem;
    color: var(--text-primary);
    animation: slideInRight 0.3s ease-out;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.toast-item.fade-out {
    opacity: 0;
}

.toast-warning {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.15);
}

.toast-info {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.15);
}

/* ==========================================================================
   Keyframe Animations
   ========================================================================== */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

@keyframes pulseCountdown {
    0% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   AI Settings Modal & Top Status Pill
   ========================================================================== */
.setup-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ai-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-status-pill:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-dot.active {
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
}

.status-dot.warning {
    background: #f59e0b;
    box-shadow: 0 0 10px #f59e0b;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 8, 17, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
    animation: fadeInScale 0.25s ease-out;
}

.modal-card {
    width: 100%;
    max-width: 520px;
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(56, 189, 248, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.btn-close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(10, 15, 29, 0.8);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.form-hint a {
    color: var(--accent-blue);
    text-decoration: none;
}

.form-hint a:hover {
    text-decoration: underline;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

