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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    width: 100vw;
    display: flex;
    padding: 0;
    margin: 0;
    position: relative;
    overflow-x: hidden;
}

/* Particle canvas background */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: -380px;
    top: 0;
    width: 360px;
    height: 100vh;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Toggle sidebar button */
#toggle-sidebar {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 40;
}

.sidebar.open {
    left: 0;
}

.sidebar-content {
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: #f8fafc;
    border: 2px solid transparent;
}

.chat-item:hover {
    background: #f0f4ff;
    border-color: #d0deff;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.chat-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25);
    transform: scale(1.02);
}

.chat-item.active .chat-title,
.chat-item.active .chat-date {
    color: white;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a202c;
    margin-bottom: 4px;
}

.chat-date {
    font-size: 0.75rem;
    color: #718096;
}

.delete-chat-btn {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.chat-item.active .delete-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    opacity: 1;
}

.delete-chat-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.15);
}

.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 1;
}

.header-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.header-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fafbfc;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-content {
    max-width: 70%;
    padding: 16px 20px;
    border-radius: 24px;
    line-height: 1.6;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

.bot-message {
    justify-content: flex-start;
}

.bot-message .message-content {
    background: white;
    color: #1a202c;
    border-bottom-left-radius: 6px;
    border: 1px solid #e2e8f0;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
    border: none;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

/* Markdown styling for bot messages */
.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3,
.bot-message .message-content h4,
.bot-message .message-content h5,
.bot-message .message-content h6 {
    margin-top: 20px;
    margin-bottom: 12px;
    font-weight: 700;
    line-height: 1.3;
    color: #1a202c;
}

.bot-message .message-content h1 { font-size: 1.875rem; }
.bot-message .message-content h2 { font-size: 1.5rem; }
.bot-message .message-content h3 { font-size: 1.25rem; }
.bot-message .message-content h4 { font-size: 1.125rem; }
.bot-message .message-content h5 { font-size: 1rem; }
.bot-message .message-content h6 { font-size: 0.875rem; }

.bot-message .message-content h1:first-child,
.bot-message .message-content h2:first-child,
.bot-message .message-content h3:first-child,
.bot-message .message-content h4:first-child,
.bot-message .message-content h5:first-child,
.bot-message .message-content h6:first-child {
    margin-top: 0;
}

.bot-message .message-content p {
    margin-bottom: 12px;
    color: #2d3748;
}

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

.bot-message .message-content ul,
.bot-message .message-content ol {
    margin-left: 24px;
    margin-bottom: 12px;
}

.bot-message .message-content li {
    margin-bottom: 8px;
    color: #2d3748;
}

.bot-message .message-content code {
    background: #f7fafc;
    padding: 4px 8px;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d53f8c;
    border: 1px solid #e2e8f0;
}

.bot-message .message-content pre {
    background: #1a202c;
    color: #f7fafc;
    padding: 20px;
    border-radius: 12px;
    overflow-x: auto;
    margin-bottom: 12px;
    border: 1px solid #2d3748;
}

.bot-message .message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    border: none;
}

.bot-message .message-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 20px;
    margin-left: 0;
    margin-bottom: 12px;
    color: #4a5568;
    font-style: italic;
    background: #f0f4ff;
    padding: 16px 20px;
    border-radius: 8px;
}

.bot-message .message-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.bot-message .message-content a:hover {
    color: #5a67d8;
    text-decoration: underline;
}

.bot-message .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 12px;
    border-radius: 8px;
    overflow: hidden;
}

.bot-message .message-content table th,
.bot-message .message-content table td {
    border: 1px solid #e2e8f0;
    padding: 12px;
    text-align: left;
}

.bot-message .message-content table th {
    background: #f7fafc;
    font-weight: 600;
    color: #1a202c;
}

.bot-message .message-content hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 24px 0;
}

.typing-indicator {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    background: white;
    border-radius: 24px;
    border-bottom-left-radius: 6px;
    max-width: 80px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-12px);
        opacity: 1;
    }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar,
.chat-list::-webkit-scrollbar {
    width: 10px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 8px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

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

    .chat-messages {
        padding: 20px 16px;
        gap: 20px;
    }

    .message-content {
        max-width: 85%;
        padding: 14px 18px;
    }

    .sidebar {
        width: calc(100vw - 40px);
        max-width: 340px;
        left: calc(-100vw);
        padding: 12px;
    }

    .sidebar-content {
        border-radius: 20px;
    }
}