/**
 * ملف التصميم الرئيسي
 * Main Stylesheet - RTL Arabic
 */

/* ========== المتغيرات ========== */
:root {
    --primary-color: #6200EA;
    --secondary-color: #03DAC6;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --warning-color: #FF9800;
    --info-color: #2196F3;
    
    --bg-color: #F5F5F5;
    --card-bg: #FFFFFF;
    --text-color: #212121;
    --text-secondary: #757575;
    --border-color: #E0E0E0;
    
    --message-color-1: #4CAF50;
    --message-color-2: #2196F3;
    
    --navbar-height: 60px;
    --sidebar-width: 280px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
    
    --transition: all 0.3s ease;
}

/* ========== إعادة تعيين ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-color);
}

img {
    max-width: 100%;
    height: auto;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input, textarea, select {
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    width: 100%;
    transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(98, 0, 234, 0.1);
}

/* ========== الأزرار ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
}

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

.btn-primary:hover {
    background-color: #5000D0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #02C4B0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-block {
    width: 100%;
}

/* ========== شريط التنقل العلوي ========== */
.top-navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--navbar-height);
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.sidebar-toggle {
    font-size: 24px;
    color: var(--text-color);
    padding: 8px;
}

.navbar-brand h2 {
    color: var(--primary-color);
    font-size: 24px;
}

.navbar-icons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-icon {
    position: relative;
    font-size: 20px;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
}

.nav-icon:hover {
    color: var(--primary-color);
}

.nav-icon .badge {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--error-color);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.nav-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

/* ========== القائمة الجانبية ========== */
.sidebar {
    position: fixed;
    top: 0;
    right: -280px;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--card-bg);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar.active {
    right: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-close {
    font-size: 24px;
    color: var(--text-color);
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: var(--text-color);
    transition: var(--transition);
}

.sidebar-menu li a:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.sidebar-menu li a i {
    font-size: 20px;
    width: 25px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========== المحتوى الرئيسي ========== */
.main-content {
    min-height: 100vh;
    padding: 20px;
}

.main-content.with-navbar {
    margin-top: var(--navbar-height);
    padding-top: 30px;
}

/* ========== الرسائل التنبيهية ========== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
    cursor: pointer;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background-color: #E8F5E9;
    color: #2E7D32;
    border-right: 4px solid var(--success-color);
}

.alert-error {
    background-color: #FFEBEE;
    color: #C62828;
    border-right: 4px solid var(--error-color);
}

/* ========== صفحات المصادقة ========== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.auth-box {
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.register-box {
    max-width: 600px;
}

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

.auth-header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

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

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background-color: var(--bg-color);
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
}

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

.auth-form-container.hidden {
    display: none;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.auth-links {
    text-align: center;
    margin-top: 15px;
}

.auth-links a {
    color: var(--primary-color);
    font-size: 14px;
}

.auth-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 600;
}

.guest-info {
    margin-top: 15px;
    padding: 12px;
    background-color: var(--bg-color);
    border-radius: 8px;
    text-align: center;
}

.guest-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== صفحة الغرف ========== */
.rooms-container {
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 32px;
}

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

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.room-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.room-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.room-header h3 {
    color: var(--text-color);
    font-size: 20px;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--success-color);
    font-size: 14px;
    font-weight: 600;
}

.online-badge i {
    font-size: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.room-description {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 14px;
}

.room-last-message {
    background-color: var(--bg-color);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.last-message-user {
    font-weight: 600;
    color: var(--primary-color);
}

.last-message-text {
    color: var(--text-color);
}

.last-message-time {
    color: var(--text-secondary);
    font-size: 12px;
    margin-right: 10px;
}

/* ========== صفحة الدردشة ========== */
.chat-container {
    display: flex;
    height: calc(100vh - var(--navbar-height));
    max-width: 1400px;
    margin: 0 auto;
    gap: 0;
    position: relative;
}

/* أيقونات القائمة الجانبية اليسرى - مطابقة للصورة */
.chat-left-icons {
    position: absolute;
    left: 10px;
    top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.left-icon-group {
    display: flex;
    gap: 6px;
}

.left-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.left-icon:hover {
    background-color: #e8e8e8;
    color: #333;
}

.chat-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    font-size: 20px;
    color: white;
    padding: 5px;
}

.chat-header h2 {
    font-size: 20px;
}

.room-online-count {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 5px;
    background-color: #FAFAFA;
}

.loading-messages {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* ==================== */
/* الرسالة - مطابقة للصورة: صورة يمين + بالون يسار */
/* ==================== */
.chat-message {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
    padding: 3px 8px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* صورة المستخدم - يمين */
.message-avatar {
    flex-shrink: 0;
}

.message-avatar img {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid #e0e0e0;
}

/* محتوى الرسالة */
.message-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    max-width: calc(100% - 70px);
}

/* ==================== */
/* فقاعة الرسالة - حواف دائرية كبيرة */
/* ==================== */
.message-bubble {
    display: block;
    padding: 10px 14px;
    word-wrap: break-word;
    position: relative;
    min-width: 120px;
    border-radius: 16px 0 16px 16px;
    direction: rtl;
}

/* ==================== */
/* الذيل - مثلث يخرج من يمين الفقاعة */
/* ==================== */
.bubble-arrow {
    position: absolute;
    top: 0;
    right: -10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 14px 12px;
    border-color: transparent;
}

/* رأس الفقاعة - أيقونات يسار + اسم يمين */
.bubble-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    direction: rtl;
}

/* الجزء الأيمن: الاسم */
.bubble-username {
    font-weight: 700;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    order: 1;
}

.bubble-username:hover {
    text-decoration: underline;
}

/* الجزء الأيسر: أيقونات + وقت */
.bubble-left-section {
    display: flex;
    align-items: center;
    gap: 6px;
    order: 2;
    direction: ltr;
}

.bubble-time {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.55);
    white-space: nowrap;
}

/* أيقونات Play و Ban */
.bubble-icons {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
}

.bubble-icons i {
    cursor: pointer;
    transition: color 0.2s;
}

.bubble-icons i:hover {
    color: #333;
}

/* نص الرسالة */
.bubble-text {
    color: #333;
    font-size: 15px;
    line-height: 1.6;
    text-align: right;
    word-break: break-word;
    direction: rtl;
}

.role-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    margin-right: 6px;
}

.role-badge.admin {
    background-color: #F44336;
    color: white;
}

.role-badge.moderator {
    background-color: #FF9800;
    color: white;
}

@keyframes likeAnimation {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ========== نموذج إرسال الرسالة - مطابق للصورة ========== */
.chat-input-container {
    padding: 10px 15px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
}

.chat-form {
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
    align-items: center;
}

/* حقل الكتابة */
.chat-form textarea {
    flex: 1;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    direction: rtl;
}

/* أيقونات الإيموجي و + */
.input-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    color: #666;
}

.input-icons i {
    cursor: pointer;
    transition: color 0.2s;
}

.input-icons i:hover {
    color: #333;
}

/* زر الإرسال الدائري الكبير */
.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #6200EA;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.send-btn:hover {
    background-color: #5000D0;
    transform: scale(1.05);
}

.send-btn i {
    transform: rotate(-45deg);
}

/* ========== القائمة الجانبية للمشاركين ========== */
.chat-sidebar {
    width: 280px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sidebar-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-toggle-btn {
    display: none;
    color: white;
    font-size: 20px;
}

.participants-list {
    padding: 15px;
    max-height: calc(100vh - var(--navbar-height) - 60px);
    overflow-y: auto;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.participant-item:hover {
    background-color: var(--bg-color);
}

.participant-avatar {
    position: relative;
}

.participant-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.participant-info h4 {
    font-size: 14px;
    color: var(--text-color);
}

.participant-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.show-participants-btn {
    display: none;
}

/* ========== Modal ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-color);
}

/* ========== الإشعارات ========== */
.notifications-dropdown {
    position: fixed;
    top: var(--navbar-height);
    left: 20px;
    width: 350px;
    max-height: 500px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    animation: slideDown 0.3s ease;
}

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.notifications-header h3 {
    font-size: 18px;
}

.notifications-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.notification-item:hover {
    background-color: var(--bg-color);
}

.notification-item.unread {
    background-color: #E3F2FD;
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.notification-icon.friend_request {
    background-color: var(--primary-color);
}

.notification-icon.friend_accepted {
    background-color: var(--success-color);
}

.notification-icon.private_message {
    background-color: var(--info-color);
}

.notification-icon.message_like {
    background-color: var(--warning-color);
}

.notification-icon.system {
    background-color: var(--text-secondary);
}

.notification-content {
    flex: 1;
}

.notification-content p {
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 5px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.no-notifications {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* ========== Footer ========== */
.footer {
    background-color: var(--card-bg);
    padding: 20px;
    text-align: center;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--text-secondary);
    font-size: 14px;
}

