:root {
    --bg-color: #ffffff;
    --chat-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --bot-msg-bg: #f1f5f9;
    --user-msg-bg: #3b82f6;
    --danger: #ef4444;
    --success: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background-image: radial-gradient(circle at top right, rgba(59, 130, 246, 0.1), transparent 400px),
                      radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent 400px);
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    height: 90dvh;
    background: #ffffff;
    backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

/* Header */
.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.bot-avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--success);
}

/* Chat Box */
.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}
.chat-box::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.15);
    border-radius: 10px;
}

.message {
    display: flex;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

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

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

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

.message-content {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.message.bot .message-content {
    background: var(--bot-msg-bg);
    border-bottom-left-radius: 4px;
}

/* System messages (e.g. status updates) */
.message.system {
    align-self: center;
    max-width: 90%;
}
.message.system .message-content {
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    padding: 5px;
    text-align: center;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 5px 10px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    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); }
    40% { transform: scale(1); }
}

/* Input Area */
.chat-input-area {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 600px) {
    .chat-container {
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 25px;
    padding: 6px 10px;
    transition: border-color 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 15px;
    font-size: 0.95rem;
    outline: none;
}

.input-wrapper input::placeholder {
    color: var(--text-secondary);
}

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

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.05);
}

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

.record-btn {
    color: var(--text-secondary);
}

.record-btn.recording {
    color: var(--danger);
    animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-danger {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.wake-btn {
    color: var(--text-secondary);
}

.wake-btn.active {
    color: var(--success);
    animation: pulse-success 1.5s infinite;
}

@keyframes pulse-success {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(5px);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, -20px);
    pointer-events: none;
}

/* Voice Profile Dropdown & Sinh trắc học */
.voice-profile-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    position: absolute;
    right: 0;
    top: 50px;
    background: #ffffff;
    backdrop-filter: blur(15px);
    border: 1px solid #e2e8f0;
    min-width: 180px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    z-index: 100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 6px;
    transition: all 0.3s ease;
}

.dropdown-content.hidden {
    display: none;
}

.dropdown-item {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 16px;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: rgba(15, 23, 42, 0.05);
}

.dropdown-item i {
    font-size: 1rem;
    width: 16px;
}

#voiceProfileBtn.has-profile {
    color: var(--success);
    filter: drop-shadow(0 0 5px var(--success));
}

#registerVoiceBtn {
    color: var(--text-primary);
}

#deleteVoiceBtn {
    color: var(--danger);
}

#ttsToggleBtn.active {
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary));
}

.voice-select {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 20px;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.voice-select:hover {
    background: #f1f5f9;
    border-color: var(--primary);
}

.voice-select option {
    background: #ffffff;
    color: var(--text-primary);
}
