:root {
    --bg-main: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #f4f4f4;
    --text-main: #000000;
    --text-muted: #888888;
    --border-color: #e5e5e5;
    --primary-color: #10a37f;
    --primary-hover: #0d8c6d;
    --msg-user-bg: #f4f4f4;
    --msg-ai-bg: #ffffff;
}

.dark-mode {
    --bg-main: #000000;
    --bg-sidebar: #171717;
    --bg-input: #212121;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --border-color: #333333;
    --msg-user-bg: #2f2f2f;
    --msg-ai-bg: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
}

.app-container { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    z-index: 20;
    position: absolute;
    height: 100%;
    border-left: 1px solid var(--border-color);
}
.sidebar.closed { transform: translateX(100%); }

.sidebar-top-header {
    display: flex; justify-content: space-between; align-items: center; padding: 15px; color: var(--text-main);
}
.sidebar-menu-list {
    padding: 0 10px 15px 10px; display: flex; flex-direction: column; gap: 5px;
}
.sidebar-menu-btn {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; background: transparent; border: none; border-radius: 8px; color: var(--text-main); font-size: 15px; font-weight: 600; cursor: pointer; text-align: right; transition: background-color 0.2s;
}
.sidebar-menu-btn:hover { background-color: var(--bg-input); }
.sidebar-menu-btn i { font-size: 18px; width: 20px; text-align: center; }

.search-wrapper { cursor: text; }
.search-wrapper input {
    border: none; background: transparent; outline: none; color: var(--text-main); font-family: inherit; font-size: 15px; font-weight: 600; width: 100%;
}
.search-wrapper input::placeholder { color: var(--text-main); opacity: 0.8; }

.primary-btn {
    width: 100%; padding: 12px; background-color: var(--primary-color);
    color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 10px;
}

.chat-history { flex: 1; overflow-y: auto; padding: 10px; }
.chat-item { padding: 12px; border-radius: 8px; cursor: pointer; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; }
.chat-item:hover, .chat-item.active { background-color: var(--bg-input); }
.chat-item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.user-account { padding: 15px; border-top: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar { width: 35px; height: 35px; border-radius: 50%; }

.main-content {
    flex: 1; display: flex; flex-direction: column; position: relative; width: 100%;
}

header {
    height: 60px; background-color: var(--bg-main); z-index: 10;
}
.icon-btn { background: none; border: none; cursor: pointer; transition: 0.2s; }
.icon-btn:hover { opacity: 0.7; }

.welcome-screen {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center;
}

.chat-container {
    flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; scroll-behavior: smooth; padding-bottom: 120px;
}
.message { display: flex; gap: 15px; max-width: 800px; margin: 0 auto; width: 100%; }
.message.user { flex-direction: row-reverse; }
.msg-bubble { padding: 15px; border-radius: 12px; max-width: 80%; line-height: 1.6; }
.message.user .msg-bubble { background-color: var(--msg-user-bg); border-radius: 18px 18px 0 18px; }
.message.ai .msg-bubble { background-color: var(--msg-ai-bg); border-radius: 18px 18px 18px 0; }
.msg-image { max-width: 100%; border-radius: 8px; margin-bottom: 10px; }

.input-area {
    position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%);
    width: 95%; max-width: 800px; padding: 0; z-index: 10;
}
.image-preview-container { text-align: center; margin-bottom: 10px; }
#image-preview { height: 60px; border-radius: 8px; }
#remove-image { background: red; color: white; border: none; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; }

#message-input::placeholder { color: #888888; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 100; align-items: center; justify-content: center; }
.modal-content { background-color: var(--bg-main); padding: 30px; border-radius: 12px; width: 400px; max-width: 90%; position: relative; border: 1px solid var(--border-color); }
.close-modal { position: absolute; top: 15px; right: 15px; cursor: pointer; font-size: 20px; color: var(--text-main); }
.settings-group { margin-top: 15px; display: flex; flex-direction: column; gap: 5px; }
.settings-group input { padding: 10px; border-radius: 5px; border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-main); }
.danger-btn { width: 100%; padding: 10px; background: #e74c3c; color: white; border: none; border-radius: 5px; margin-top: 20px; cursor: pointer; }
