:root {
    --aiva-bg: #ffffff;
    --aiva-surface: #f9fafb;
    --aiva-surface-2: #f3f4f6;
    --aiva-border: #e5e7eb;
    --aiva-text: #111827;
    --aiva-text-secondary: #6b7280;
    --aiva-text-muted: #9ca3af;
    --aiva-primary: #6366f1;
    --aiva-primary-light: #818cf8;
    --aiva-primary-dark: #4f46e5;
    --aiva-user-bg: #6366f1;
    --aiva-user-text: #ffffff;
    --aiva-bot-bg: #f3f4f6;
    --aiva-bot-text: #1f2937;
    --aiva-green: #22c55e;
    --aiva-red: #ef4444;
    --aiva-orange: #f59e0b;
    --aiva-shadow: 0 4px 24px rgba(0,0,0,0.08);
    --aiva-radius: 16px;
    --aiva-radius-sm: 10px;
    --aiva-input-bg: #ffffff;
    --aiva-input-border: #d1d5db;
    --aiva-header-bg: #6366f1;
    --aiva-header-text: #ffffff;
}

.aiva-dark {
    --aiva-bg: #0f172a;
    --aiva-surface: #1e293b;
    --aiva-surface-2: #1e293b;
    --aiva-border: #334155;
    --aiva-text: #f1f5f9;
    --aiva-text-secondary: #94a3b8;
    --aiva-text-muted: #64748b;
    --aiva-bot-bg: #1e293b;
    --aiva-bot-text: #e2e8f0;
    --aiva-shadow: 0 4px 24px rgba(0,0,0,0.3);
    --aiva-input-bg: #1e293b;
    --aiva-input-border: #334155;
    --aiva-header-bg: #1e293b;
}

.aiva-container {
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--aiva-bg);
    border-radius: var(--aiva-radius);
    border: 1px solid var(--aiva-border);
    box-shadow: var(--aiva-shadow);
    display: flex;
    flex-direction: column;
    height: 700px;
    max-height: 85vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
    color: var(--aiva-text);
}

.aiva-header {
    background: var(--aiva-header-bg);
    color: var(--aiva-header-text);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.aiva-header-left { display: flex; align-items: center; gap: 12px; }
.aiva-header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.aiva-header-name { font-size: 15px; font-weight: 600; }
.aiva-header-status { font-size: 12px; opacity: 0.8; display: flex; align-items: center; gap: 6px; }
.aiva-online-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #4ade80;
    display: inline-block;
    animation: aivaPulse 2s ease-in-out infinite;
}
@keyframes aivaPulse {
    0%,100% { opacity:1; box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
    50% { opacity:0.8; box-shadow: 0 0 0 6px rgba(74,222,128,0); }
}
.aiva-header-actions { display: flex; gap: 6px; }
.aiva-header-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: none;
    color: var(--aiva-header-text); cursor: pointer;
    font-size: 14px; transition: background 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.aiva-header-btn:hover { background: rgba(255,255,255,0.2); }

.aiva-messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
    background: var(--aiva-surface);
    scrollbar-width: thin;
    scrollbar-color: var(--aiva-border) transparent;
}
.aiva-messages::-webkit-scrollbar { width: 5px; }
.aiva-messages::-webkit-scrollbar-thumb { background: var(--aiva-border); border-radius: 3px; }

.aiva-welcome {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center;
    flex: 1; padding: 40px 20px;
}
.aiva-welcome-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, var(--aiva-primary), var(--aiva-primary-light));
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: #fff; margin-bottom: 18px;
    box-shadow: 0 8px 30px rgba(99,102,241,0.3);
}
.aiva-welcome h3 {
    font-size: 20px; font-weight: 700; color: var(--aiva-text);
    margin: 0 0 6px;
}
.aiva-welcome p {
    font-size: 14px; color: var(--aiva-text-secondary);
    max-width: 380px; margin: 0 0 20px;
}
.aiva-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.aiva-suggestion {
    padding: 8px 16px; border-radius: 20px; font-size: 13px;
    background: var(--aiva-bg); border: 1px solid var(--aiva-border);
    color: var(--aiva-text); cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.aiva-suggestion:hover {
    border-color: var(--aiva-primary); color: var(--aiva-primary);
    background: rgba(99,102,241,0.05);
}

.aiva-msg {
    display: flex; gap: 10px; max-width: 85%;
    animation: aivaFadeIn 0.3s ease;
}
@keyframes aivaFadeIn {
    from { opacity:0; transform:translateY(8px); }
    to { opacity:1; transform:translateY(0); }
}
.aiva-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.aiva-msg.bot { align-self: flex-start; }

.aiva-msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; margin-top: 2px;
}
.aiva-msg.bot .aiva-msg-avatar { background: linear-gradient(135deg, var(--aiva-primary), var(--aiva-primary-light)); color: #fff; }
.aiva-msg.user .aiva-msg-avatar { background: var(--aiva-surface-2); color: var(--aiva-text-secondary); }

.aiva-msg-content { display: flex; flex-direction: column; gap: 4px; }
.aiva-msg.user .aiva-msg-content { align-items: flex-end; }

.aiva-bubble {
    padding: 12px 16px; border-radius: 18px;
    font-size: 14px; line-height: 1.6; word-break: break-word;
}
.aiva-msg.bot .aiva-bubble {
    background: var(--aiva-bot-bg); color: var(--aiva-bot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--aiva-border);
}
.aiva-msg.user .aiva-bubble {
    background: var(--aiva-user-bg); color: var(--aiva-user-text);
    border-bottom-right-radius: 4px;
}
.aiva-bubble strong { font-weight: 600; }
.aiva-bubble em { font-style: italic; }
.aiva-bubble code {
    background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 4px;
    font-size: 13px; font-family: 'SF Mono', Consolas, monospace;
}
.aiva-dark .aiva-bubble code { background: rgba(255,255,255,0.08); }
.aiva-bubble pre {
    background: #1e293b; color: #e2e8f0; padding: 12px 16px;
    border-radius: 10px; overflow-x: auto; font-size: 13px;
    margin: 8px 0; font-family: 'SF Mono', Consolas, monospace;
}
.aiva-bubble pre code { background: none; padding: 0; font-size: inherit; }
.aiva-bubble ul, .aiva-bubble ol { margin: 6px 0; padding-left: 20px; }
.aiva-bubble li { margin: 3px 0; }

.aiva-msg-time {
    font-size: 11px; color: var(--aiva-text-muted);
    padding: 0 4px;
}

.aiva-typing {
    display: flex; gap: 5px; padding: 12px 16px;
    background: var(--aiva-bot-bg); border-radius: 18px;
    border-bottom-left-radius: 4px; border: 1px solid var(--aiva-border);
}
.aiva-typing span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--aiva-text-muted);
    animation: aivaBounce 1.4s ease-in-out infinite;
}
.aiva-typing span:nth-child(2) { animation-delay: 0.2s; }
.aiva-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aivaBounce {
    0%,80%,100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.aiva-input-area {
    padding: 14px 16px; border-top: 1px solid var(--aiva-border);
    background: var(--aiva-bg); flex-shrink: 0;
}
.aiva-input-row {
    display: flex; align-items: flex-end; gap: 8px;
}
.aiva-input-row textarea {
    flex: 1; resize: none; border: 1px solid var(--aiva-input-border);
    border-radius: var(--aiva-radius-sm); padding: 10px 14px;
    font-size: 14px; font-family: inherit;
    background: var(--aiva-input-bg); color: var(--aiva-text);
    outline: none; min-height: 42px; max-height: 120px;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
}
.aiva-input-row textarea:focus {
    border-color: var(--aiva-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.aiva-input-row textarea::placeholder { color: var(--aiva-text-muted); }

.aiva-mic-btn, .aiva-send-btn {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    cursor: pointer; font-size: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.aiva-mic-btn {
    background: var(--aiva-surface-2); color: var(--aiva-text-secondary);
    border: 1px solid var(--aiva-border);
}
.aiva-mic-btn:hover { background: var(--aiva-border); color: var(--aiva-text); }
.aiva-mic-btn.listening {
    background: var(--aiva-red); color: #fff; border-color: var(--aiva-red);
    animation: aivaMicPulse 1.5s ease-in-out infinite;
}
@keyframes aivaMicPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
}

.aiva-send-btn {
    background: var(--aiva-primary); color: #fff;
}
.aiva-send-btn:hover { background: var(--aiva-primary-dark); }
.aiva-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.aiva-voice-indicator {
    display: none;
    align-items: center; justify-content: center; gap: 14px;
    padding: 12px 16px; margin-bottom: 10px;
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--aiva-radius-sm);
}
.aiva-voice-indicator.active { display: flex; }

.aiva-voice-waves {
    display: flex; align-items: center; gap: 3px; height: 24px;
}
.aiva-voice-waves span {
    width: 3px; background: var(--aiva-red); border-radius: 2px;
    animation: aivaWave 1s ease-in-out infinite;
}
.aiva-voice-waves span:nth-child(1) { height: 8px; animation-delay: 0s; }
.aiva-voice-waves span:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.aiva-voice-waves span:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.aiva-voice-waves span:nth-child(4) { height: 16px; animation-delay: 0.3s; }
.aiva-voice-waves span:nth-child(5) { height: 8px; animation-delay: 0.4s; }
@keyframes aivaWave {
    0%,100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.2); }
}
.aiva-voice-text { font-size: 14px; font-weight: 500; color: var(--aiva-red); }
.aiva-voice-stop {
    padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
    background: var(--aiva-red); color: #fff; border: none;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; gap: 6px;
}
.aiva-voice-stop:hover { background: #dc2626; }

.aiva-footer-text {
    text-align: center; font-size: 11px; color: var(--aiva-text-muted);
    margin-top: 8px;
}

@media (max-width: 768px) {
    .aiva-container { height: 100vh; max-height: 100vh; border-radius: 0; border: none; }
    .aiva-msg { max-width: 90%; }
    .aiva-bubble { font-size: 14px; padding: 10px 14px; }
    .aiva-welcome { padding: 30px 16px; }
    .aiva-suggestions { gap: 6px; }
    .aiva-suggestion { font-size: 12px; padding: 6px 12px; }
}
@media (max-width: 480px) {
    .aiva-header-name { font-size: 14px; }
    .aiva-header-avatar { width: 36px; height: 36px; font-size: 16px; }
}
