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

:root {
    --primary-color: #10a37f;
    --primary-hover: #0d8a6a;
    --bg-dark: #343541;
    --bg-darker: #202123;
    --bg-light: #444654;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --border-color: #565869;
    --error-color: #ef4444;
    --user-bg: #343541;
    --assistant-bg: #444654;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Auth Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-box {
    background: var(--bg-darker);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    margin-bottom: 24px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-light);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--primary-color);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

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

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    text-align: center;
}

/* Chat Container */
.chat-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-darker);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s;
}

.sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar-header {
    padding: 16px;
}

.btn-new-chat {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-new-chat:hover {
    background: var(--bg-light);
}

.btn-new-chat span {
    font-size: 1.25rem;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.conversation-item:hover {
    background: var(--bg-light);
}

.conversation-item.active {
    background: var(--bg-light);
    color: var(--text-primary);
}

.conversation-item .delete-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
}

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

.conversation-item .delete-btn:hover {
    color: var(--error-color);
}

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

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--bg-light);
    color: var(--error-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 16px 24px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    display: none;
}

.chat-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.welcome-message p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 500px;
}

.suggestion {
    padding: 16px;
    background: var(--bg-light);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.suggestion:hover {
    background: var(--border-color);
}

/* Message Styles */
.message {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
}

.message:last-child {
    border-bottom: none;
}

.message.user {
    background: var(--user-bg);
}

.message.assistant {
    background: var(--assistant-bg);
}

.message-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 16px;
}

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

.message.user .message-avatar {
    background: var(--primary-color);
}

.message.assistant .message-avatar {
    background: var(--primary-color);
}

.message-text {
    flex: 1;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text code {
    background: var(--bg-darker);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}

.message-text pre {
    background: var(--bg-darker);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: none;
    padding: 0;
}

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

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

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

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

/* Chat Input */
.chat-input-container {
    padding: 16px 24px 24px;
    background: var(--bg-dark);
}

#chat-form {
    display: flex;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
    padding: 14px 16px;
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#send-btn {
    padding: 14px 20px;
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .btn-toggle {
        display: block;
    }
    
    .suggestions {
        grid-template-columns: 1fr;
    }
    
    .message-content {
        padding: 0 12px;
    }
    
    .chat-input-container {
        padding: 12px;
    }
    
    #chat-form {
        padding: 0;
    }
}
