:root {
    --sidebar-width: 260px;
    --sidebar-bg: #202123;
    --chat-bg: #343541;
    --message-bg-user: #444654;
    --message-bg-bot: #343541;
    --primary-color: #10a37f;
    --text-color: #ececf1;
    --border-color: #555;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: var(--chat-bg);
    color: var(--text-color);
    direction: rtl;
    height: 100vh;
    overflow: hidden;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--chat-bg);
}

.login-box {
    background: var(--sidebar-bg);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    max-width: 400px;
    margin: 0 1rem;
}

.login-logo {
    width: 80px;
    margin-bottom: 1rem;
    border-radius: 50%;
}

#password {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 1rem;
}

#loginForm button {
    width: 100%;
    padding: 0.8rem;
    background: var(--primary-color);
    border: none;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.2s;
}

#loginForm button:hover {
    opacity: 0.9;
}

.container {
    display: none;
    height: 100vh;
    position: relative;
}

.sidebar-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    border: none;
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.3s ease;
    font-size: 1.2rem;
}

.sidebar-toggle.collapsed {
    top: auto;
    bottom: 1rem;
    right: 1rem;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
}

.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    transform: translateX(100%);
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

#newChat {
    width: 100%;
    padding: 0.8rem;
    background: var(--primary-color);
    border: none;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

#newChat:hover {
    background: #0d8f6f;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.conversation-item:hover {
    background: #2b2c3f;
}

.conversation-item.active {
    background: #343541;
    font-weight: 500;
}

.conversation-item:hover .delete-conversation {
    visibility: visible;
}

.conversation-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 0.5rem;
}

.delete-conversation {
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 1.2rem;
    visibility: hidden;
    padding: 0 0.5rem;
}

.conversation-item.active .delete-conversation {
    color: #ff6666;
}

.conversation-item span[contenteditable="true"] {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    border-radius: 4px;
    padding: 0.2rem;
}

.main-chat {
    height: 100vh;
    margin-right: 0;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar:not(.collapsed) + .main-chat {
    margin-right: var(--sidebar-width);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.message {
    padding: 1rem 1.25rem;
    max-width: 85%;
    border-radius: 8px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
    font-size: 1rem;
    word-break: break-word;
    white-space: pre-wrap;
}

.user-message {
    background: var(--message-bg-user);
    margin-left: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.assistant-message {
    background: var(--message-bg-bot);
    margin-left: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.input-container {
    padding: 1.5rem;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    max-width: 90%;
    margin: 0 auto;
    position: relative;
}

#messageInput {
    width: 100%;
    height: 100%;
    padding: 1rem 4.5rem 1rem 1rem;
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 8px;
    resize: none;
    font-size: 1rem;
    line-height: 1.5;
    min-height: 70px;
    overflow-y: auto;
    transition: all 0.2s;
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

#sendButton {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    padding: 0.5rem 1.25rem;
    background: var(--primary-color);
    border: none;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#sendButton:hover {
    background: #0d8f6f;
}

.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-color);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message a {
    color: #10a37f; /* Customize this color with your desired color */
    text-decoration: none; /* Removes underline if you don't want it */
}

.message a:hover {
    color: #195546; /* Change this to the hover color you prefer */
    text-decoration: underline; /* Optionally add an underline on hover */
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }
    
    .sidebar:not(.collapsed) + .main-chat {
        margin-right: 0;
        transform: translateX(-100%);
    }
    
    .sidebar-toggle {
        right: 0.5rem;
        top: 0.5rem;
    }
}