:root {
    --bg-color: #080c14;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #00f2fe;
    --primary-glow: rgba(0, 242, 254, 0.5);
    --secondary: #4facfe;
    --text-main: #ffffff;
    --text-muted: #8b949e;
    --success: #2ea043;
    --danger: #f85149;
    --danger-glow: rgba(248, 81, 73, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at center, #151b29 0%, var(--bg-color) 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 2rem;
    position: relative;
}

/* Face UI */
.tj-face-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    perspective: 1000px; /* For 3D floating effect */
}

.tj-face {
    width: 320px;
    height: 320px;
    background: rgba(10, 15, 25, 0.6);
    border-radius: 40%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 35px;
    position: relative;
    backdrop-filter: blur(15px);
    border: 2px solid var(--primary);
    box-shadow: 0 0 60px var(--primary-glow), inset 0 0 25px var(--primary-glow);
    animation: float 6s ease-in-out infinite, pulse-blue 6s ease-in-out infinite;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden; /* Contains the holographic shimmer */
    transform-style: preserve-3d;
}

/* Holographic Shimmer Effect */
.tj-face::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0) 40%,
        rgba(255,255,255,0.15) 50%,
        rgba(255,255,255,0) 60%,
        rgba(255,255,255,0) 100%
    );
    transform: rotate(30deg) translateY(-100%);
    animation: shimmer 7s infinite linear;
    pointer-events: none;
    z-index: 10;
}

@keyframes shimmer {
    0% { transform: rotate(30deg) translateY(-100%); }
    20% { transform: rotate(30deg) translateY(100%); }
    100% { transform: rotate(30deg) translateY(100%); }
}

/* Advanced 3D Float without hardcoded colors */
@keyframes float {
    0%, 100% { transform: translateY(0) rotateX(0) rotateY(0); }
    33% { transform: translateY(-15px) rotateX(6deg) rotateY(-4deg); }
    66% { transform: translateY(-5px) rotateX(-4deg) rotateY(6deg); }
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 60px var(--primary-glow), inset 0 0 25px var(--primary-glow); border-color: var(--primary); }
    33% { box-shadow: 0 15px 70px var(--primary-glow), inset 0 0 30px var(--primary-glow); border-color: var(--primary); }
    66% { box-shadow: 0 -5px 50px var(--primary-glow), inset 0 0 20px var(--primary-glow); border-color: var(--primary); }
}

/* Disconnected State */
.tj-face.disconnected {
    border-color: var(--danger) !important;
    box-shadow: 0 0 50px var(--danger-glow), inset 0 0 20px var(--danger-glow) !important;
    cursor: pointer;
    animation: float-disconnected 4s ease-in-out infinite, pulse-red-strong 2.5s infinite !important;
}

.tj-face.disconnected:hover {
    box-shadow: 0 0 80px rgba(248, 81, 73, 0.7), inset 0 0 30px rgba(248, 81, 73, 0.5) !important;
    transform: scale(1.02);
}

@keyframes float-disconnected {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse-red-strong {
    0%, 100% { box-shadow: 0 0 40px var(--danger-glow), inset 0 0 15px var(--danger-glow); border-color: var(--danger); }
    50% { box-shadow: 0 0 80px rgba(248, 81, 73, 0.8), inset 0 0 30px rgba(248, 81, 73, 0.6); border-color: var(--danger); }
}

.eyes {
    display: flex;
    gap: 70px;
    z-index: 2;
}

.eye-container {
    width: 35px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.eye {
    width: 100%;
    height: 100%;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--primary);
    animation: blink 5s infinite cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

/* Disconnected eyes */
.tj-face.disconnected .eye {
    background: var(--danger) !important;
    box-shadow: 0 0 15px var(--danger) !important;
    animation: none !important;
    height: 12px !important;
    border-radius: 20px !important;
    opacity: 0.8 !important;
}

@keyframes blink {
    0%, 93%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.05); }
    97% { transform: scaleY(1); }
}

.mouth {
    width: 80px;
    height: 12px;
    background: var(--primary);
    border-radius: 20px;
    box-shadow: 0 0 20px var(--primary);
    transform-origin: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.tj-face.disconnected .mouth {
    background: var(--danger) !important;
    box-shadow: 0 0 15px var(--danger) !important;
    width: 12px !important;
    height: 12px !important;
    border-radius: 50% !important;
    opacity: 0.8 !important;
}

/* Professional Speaking Animation */
.mouth.speaking {
    animation: professional-speak 0.6s infinite ease-in-out;
}

@keyframes professional-speak {
    0%   { transform: scaleY(1) scaleX(1); }
    20%  { transform: scaleY(2.2) scaleX(0.95); }
    40%  { transform: scaleY(1.3) scaleX(1); }
    60%  { transform: scaleY(2.8) scaleX(0.9); }
    80%  { transform: scaleY(1.5) scaleX(0.95); }
    100% { transform: scaleY(1) scaleX(1); }
}


/* =========================================
   DYNAMIC EMOTION SYSTEM
   ========================================= */

/* HAPPY */
.tj-face.emotion-happy .mouth {
    border-radius: 5px 5px 40px 40px;
    height: 25px;
    width: 85px;
}
.tj-face.emotion-happy .eye {
    border-radius: 50% 50% 20% 20%;
    transform: scaleY(0.85);
}

/* SAD */
.tj-face.emotion-sad .mouth {
    border-radius: 40px 40px 5px 5px;
    height: 18px;
    width: 65px;
}
.tj-face.emotion-sad .eye {
    border-radius: 20% 20% 50% 50%;
    transform: scaleY(0.85);
}

/* ANGRY */
.tj-face.emotion-angry {
    animation: float 6s ease-in-out infinite, pulse-red 2.5s infinite;
}
.tj-face.emotion-angry .mouth {
    background: var(--danger);
    box-shadow: 0 0 20px var(--danger);
    border-radius: 10px;
    height: 8px;
    width: 60px;
}
.tj-face.emotion-angry .eye {
    background: var(--danger);
    box-shadow: 0 0 20px var(--danger);
}
.tj-face.emotion-angry .left-eye { 
    transform: rotate(18deg) scaleY(0.7); 
    border-radius: 10px 50% 50% 50%; 
}
.tj-face.emotion-angry .right-eye { 
    transform: rotate(-18deg) scaleY(0.7); 
    border-radius: 50% 10px 50% 50%; 
}

/* SHOCKED */
.tj-face.emotion-shocked .mouth {
    border-radius: 50%;
    height: 45px;
    width: 45px;
}
.tj-face.emotion-shocked .eye {
    transform: scale(1.3);
    border-radius: 50%;
}

/* =========================================
   LISTENING STATE
   ========================================= */
.tj-face.listening:not(.emotion-happy):not(.emotion-sad):not(.emotion-angry):not(.emotion-shocked) .mouth {
    /* Shrink mouth to an attentive dot */
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.tj-face.listening .eye {
    /* Subtle attentive squint */
    animation: blink 5s infinite cubic-bezier(0.4, 0, 0.2, 1), listening-squint 3s infinite ease-in-out;
}

.tj-face.listening {
    /* Gently pulse the aura to show it's recording/processing */
    animation: float 6s ease-in-out infinite, pulse-listening 2s infinite alternate;
}

@keyframes listening-squint {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.9); }
}

@keyframes pulse-listening {
    from { box-shadow: 0 0 60px var(--primary-glow), inset 0 0 25px var(--primary-glow); border-color: var(--primary); }
    to { box-shadow: 0 0 90px rgba(0, 242, 254, 0.7), inset 0 0 40px rgba(0, 242, 254, 0.5); border-color: var(--primary); }
}


/* Connect Prompt */
.connect-prompt {
    margin-top: 50px;
    font-size: 1rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    animation: fadePulse 2s infinite;
}

@keyframes fadePulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Controls */
.controls {
    display: none; 
    margin-top: 50px;
    justify-content: center;
    gap: 1.5rem;
    animation: slideUp 0.4s ease-out forwards;
}

.controls.show {
    display: flex;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon.danger {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
    box-shadow: 0 0 15px rgba(248, 81, 73, 0.1);
}

.btn-icon.danger:hover {
    background: rgba(248, 81, 73, 0.1);
    box-shadow: 0 0 20px rgba(248, 81, 73, 0.3);
    transform: translateY(-2px) scale(1.05);
}

.btn-icon.secondary {
    background: transparent;
    border: 2px solid var(--text-muted);
    color: var(--text-muted);
    backdrop-filter: blur(10px);
}

.btn-icon.secondary.active-mic {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
    color: var(--primary);
}

.btn-icon.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px) scale(1.05);
}
