:root {
    --bg-color: #0f111a;
    --sidebar-bg: #1e212b;
    --chat-bg: #161821;
    --user-msg-bg: #2b3040;
    --ai-msg-bg: #1e212b;
    --accent-color: #4a90e2;
    --text-color: #e0e6ed;
    --text-muted: #9499a0;
    --border-color: #2b3040;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Auth Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.auth-container {
    background: var(--sidebar-bg);
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
}

.auth-header {
    margin-bottom: 2rem;
    text-align: center;
}

.auth-header h2 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--chat-bg);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent-color);
}

.btn {
    width: 100%;
    padding: 0.8rem;
    border-radius: 6px;
    border: none;
    background: linear-gradient(135deg, var(--accent-color), #357abd);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.auth-toggle {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

.auth-toggle a {
    color: var(--accent-color);
    text-decoration: none;
    cursor: pointer;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.login-btn-sidebar {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

.history-item {
    padding: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
    transition: background 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    position: relative;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 150px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message.ai .avatar {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    /* Gemini-like gradient backup */
    background: url('https://upload.wikimedia.org/wikipedia/commons/8/8a/Google_Gemini_logo.svg') center/cover no-repeat;
    background-size: 24px;
    background-color: #fff;
    border: 1px solid #ddd;
}

.message-content {
    background: var(--ai-msg-bg);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border-top-left-radius: 2px;
    max-width: 80%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
    background: var(--user-msg-bg);
    border-radius: 12px;
    border-top-right-radius: 2px;
}

/* Markdown Styles inside message content */
.message-content pre {
    background: #0d1117;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.message-content code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content p {
    margin-bottom: 0.8rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.message-content a {
    color: var(--accent-color);
}

/* Input Area */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2rem;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
    display: flex;
    justify-content: center;
}

.input-container {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 1.2rem;
    padding-right: 3.5rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-color);
    font-size: 1rem;
    resize: none;
    outline: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.2s, border-color 0.2s;
    overflow-y: hidden;
    /* Auto grow not implemented for simplicity */
    height: 60px;
}

.chat-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.15);
}

.send-btn {
    position: absolute;
    right: 15px;
    bottom: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.send-btn:hover {
    color: var(--accent-color);
}

.send-btn i {
    font-size: 1.3rem;
}

/* Loading Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100%;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(260px);
    }
}