:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-chat: #0d0d14;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --user-bubble: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --ai-bubble: #1e1e2e;
    --border: rgba(255,255,255,0.08);
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-chat: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --ai-bubble: #ffffff;
    --border: rgba(0,0,0,0.08);
    --shadow: 0 8px 32px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s ease;
}

/* Welcome Screen */
.welcome-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 1000;
    animation: fadeOut 0.5s ease 4s forwards;
}

.welcome-content {
    text-align: center;
    animation: slideUp 0.8s ease;
}

.logo-glow {
    position: relative;
    display: inline-block;
    margin-bottom: 2rem;
}

.logo {
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #ec4899, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 20px rgba(99,102,241,0.5)); }
    to { filter: drop-shadow(0 0 40px rgba(139,92,246,0.8)); }
}

.welcome-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0;
    animation: fadeIn 0.8s ease 0.5s forwards;
}

.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeIn 0.8s ease 0.8s forwards;
}

.start-btn {
    padding: 1rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    cursor: pointer;
    opacity: 0;
    animation: fadeIn 0.8s ease 1.1s forwards, pulse 2s infinite;
    transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px var(--accent-glow);
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.app.visible {
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
}

.ai-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

.avatar-glow {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    opacity: 0.5;
    filter: blur(8px);
    animation: pulse 3s infinite;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.icon-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(1.05);
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-chat);
    scroll-behavior: smooth;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: slideIn 0.3s ease;
}

.user-message {
    align-self: flex-end;
}

.ai-message {
    align-self: flex-start;
}

.message-bubble {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: var(--shadow);
}

.user-message .message-bubble {
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.ai-message .message-bubble {
    background: var(--ai-bubble);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.7;
}

.user-message .message-time {
    align-self: flex-end;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    animation: slideIn 0.3s ease;
}

.typing-bubble {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--ai-bubble);
    border-radius: 1.25rem;
    border: 1px solid var(--border);
}

.typing-bubble span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-bubble span:nth-child(1) { animation-delay: 0s; }
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

.typing-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--bg-chat);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: all 0.2s;
    max-height: 120px;
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.mic-btn, .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mic-btn {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    border: 1px solid var(--border);
}

.mic-btn:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.05);
}

.mic-btn.recording {
    background: #ef4444;
    color: white;
    animation: pulse 1s infinite;
}

.send-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0.5rem auto 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.speak-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.speak-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Voice Overlay */
.voice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.voice-wave {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.voice-wave span {
    width: 6px;
    height: 40px;
    background: linear-gradient(180deg, #6366f1, #ec4899);
    border-radius: 3px;
    animation: wave 1s infinite ease-in-out;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; height: 20px; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; height: 35px; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; height: 50px; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; height: 35px; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; height: 20px; }

.voice-overlay p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.stop-mic-btn {
    padding: 0.75rem 2rem;
    border-radius: 50px;
    border: 1px solid #ef4444;
    background: transparent;
    color: #ef4444;
    cursor: pointer;
    transition: all 0.2s;
}

.stop-mic-btn:hover {
    background: #ef4444;
    color: white;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes wave {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1); }
}

/* Scrollbar */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Mobile */
@media (max-width: 640px) {
    .message { max-width: 90%; }
    .welcome-content h1 { font-size: 1.75rem; }
    .logo { font-size: 3rem; }
    .input-area { padding: 0.75rem 1rem; }
}
