/* Variables */
:root {
    --primary: #1f3f69;
    --primary-dark: #12253f;
    --accent: #2c5896;
    --bg: #f8fafc;
    --bg-chat: #ffffff;
    --text: #1f2230;
    --text-light: #64748b;
    --border: #e2e8f0;
    --user-bubble: #1f3f69;
    --assistant-bubble: #f1f5f9;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 16px;
}

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

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* App Container */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-chat);
    box-shadow: var(--shadow);
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-container {
    position: relative;
    flex-shrink: 0;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--primary);
}

.header-info {
    flex: 1;
}

.header-info h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.header-info p {
    font-size: 0.85rem;
    opacity: 0.85;
}

.back-link {
    color: white;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0.5rem;
}

.back-link:hover {
    opacity: 1;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Messages */
.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-content {
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius);
    line-height: 1.5;
    font-size: 0.95rem;
}

.message.user .message-content {
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--assistant-bubble);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: #1f3f69;
    text-decoration: underline;
    font-weight: 500;
}

.message.user .message-content a {
    color: #93c5fd;
}

.message-content a:hover {
    text-decoration: none;
}

/* Speaker Button */
.speak-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 8px;
    flex-shrink: 0;
}

.speak-btn:hover {
    background: var(--primary);
    color: white;
}

.speak-btn.loading {
    background: var(--primary);
    color: white;
    animation: pulse 1s infinite;
}

.speak-btn.playing {
    background: #22c55e;
    color: white;
}

.speak-btn.error {
    background: #ef4444;
    color: white;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.message.assistant {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem 1.25rem;
}

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

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

/* Suggestions */
.suggestions {
    padding: 0.75rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.suggestion-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--accent);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 0.5rem 0;
    font-family: inherit;
}

#messageInput:focus {
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-light);
}

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

.mic-btn {
    background: transparent;
    color: var(--text-light);
}

.mic-btn:hover {
    background: var(--assistant-bubble);
    color: var(--primary);
}

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

.mic-btn.loading {
    background: var(--primary);
    color: white;
    animation: pulse 1s infinite;
}

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

.send-btn {
    background: var(--primary);
    color: white;
}

.send-btn:hover {
    background: var(--primary-dark);
}

.send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 600px) {
    .header {
        padding: 0.875rem 1rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .message {
        max-width: 90%;
    }

    .speak-btn {
        width: 28px;
        height: 28px;
    }

    .suggestions {
        padding: 0.5rem 1rem;
    }

    .suggestion-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    .input-area {
        padding: 0.75rem 1rem;
    }
}

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

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

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

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
