:root {
    /* Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    
    /* Message Colors */
    --msg-user-bg: var(--primary);
    --msg-user-text: #ffffff;
    --msg-ai-bg: rgba(255, 255, 255, 0.05);
    --msg-ai-text: #f1f5f9;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Radii */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Background Animation */
.background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--primary);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--secondary);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 50%;
    width: 400px;
    height: 400px;
    background: #8b5cf6;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(100px, 50px) scale(1.2); }
    100% { transform: translate(-50px, 100px) scale(0.9); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-glass);
    text-align: center;
    backdrop-filter: blur(16px);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    margin-bottom: 1rem;
}

.modal-icon {
    color: var(--primary);
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.modal h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.modal p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal input {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal input:focus {
    border-color: var(--primary);
}

.modal .btn-primary, .modal .btn-secondary {
    width: 100%;
}

/* Settings Modal Specific */
.settings-modal {
    text-align: left;
}

.settings-modal h2 {
    text-align: center;
}

.settings-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.settings-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

.settings-group select,
.settings-group textarea,
.settings-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.settings-group select:focus,
.settings-group textarea:focus,
.settings-group input:focus {
    border-color: var(--primary);
}

.settings-group select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

.settings-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.settings-actions .btn-primary,
.settings-actions .btn-secondary {
    flex: 1;
}

.modal-footer {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 1rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
}

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

.logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Messages */
.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: slideIn 0.3s ease-out forwards;
}

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

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

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.user-message .avatar {
    background: var(--text-main);
    color: var(--primary);
}

.ai-message .avatar {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    line-height: 1.6;
    font-size: 0.95rem;
}

.user-message .message-content {
    background: var(--msg-user-bg);
    color: var(--msg-user-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.ai-message .message-content {
    background: var(--msg-ai-bg);
    color: var(--msg-ai-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Markdown Styles in Messages */
.message-content p { margin-bottom: 0.75rem; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.message-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 0.75rem;
}
.message-content pre code {
    background: transparent;
    padding: 0;
}

/* Loading Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Footer & Input */
.app-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 0.5rem;
    transition: border-color 0.3s;
}

.chat-form:focus-within {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
}

.chat-form input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    padding: 0.5rem 1rem;
    outline: none;
}

.chat-form input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

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

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

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

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

.send-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    
    .message {
        max-width: 95%;
    }
}
