/* style.css */
:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F3F4F6;
    --chat-bg: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --user-msg-bg: #4F46E5;
    --user-msg-text: #FFFFFF;
    --bot-msg-bg: #F3F4F6;
    --bot-msg-text: #111827;
    --border-color: #E5E7EB;
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --sidebar-hover: #F3F4F6;
    --sidebar-active: #E0E7FF;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 100% 0%, #e0e7ff 0%, transparent 50%), 
                      radial-gradient(circle at 0% 100%, #fef08a 0%, transparent 50%);
    background-attachment: fixed;
    height: 100vh;
    color: var(--text-main);
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    height: 100%;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

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

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

#new-chat-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#new-chat-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}
.chat-list::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 10px;
}

.chat-item {
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
    border: 1px solid transparent;
}

.chat-item:hover {
    background: var(--sidebar-hover);
}

.chat-item.active {
    background: var(--sidebar-active);
    border-color: rgba(79, 70, 229, 0.2);
}

.chat-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.delete-btn {
    background: transparent;
    border: none;
    color: #EF4444;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

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

.delete-btn:hover {
    background: #FEE2E2;
}

/* Chat Container */
.chat-container {
    flex: 1;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.mobile-menu-btn {
    display: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
}

.chat-header {
    padding: 20px 24px;
    background: var(--chat-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.8rem;
    animation: bounce 2s infinite ease-in-out;
}

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

.chat-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4F46E5, #9333EA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

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

.chat-box::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 10px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: slideIn 0.3s ease-out;
}

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

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

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

.avatar {
    width: 36px;
    height: 36px;
    background: #E0E7FF;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-message .avatar {
    background: #FEF08A;
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    box-shadow: var(--shadow-sm);
    word-break: break-word;
}

.bot-message .bubble {
    background: var(--bot-msg-bg);
    color: var(--bot-msg-text);
    border-top-left-radius: 4px;
}

.user-message .bubble {
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-top-right-radius: 4px;
}

.bubble p {
    margin-bottom: 8px;
}
.bubble p:last-child {
    margin-bottom: 0;
}

.chat-input-area {
    padding: 16px 24px;
    background: var(--chat-bg);
    border-top: 1px solid var(--border-color);
}

#chat-form {
    display: flex;
    gap: 12px;
    background: var(--bg-color);
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

#chat-form:focus-within {
    border-color: var(--primary-color);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.95rem;
    padding: 8px 4px;
    color: var(--text-main);
}

#user-input::placeholder {
    color: #9CA3AF;
}

#send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 4px;
    align-items: center;
}

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

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

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

/* markdown specific styles */
.bubble pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: monospace;
}

.bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.bot-message .bubble code {
    background: rgba(0,0,0,0.05);
}

.user-message .bubble code {
    background: rgba(255,255,255,0.2);
}

.bubble ul, .bubble ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.bubble strong {
    font-weight: 600;
}

@media (max-width: 768px) {
    .app-container {
        padding: 0;
        gap: 0;
    }
    
    .chat-container {
        border-radius: 0;
        border: none;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        border-radius: 0;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-menu-btn {
        display: block;
        position: absolute;
        left: 16px;
        top: 24px;
    }
}
