:root {
    --bg-dark: #0f111a;
    --panel-bg: rgba(22, 25, 43, 0.65);
    --bot-msg-bg: rgba(33, 38, 64, 0.7);
    --user-msg-bg: linear-gradient(135deg, #4f46e5, #6366f1);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-stack);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-image:
        radial-gradient(ellipse at top left, rgba(79, 70, 229, 0.15) 0%, transparent 40%),
        radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.15) 0%, transparent 40%);
}

.app-container {
    display: flex;
    width: 100%;
    max-width: 1300px;
    height: 90vh;
    margin: 0 auto;
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 17, 26, 0.4);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #4f46e5, #8b5cf6);
    border-radius: 8px;
    box-shadow: 0 0 15px var(--accent-glow);
}

.logo h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 32px;
}

.glow-button {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.glow-button:hover {
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
}

/* Chat Main Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(22, 25, 43, 0.3);
}

.chat-header h3 {
    font-size: 1.05rem;
    font-weight: 500;
}

.status {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Chat History */
.chat-history {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

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

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: fadeIn 0.4s ease forwards;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.assistant-avatar {
    background: linear-gradient(135deg, #4f46e5, #8b5cf6);
    box-shadow: 0 0 10px var(--accent-glow);
}

.user-avatar {
    background: #374151;
}

.message-content {
    padding: 16px 20px;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.assistant-message .message-content {
    background: var(--bot-msg-bg);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.user-message .message-content {
    background: var(--user-msg-bg);
    border-top-right-radius: 4px;
    box-shadow: 0 10px 20px -10px rgba(79, 70, 229, 0.5);
}

/* Markdown Styles inside message content */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 10px 0;
    font-weight: 600;
}

.message-content h1 {
    font-size: 1.25rem;
}

.message-content h2 {
    font-size: 1.15rem;
}

.message-content h3 {
    font-size: 1.05rem;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 10px 0 10px 20px;
}

.message-content li {
    margin-bottom: 6px;
}

.message-content strong {
    color: #fff;
    font-weight: 600;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.message-content th,
.message-content td {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    text-align: left;
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

.message-content a {
    color: var(--accent);
    text-decoration: underline;
    word-break: break-all;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 8px;
}

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

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}


/* Input Area */
.chat-input-wrapper {
    padding: 24px 30px;
    background: linear-gradient(to top, var(--panel-bg) 70%, transparent);
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(15, 17, 26, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.chat-input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    padding: 8px 4px;
    max-height: 150px;
    min-height: 60px;
    overflow-y: auto;
}

#chat-input:focus {
    outline: none;
}

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

.send-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--accent);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s;
    height: 40px;
    width: 40px;
}

.send-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.send-btn svg {
    width: 20px;
    height: 20px;
    transform: rotate(-45deg);
    transition: transform 0.2s;
}

.send-btn:hover svg {
    transform: rotate(0) scale(1.1);
}

.send-btn:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

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

    .message {
        max-width: 90%;
    }
}