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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --light-bg: #ecf0f1;
    --dark-bg: #34495e;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --font-family: 'Cairo', sans-serif;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* شاشة الدخول */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.logo-section h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.logo-section p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.login-form h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.input-group {
    margin-bottom: 20px;
    text-align: right;
}

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

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    transition: border-color 0.3s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* الأزرار */
.btn-primary,
.btn-secondary,
.btn-guest {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-guest {
    background: var(--text-secondary);
    color: white;
    margin-top: 15px;
}

.btn-guest:hover {
    background: #6c757d;
}

/* واجهة الدردشة */
.chat-interface {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--light-bg);
}

/* الشريط العلوي */
.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.header-right,
.header-center,
.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
}

.online-count {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--success-color);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
}

.room-info {
    font-weight: 600;
}

.header-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    position: relative;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-btn.logout:hover {
    background: var(--accent-color);
}

.notification-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-badge:empty {
    display: none;
}

/* المحتوى الرئيسي */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 250px 1fr 250px;
    gap: 10px;
    padding: 10px;
    min-height: calc(100vh - 70px);
}

/* الأشرطة الجانبية */
.sidebar-right,
.sidebar-left {
    background: white;
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    max-height: calc(100vh - 90px);
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* قائمة المستخدمين */
.users-list {
    max-height: 200px;
    overflow-y: auto;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.3s;
}

.user-item:hover {
    background: var(--light-bg);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
}

.user-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

.user-status.offline {
    background: var(--text-secondary);
}

.user-status.away {
    background: var(--warning-color);
}

/* مشغل الراديو */
.radio-player {
    text-align: center;
}

#radioStatus {
    margin-bottom: 10px;
    padding: 5px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

#radioUrl {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
}

#playRadio,
#stopRadio {
    padding: 8px 12px;
    margin: 0 5px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.3s;
}

#playRadio {
    background: var(--success-color);
    color: white;
}

#stopRadio {
    background: var(--accent-color);
    color: white;
}

/* خيارات المظهر */
.theme-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.theme-btn {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.theme-btn:hover,
.theme-btn.active {
    background: var(--secondary-color);
    color: white;
}

/* منطقة الدردشة الرئيسية */
.chat-main {
    background: white;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    min-height: 400px;
}

/* الرسائل */
.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message.own .message-avatar {
    background: var(--success-color);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.message.own .message-header {
    justify-content: flex-end;
}

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

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.message-text {
    background: var(--light-bg);
    padding: 10px 15px;
    border-radius: 15px;
    line-height: 1.4;
}

.message.own .message-text {
    background: var(--secondary-color);
    color: white;
}

.message-media {
    margin-top: 8px;
}

.message-image {
    max-width: 200px;
    border-radius: var(--border-radius);
}

.message-audio {
    width: 100%;
    max-width: 250px;
}

/* إدخال الرسائل */
.chat-input-container {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.message-tools {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.tool-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
}

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

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-family: var(--font-family);
    font-size: 14px;
    resize: none;
}

#messageInput:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.send-btn {
    background: var(--secondary-color);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.3s;
}

.send-btn:hover {
    background: #2980b9;
}

/* إجراءات المشرفين */
.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    padding: 8px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.85rem;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#muteBtn {
    background: var(--warning-color);
    color: white;
}

#kickBtn {
    background: var(--accent-color);
    color: white;
}

#banBtn {
    background: #8e44ad;
    color: white;
}

.chat-info {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.chat-info p {
    margin-bottom: 5px;
}

/* النوافذ المنبثقة */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-content.large {
    max-width: 800px;
    height: 600px;
}

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

.modal-header h2 {
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.modal-close:hover {
    background: var(--light-bg);
}

.modal-body {
    padding: 20px;
}

/* الملف الشخصي */
.profile-photo {
    text-align: center;
    margin-bottom: 20px;
}

#profileImage {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    margin-bottom: 10px;
}

#changePhoto {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
}

.profile-info .input-group {
    margin-bottom: 15px;
}

.profile-actions {
    text-align: center;
    margin-top: 20px;
}

/* الرسائل الخاصة */
.messages-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    height: 500px;
}

.conversations-list {
    border-left: 1px solid var(--border-color);
    padding-left: 20px;
}

.conversations-list h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

#conversationsList {
    max-height: 400px;
    overflow-y: auto;
}

.conversation-item {
    padding: 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-bottom: 5px;
    transition: background 0.3s;
}

.conversation-item:hover,
.conversation-item.active {
    background: var(--light-bg);
}

.conversation-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.conversation-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    background: var(--light-bg);
}

.conversation-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    max-height: 350px;
}

.conversation-input {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

#privateMessageInput {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
}

#sendPrivateMessage {
    background: var(--secondary-color);
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 15px;
    color: white;
    cursor: pointer;
}

/* الأصدقاء */
.friends-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.friends-list {
    max-height: 300px;
    overflow-y: auto;
}

.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: var(--border-radius);
    margin-bottom: 5px;
    background: var(--light-bg);
}

.friend-actions {
    display: flex;
    gap: 5px;
}

.friend-btn {
    padding: 5px 10px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s;
}

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

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

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

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

/* الإعدادات */
.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 5px 0;
}

.setting-item label {
    font-weight: 500;
}

.setting-item input[type="color"],
.setting-item select {
    padding: 5px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.setting-item input[type="checkbox"] {
    margin-left: 10px;
}

.settings-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* المظاهر */
body.dark-theme {
    --light-bg: #2c3e50;
    --primary-color: #ecf0f1;
    --text-primary: #ecf0f1;
    --border-color: #34495e;
}

body.blue-theme {
    --primary-color: #2980b9;
    --secondary-color: #3498db;
    --light-bg: #ebf3fd;
}

body.green-theme {
    --primary-color: #27ae60;
    --secondary-color: #2ecc71;
    --light-bg: #eafaf1;
}

/* الاستجابة للشاشات الصغيرة */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .sidebar-right,
    .sidebar-left {
        display: none;
    }
    
    .chat-header {
        padding: 10px 15px;
    }
    
    .header-right,
    .header-center,
    .header-left {
        gap: 10px;
    }
    
    .logo span {
        display: none;
    }
    
    .online-count {
        font-size: 0.8rem;
        padding: 3px 8px;
    }
    
    .modal-content {
        margin: 10px;
        max-width: none;
        width: auto;
    }
    
    .modal-content.large {
        height: 80vh;
    }
    
    .messages-container {
        grid-template-columns: 1fr;
        grid-template-rows: 150px 1fr;
    }
    
    .conversations-list {
        border-left: none;
        border-bottom: 1px solid var(--border-color);
        padding-left: 0;
        padding-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 20px;
        margin: 10px;
    }
    
    .chat-messages {
        max-height: calc(100vh - 160px);
        min-height: 200px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .message-tools {
        justify-content: center;
        flex-wrap: wrap;
    }
}