* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #0ea5e9;
    --dark-bg: #0f0f23;
    --darker-bg: #0a0a18;
    --card-bg: #1a1a2e;
    --card-border: #2d2d42;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --user-msg: #3b82f6;
    --ai-msg: #374151;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 900px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 90vh;
    border: 1px solid var(--card-border);
    transition: var(--transition);
}

.header {
    background: linear-gradient(135deg, var(--darker-bg) 0%, var(--card-bg) 100%);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo i {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.3));
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: var(--success);
    opacity: 0.4;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.4; }
    70% { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(1.8); opacity: 0; }
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    background: var(--darker-bg);
}

.welcome-message {
    text-align: center;
    padding: 25px;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.4rem;
    font-weight: 600;
}

.welcome-message p {
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 80%;
    padding: 18px 22px;
    border-radius: var(--radius);
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.4s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--user-msg), #2563eb);
    color: white;
    border-bottom-right-radius: 6px;
}

.ai-message {
    align-self: flex-start;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    border-bottom-left-radius: 6px;
}

.message-content {
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 8px;
    text-align: right;
    font-weight: 500;
}

.error-message {
    align-self: center;
    background: var(--error);
    color: white;
    text-align: center;
    max-width: 90%;
    border-radius: 10px;
    padding: 15px 20px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    align-self: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.input-area {
    border-top: 1px solid var(--card-border);
    padding-top: 20px;
    background: var(--darker-bg);
}

.message-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
    max-height: 120px;
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#messageInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    background: var(--card-border);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.char-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.suggestions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.suggestion-chip {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.suggestion-chip:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.footer {
    background: var(--darker-bg);
    text-align: center;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--card-border);
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--darker-bg);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.message-link {
    color: var(--primary-light);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-light);
    transition: var(--transition);
    padding: 0 2px;
}

.message-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    border-radius: 3px;
}

.message-bold {
    font-weight: 700;
    color: var(--text-primary);
}

.message-italic {
    font-style: italic;
    opacity: 0.9;
}

.message-code {
    background: rgba(30, 41, 59, 0.5);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'Courier New', Monaco, monospace;
    font-size: 0.9em;
    color: var(--primary-light);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.ai-message .message-link {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
}

.ai-message .message-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(139, 92, 246, 0.15);
}

.user-message .message-link,
.user-message .message-bold,
.user-message .message-italic,
.user-message .message-code {
    color: inherit;
    opacity: 0.95;
}

.user-message .message-link {
    border-bottom-color: rgba(255, 255, 255, 0.7);
}

.user-message .message-link:hover {
    border-bottom-color: white;
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .container {
        height: 95vh;
        border-radius: 12px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .logo h1 {
        font-size: 1.3rem;
    }
    
    .message {
        max-width: 90%;
        padding: 15px 18px;
    }
    
    .chat-container {
        padding: 15px;
    }
    
    .send-button {
        width: 50px;
        height: 50px;
    }
    
    .suggestions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .message {
        max-width: 95%;
    }
    
    .suggestions {
        justify-content: center;
    }
    
    .suggestion-chip {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}