:root {
    /* Stunning Dark Mode Palette */
    --bg-base: #0B0E14;
    --bg-surface: rgba(20, 24, 34, 0.6);
    
    /* Vibrant Accents */
    --primary: #00F0FF; /* Neon Cyan */
    --secondary: #8A2BE2; /* Deep Neon Purple */
    --accent: #FF0055; /* Hot Pink */
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #00F0FF 0%, #8A2BE2 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    
    /* Text Colors */
    --text-main: #FFFFFF;
    --text-muted: #94A3B8;
    
    /* Glassmorphism */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Chat Bubbles */
    --user-msg-bg: var(--gradient-primary);
    --bot-msg-bg: rgba(30, 41, 59, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Quicksand', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Stunning Animated Background Orbs */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    animation: floatOrb 15s infinite ease-in-out alternate;
    opacity: 0.5;
}

.shape-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    top: -150px;
    left: -100px;
}

.shape-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    bottom: -200px;
    right: -150px;
    animation-delay: -5s;
}

.shape-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    top: 50%;
    left: 40%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
    opacity: 0.3;
}

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

/* Premium App Container */
.app-container {
    width: 95%;
    max-width: 1000px;
    height: 92vh;
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Header */
.app-header {
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: var(--gradient-glass);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo-icon {
    width: 52px;
    height: 52px;
    background: var(--gradient-primary);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 24px;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.app-header h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.header-right {
    display: flex;
    gap: 16px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.2);
    border-color: rgba(0, 240, 255, 0.3);
}

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

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

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

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Welcome Screen */
.welcome-screen {
    text-align: center;
    margin: auto;
    max-width: 550px;
    animation: scaleIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.welcome-icon {
    font-size: 72px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
    display: inline-block;
    filter: drop-shadow(0 0 15px rgba(138, 43, 226, 0.4));
    animation: floatWelcome 3s ease-in-out infinite;
}

@keyframes floatWelcome {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.welcome-screen h2 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.welcome-screen p {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 32px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.chip {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 14px;
    color: #E2E8F0;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chip:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.15);
    color: var(--primary);
}

/* Chat History */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    max-width: 85%;
    animation: messageSlide 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

.message-content {
    padding: 18px 24px;
    border-radius: 24px;
    line-height: 1.6;
    font-size: 15px;
    position: relative;
    word-break: break-word;
}

.user-message .message-content {
    background: var(--user-msg-bg);
    color: #FFFFFF;
    border-bottom-right-radius: 6px;
    box-shadow: 0 8px 25px rgba(138, 43, 226, 0.25);
    font-weight: 500;
}

.bot-message .message-content {
    background: var(--bot-msg-bg);
    color: var(--text-main);
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

/* Markdown Styles in Bot Message */
.bot-message .message-content p { margin-bottom: 16px; }
.bot-message .message-content p:last-child { margin-bottom: 0; }
.bot-message .message-content strong { font-weight: 700; color: var(--primary); }
.bot-message .message-content ul, .bot-message .message-content ol { margin-bottom: 16px; padding-left: 24px; }
.bot-message .message-content li { margin-bottom: 6px; }
.bot-message .message-content code {
    background: rgba(0, 240, 255, 0.1);
    color: var(--primary);
    padding: 3px 6px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    border: 1px solid rgba(0, 240, 255, 0.2);
}
.bot-message .message-content pre {
    background: #0B0E14;
    color: #E2E8F0;
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--glass-border);
}
.bot-message .message-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border: none;
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 14px 20px !important;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--gradient-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input Area */
.input-area {
    padding: 24px 32px;
    background: var(--gradient-glass);
    border-top: 1px solid var(--glass-border);
}

#chatForm {
    display: flex;
    gap: 16px;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px;
    transition: all 0.3s ease;
}

#chatForm:focus-within {
    border-color: var(--secondary);
    box-shadow: 0 0 20px rgba(138, 43, 226, 0.15);
    background: rgba(0, 0, 0, 0.5);
}

#messageInput {
    flex: 1;
    padding: 16px 20px;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-main);
    outline: none;
}

#messageInput::placeholder {
    color: #64748B;
}

#sendBtn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

#sendBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

#sendBtn:active {
    transform: scale(0.95);
}

/* 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: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    width: 90%;
    max-width: 450px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: translateY(30px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
}

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

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h3 i {
    color: var(--primary);
}

.close-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s;
}

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

.modal-body {
    padding: 24px;
}

.modal-body p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.6;
}

#apiKeyInput {
    width: 100%;
    padding: 16px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-main);
    margin-bottom: 16px;
    outline: none;
    transition: all 0.3s;
}

#apiKeyInput:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.2);
}

.help-text {
    font-size: 13px !important;
    color: #64748B !important;
    margin-bottom: 20px !important;
}

.link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    display: inline-block;
    padding: 8px 16px;
    background: rgba(0, 240, 255, 0.1);
    border-radius: 8px;
    transition: all 0.3s;
}

.link:hover {
    background: rgba(0, 240, 255, 0.2);
    transform: translateY(-2px);
}

.modal-footer {
    padding: 20px 24px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--glass-border);
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 12px 28px;
    background: var(--gradient-primary);
    color: var(--text-main);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.4);
}

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