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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 800px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 900px;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 20px 20px 0 0;
}

.chat-header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 15px;
}

.config-section {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 15px;
}

.config-section label {
    font-size: 14px;
}

.config-section input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.welcome-message {
    text-align: center;
    color: #667eea;
    padding: 40px 20px;
    font-size: 18px;
    line-height: 1.6;
}

.message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 18px 18px 18px 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    padding: 0 8px;
}

.message.user .message-time {
    text-align: right;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.3s;
    outline: none;
}

#message-input:focus {
    border-color: #667eea;
}

.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-icon {
    background: none;
    border: none;
    color: #667eea;
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(102, 126, 234, 0.1);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
}

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

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

.status-dot.error {
    background: #ef4444;
}

.status-dot.loading {
    background: #f59e0b;
}

.rag-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 350px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: transform 0.3s;
}

.rag-panel.collapsed .rag-content {
    display: none;
}

.rag-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rag-header h3 {
    font-size: 16px;
}

.rag-content {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(80vh - 50px);
}

.rag-placeholder {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.rag-info {
    margin-bottom: 15px;
}

.rag-info h4 {
    font-size: 14px;
    color: #667eea;
    margin-bottom: 8px;
}

.rag-info p {
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.rag-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.tag {
    background: #f3f4f6;
    color: #667eea;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.rag-examples {
    margin-top: 15px;
}

.rag-example {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    border-left: 3px solid #667eea;
}

.rag-example .taiwanese {
    color: #059669;
    margin-bottom: 3px;
}

.rag-example .mandarin {
    color: #666;
}

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

.chat-container::-webkit-scrollbar-track,
.rag-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-container::-webkit-scrollbar-thumb,
.rag-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.rag-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .rag-panel {
        display: none;
    }

    .container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
    }

    .message-content {
        max-width: 85%;
    }
}
