:root {
    --primary-color: #00BCD4; 
    --primary-dark: #0097A7;
    --chat-bg-color: #1e2126;
    --chat-header-bg: #282c34;
    --chat-message-received: #3e4451;
    --chat-message-sent: #00BCD4;
    --text-light: #ffffff;
    --text-muted: #abb2bf;
}

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

body {
    background-color: #121417;
    color: var(--text-light);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* --- تصميم الدخول --- */
.login-page { background-color: #121417; }
.login-container {
    background: var(--chat-header-bg);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10;
    width: 90%;
    max-width: 400px;
}
.login-container h2 { margin-bottom: 20px; color: var(--primary-color); }
.login-container input {
    width: 100%; padding: 12px; margin-bottom: 15px;
    border-radius: 8px; border: 1px solid #444; background: #1e2126; color: white; outline: none;
}
.login-container button {
    width: 100%; padding: 12px; border-radius: 8px; border: none;
    background: var(--primary-color); color: #fff; font-size: 16px; font-weight: bold; cursor: pointer;
}
.error-message { color: #ff4d4d; margin-top: 10px; font-size: 14px; }
.falling-number { position: absolute; color: rgba(0, 188, 212, 0.3); font-size: 1.2em; top: -20px; animation: fall linear infinite; z-index: 1; }
@keyframes fall { to { transform: translateY(100vh); } }

/* --- تصميم الدردشة --- */
.chat-wrapper {
    background: var(--chat-bg-color);
    width: 100%;
    max-width: 800px;
    height: 90vh; /* في الكمبيوتر */
    display: flex;
    flex-direction: column;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    overflow: hidden;
}

/* تجاوب الهاتف (تأخذ الشاشة بالكامل) */
@media (max-width: 768px) {
    .chat-wrapper {
        height: 100vh;
        height: 100dvh; /* لدعم متصفحات الهواتف الحديثة */
        border-radius: 0;
    }
}

.chat-header {
    background: var(--chat-header-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}
.header-info h2 { font-size: 18px; margin-bottom: 2px; }
.header-info p { font-size: 12px; color: var(--text-muted); }
.online-dot { display: inline-block; width: 8px; height: 8px; background: #4caf50; border-radius: 50%; margin-right: 5px; }

.profile-settings-button {
    background: none; border: none; color: white; font-size: 24px; cursor: pointer;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* تنسيق الرسائل */
.message { display: flex; flex-direction: column; max-width: 75%; }
.message.sent { align-self: flex-start; }
.message.received { align-self: flex-end; }

.message-content {
    padding: 12px 16px;
    border-radius: 15px;
    position: relative;
    word-wrap: break-word;
}
.message.sent .message-content {
    background: var(--chat-message-sent);
    color: #fff;
    border-top-right-radius: 2px;
}
.message.received .message-content {
    background: var(--chat-message-received);
    border-top-left-radius: 2px;
}

.sender-name { font-size: 11px; font-weight: bold; margin-bottom: 5px; display: block; opacity: 0.8; }
.message p { font-size: 15px; margin-bottom: 5px; line-height: 1.4; }
.message-time { font-size: 10px; opacity: 0.7; text-align: left; display: block; }

/* منطقة الإدخال */
.chat-input-area {
    background: var(--chat-header-bg);
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.input-container { flex-grow: 1; }
.input-container input {
    width: 100%; padding: 12px 15px; border-radius: 25px; border: none;
    background: #1e2126; color: white; outline: none; font-size: 15px;
}
#sendMessage {
    background: var(--primary-color); border: none; width: 45px; height: 45px;
    border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; color: white;
}
.send-icon { width: 20px; height: 20px; transform: rotate(180deg); /* تدوير الأيقونة لتدعم الـ RTL */ }

/* نافذة الملف الشخصي */
.profile-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 100; }
.profile-modal-content {
    background: var(--chat-header-bg); width: 90%; max-width: 350px; margin: 100px auto; padding: 25px;
    border-radius: 15px; position: relative;
}
.close-button { position: absolute; left: 20px; top: 15px; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.profile-info { margin-top: 20px; }
.profile-info input { width: 100%; padding: 10px; margin-top: 8px; border-radius: 8px; border: 1px solid #444; background: #1e2126; color: white; }
#saveProfileInfo { width: 100%; padding: 10px; margin-top: 20px; background: var(--primary-color); border: none; border-radius: 8px; color: white; font-weight: bold; cursor: pointer; }