:root {
    --bg-main: #212121;
    --bg-sidebar: #171717;
    --bg-input: #2f2f2f;
    --text-primary: #ececec;
    --text-secondary: #aaaaaa;
    --border-color: #383838;
    --accent: #19c37d; /* ChatGPT-like green */
    --accent-hover: #16b172;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-primary);
}

.sidebar-header i {
    color: var(--text-primary);
}

.new-chat-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.new-chat-btn:hover {
    background-color: #2a2a2a;
}

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

.history-item {
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.history-item.active {
    background-color: #2a2a2a;
    color: var(--text-primary);
}

.history-item:hover {
    background-color: #202020;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-profile:hover {
    background-color: #2a2a2a;
}

.user-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Main Chat Area */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at center, #232323 0%, #212121 100%);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.chat-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
}
.header-actions button:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

/* Messages */
.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 1.2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

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

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

.assistant-message .avatar {
    background-color: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.user-message .avatar {
    background-color: #555;
    color: #fff;
}

.content {
    line-height: 1.6;
    font-size: 1rem;
    padding-top: 0.4rem;
}

.content pre {
    background-color: #0d0d0d;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: inherit;
    border: 1px solid var(--border-color);
}
.content p { margin-bottom: 1rem; }
.content p:last-child { margin-bottom: 0; }

.loading {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}

.loading span {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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


/* Input Area */
.input-container {
    padding: 1.5rem;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.input-wrapper {
    position: relative;
    background-color: var(--bg-input);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    transition: border 0.3s;
}

.input-wrapper:focus-within {
    border-color: #777;
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    min-height: 24px;
    padding: 10px 0;
    outline: none;
}

#send-btn {
    background: var(--text-primary);
    color: #000;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 10px;
}

#send-btn:hover:not(:disabled) {
    background: #fff;
}

#send-btn:disabled {
    background: transparent;
    color: var(--text-secondary);
    cursor: not-allowed;
}

.input-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.8rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal {
    background: var(--bg-sidebar);
    padding: 2.5rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.modal h2 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.modal-input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.modal-input:focus {
    border-color: var(--accent);
    outline: none;
}

.primary-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--accent-hover);
}

.error-text {
    color: #ff5555;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.logout-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.6rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #ff555520;
    color: #ff5555;
    border-color: #ff555550;
}
