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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f0f;
    color: #fff;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #171717;
    border-right: 1px solid #2a2a2a;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    margin-bottom: 20px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 20px;
}

.new-chat-btn:hover {
    background: #3a3a3a;
}

.section {
    margin-bottom: 20px;
}

.section label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 8px;
}

select {
    width: 100%;
    padding: 10px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #5a5a5a;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 12px;
    background: #2a2a2a;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #3a3a3a;
}

.conversation-item.active {
    background: #3a3a3a;
    border: 1px solid #5a5a5a;
}

.conversation-item .conv-bot {
    font-weight: 500;
    margin-bottom: 4px;
}

.conversation-item .conv-preview {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .conv-meta {
    font-size: 0.7rem;
    color: #666;
    margin-top: 4px;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #2a2a2a;
    background: #171717;
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.bot-name {
    font-weight: 600;
}

.bot-status {
    font-size: 0.8rem;
    color: #888;
}

.bot-status.loading {
    color: #fbbf24;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    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;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-bottom-right-radius: 4px;
}

.message.bot {
    align-self: flex-start;
    background: #2a2a2a;
    border-bottom-left-radius: 4px;
}

.message .sender {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 4px;
}

.message .text {
    white-space: pre-wrap;
    word-break: break-word;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #2a2a2a;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

/* Input Area */
.input-area {
    padding: 16px 24px;
    border-top: 1px solid #2a2a2a;
    background: #171717;
}

#chat-form {
    display: flex;
    gap: 12px;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 24px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
}

#message-input:focus {
    border-color: #6366f1;
}

#message-input::placeholder {
    color: #666;
}

#send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
}

#send-btn:hover {
    transform: scale(1.05);
}

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

#send-btn svg {
    width: 20px;
    height: 20px;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 4px;
}

.mode-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-tab.active {
    background: #3a3a3a;
    color: #fff;
}

.mode-tab:hover:not(.active) {
    color: #ccc;
}

/* Chatroom Start Button */
.start-chatroom-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.start-chatroom-btn:hover {
    transform: scale(1.05);
}

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

#chatroom-form {
    display: flex;
    gap: 12px;
}

#topic-input {
    flex: 1;
    padding: 12px 16px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 24px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
}

#topic-input:focus {
    border-color: #6366f1;
}

#topic-input::placeholder {
    color: #666;
}
