* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #343541;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #202123;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #2c2d30;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: #2c2d30;
    border: 1px solid #4a4b4f;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: #3a3b3f;
}

.user-section {
    padding: 16px;
    border-bottom: 1px solid #2c2d30;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-name {
    color: white;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-btn {
    background: none;
    border: none;
    color: #10a37f;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
}

.auth-btn:hover {
    background: #2c2d30;
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.chat-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.2s;
    color: #ececec;
}

.chat-item:hover {
    background: #2c2d30;
}

.chat-item.active {
    background: #2c2d30;
}

.chat-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 12px;
    color: #8e8e8e;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #343541;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #2c2d30;
    background: #343541;
}

.chat-header h2 {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.message {
    display: flex;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .message-content {
    background: #10a37f;
    color: white;
}

.message.assistant .message-content {
    background: #2c2d30;
    color: #ececec;
}

.message.assistant {
    justify-content: flex-start;
}

/* Input Area */
.input-area {
    padding: 16px 24px;
    border-top: 1px solid #2c2d30;
    background: #343541;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-container textarea {
    flex: 1;
    padding: 12px;
    background: #40414f;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    resize: none;
    font-family: inherit;
}

.input-container textarea:focus {
    outline: none;
    background: #4a4b5a;
}

.send-btn {
    padding: 12px 24px;
    background: #10a37f;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #0e8a6b;
}

.send-btn:disabled {
    background: #5c5c6b;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #202123;
    border-radius: 12px;
    padding: 24px;
    width: 400px;
    color: white;
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    background: #2c2d30;
    border: 1px solid #4a4b4f;
    border-radius: 6px;
    color: white;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

.modal-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.modal-buttons button.primary {
    background: #10a37f;
    color: white;
}

.modal-buttons button.secondary {
    background: #2c2d30;
    color: white;
}

/* Loading indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #2c2d30;
    border-top-color: #10a37f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: block;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 101;
        background: #2c2d30;
        color: white;
        border: none;
        padding: 8px 12px;
        border-radius: 8px;
        cursor: pointer;
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
}