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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #eee;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: grid;
    grid-template-columns: 1fr 400px;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    gap: 1rem;
    padding: 1rem;
}

.header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 300;
    color: #0f3460;
    text-shadow: 0 0 20px rgba(94, 156, 255, 0.5);
}

.status-bar {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.status-indicator {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.status-dot.active {
    background: #4ecca3;
    box-shadow: 0 0 10px #4ecca3;
    animation: pulse 2s infinite;
}

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

.video-section {
    position: relative;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

/* AI Avatar Container */
#aiAvatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
}

/* Animated Avatar Face */
.avatar-face {
    width: 200px;
    height: 200px;
    position: relative;
    animation: float 3s ease-in-out infinite;
}

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

/* Avatar Head Circle */
.avatar-head {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.avatar-head.listening {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 10px 40px rgba(240, 147, 251, 0.6);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.avatar-head.talking {
    background: linear-gradient(135deg, #4ecca3 0%, #38d9a9 100%);
    box-shadow: 0 10px 40px rgba(78, 204, 163, 0.6);
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 10px 40px rgba(240, 147, 251, 0.6); }
    50% { box-shadow: 0 10px 60px rgba(240, 147, 251, 0.9); }
}

/* Avatar Eyes */
.avatar-eyes {
    display: flex;
    gap: 40px;
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
}

.eye {
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    position: relative;
    animation: blink 4s infinite;
}

.eye::after {
    content: '';
    width: 12px;
    height: 12px;
    background: #1a1a2e;
    border-radius: 50%;
    position: absolute;
    top: 6px;
    left: 6px;
    animation: look-around 5s infinite;
}

@keyframes blink {
    0%, 98%, 100% { height: 24px; }
    99% { height: 2px; }
}

@keyframes look-around {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(3px, 0); }
    50% { transform: translate(0, 3px); }
    75% { transform: translate(-3px, 0); }
}

/* Avatar Mouth */
.avatar-mouth {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 30px;
    border: 4px solid white;
    border-top: none;
    border-radius: 0 0 60px 60px;
    transition: all 0.3s ease;
}

.avatar-mouth.talking {
    animation: talk 0.3s infinite;
}

@keyframes talk {
    0%, 100% { height: 30px; border-radius: 0 0 60px 60px; }
    50% { height: 20px; border-radius: 0 0 40px 40px; }
}

/* Sound Wave Animation for Listening */
.sound-waves {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 4px;
}

.sound-waves.active {
    display: flex;
}

.wave-bar {
    width: 4px;
    height: 20px;
    background: linear-gradient(to top, #f093fb, #f5576c);
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { height: 20px; }
    50% { height: 40px; }
}

/* Avatar Status Text */
.avatar-status {
    margin-top: 30px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
    text-align: center;
}

#cameraOverlay {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 160px;
    height: 120px;
    border: 2px solid #4ecca3;
    border-radius: 8px;
    overflow: hidden;
}

#userCamera {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#faceCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.conversation-section {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.conversation-header {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.conversation-header h2 {
    font-size: 1.2rem;
    font-weight: 400;
}

.conversation-log {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.conversation-log::-webkit-scrollbar {
    width: 6px;
}

.conversation-log::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.conversation-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.message.ai {
    align-self: flex-start;
    background: rgba(78, 204, 163, 0.2);
    border: 1px solid rgba(78, 204, 163, 0.3);
    color: #4ecca3;
}

.message .timestamp {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.input-section {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    align-items: center;
}

#textInput {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.3);
    color: #eee;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

#textInput:focus {
    border-color: #4ecca3;
    box-shadow: 0 0 20px rgba(78, 204, 163, 0.3);
}

#textInput::placeholder {
    color: #888;
}

button {
    padding: 1rem 2rem;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

#micBtn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    min-width: 120px;
}

#micBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

#micBtn.recording {
    background: #ff4757;
    animation: recording-pulse 1s infinite;
}

@keyframes recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
}

#sendBtn {
    background: linear-gradient(135deg, #4ecca3 0%, #38d9a9 100%);
    color: #1a1a2e;
}

#sendBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(78, 204, 163, 0.4);
}

#sendBtn:disabled, #micBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.emotion-indicator {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

.emotion-indicator.happy {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.emotion-indicator.sad {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
}

.emotion-indicator.neutral {
    background: rgba(158, 158, 158, 0.2);
    color: #9e9e9e;
}

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
    }
    
    .video-section {
        max-height: 50vh;
    }
}

/* Trial/Welcome Screen */
#trialScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#trialScreen.hidden {
    display: none;
}

.container.hidden {
    display: none;
}

.trial-content {
    text-align: center;
    max-width: 600px;
    padding: 3rem 2rem;
}

.trial-content h1 {
    font-size: 3.5rem;
    color: #1a1a2e;
    font-weight: 600;
    margin-bottom: 2rem;
    line-height: 1.2;
}

.trial-content p {
    font-size: 1.25rem;
    color: #666;
    margin-bottom: 3rem;
    line-height: 1.6;
}

.get-started-btn {
    background: #007AFF;
    color: white;
    padding: 1.25rem 3.5rem;
    border-radius: 30px;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.get-started-btn:hover {
    background: #0051D5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

.get-started-btn:active {
    transform: translateY(0);
}
