/* =====================================================
   منصة الخاطبة - التنسيقات الرئيسية
   ===================================================== */

:root {
    --primary: #8B5CF6;
    --secondary: #EC4899;
    --wine: #722F37;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: #ffffff;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --border-color: #E5E7EB;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    padding-bottom: 70px;
}

.container {
    max-width: 550px;
    margin: 0 auto;
    padding: 16px;
}

/* ==================== شريط الإعلانات ==================== */
.marquee {
    background: var(--wine);
    color: white;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.marquee span {
    display: inline-block;
    animation: marqueeScroll 20s linear infinite;
}
@keyframes marqueeScroll {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* ==================== الشريط السفلي ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 10px 16px 16px;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 100;
}
.bottom-nav.show {
    display: flex;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 11px;
    position: relative;
}
.nav-item i {
    font-size: 22px;
}
.nav-item.active {
    color: var(--primary);
    transform: translateY(-2px);
}
.nav-item.active i {
    transform: scale(1.05);
}

/* عداد الإشعارات بجانب الأيقونة */
.nav-icon-wrapper {
    position: relative;
}
.nav-badge {
    position: absolute;
    top: -8px;
    right: -12px;
    background: #EF4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ==================== الصفحات ==================== */
.page {
    display: none;
    padding-bottom: 80px;
    animation: fadeIn 0.3s ease;
}
.page.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== البطاقات ==================== */
.card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

/* ==================== الأزرار ==================== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    width: 100%;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.4);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-secondary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

/* ==================== الحقول ==================== */
input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 50px;
    font-size: 14px;
    font-family: 'Tajawal', sans-serif;
    transition: all 0.2s;
    margin-bottom: 12px;
    background: var(--card-bg);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ==================== بطاقات الأعضاء ==================== */
.member-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f9fafb;
    border-radius: 20px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.2s;
}
.member-card:hover {
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.member-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    font-weight: bold;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.member-avatar.default {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.member-info {
    flex: 1;
}
.member-name {
    font-weight: bold;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.online-dot.green {
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
}
.member-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== الفلاتر ==================== */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f3f4f6;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 4px 8px 0;
    font-size: 14px;
}
.filter-chip.active {
    background: var(--primary);
    color: white;
}
.filter-chip i {
    font-size: 12px;
}

/* ==================== الرسائل ==================== */
.message-bubble {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 20px;
    margin: 8px 0;
}
.message-sent {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 20px 20px 4px 20px;
    margin-left: auto;
}
.message-received {
    background: #f3f4f6;
    color: var(--text-primary);
    border-radius: 20px 20px 20px 4px;
    margin-right: auto;
}

/* ==================== قائمة المحادثات ==================== */
.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}
.conversation-item:hover {
    background: #f9fafb;
}
.conversation-item.unread {
    background: #FEE2E2;
}
.conversation-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}
.conversation-avatar.default {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}
.conversation-info {
    flex: 1;
    min-width: 0;
}
.conversation-name {
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.conversation-last-message {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unread-count {
    background: #EF4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ==================== النوافذ المنبثقة ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal.active {
    display: flex;
}
.modal-content {
    background: var(--card-bg);
    border-radius: 32px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 20px;
    font-weight: bold;
}
.modal-header .close {
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ==================== الزر العائم - تواصل مع الخاطبة ==================== */
.floating-btn {
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 99;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}
.floating-btn i {
    font-size: 28px;
    color: white;
}
.floating-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.floating-btn.hide {
    transform: translateY(80px);
    opacity: 0;
    pointer-events: none;
}
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(139, 92, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    }
}

/* ==================== التنبيهات ==================== */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 50px;
    color: white;
    z-index: 200;
    animation: toastSlideUp 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    white-space: nowrap;
}
@keyframes toastSlideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==================== الأرقام ==================== */
.stat-number {
    font-size: 28px;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

/* ==================== لوحة الأدمن ==================== */
.admin-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
}
.admin-table {
    width: 100%;
    overflow-x: auto;
}
.admin-table table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}
.admin-table th {
    background: #f9fafb;
    font-weight: bold;
}

/* ==================== رفع الصورة ==================== */
.profile-image-container {
    position: relative;
    display: inline-block;
}
.profile-image-upload {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid white;
}
.profile-image-upload i {
    font-size: 14px;
    color: white;
}
.upload-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-overlay.hidden {
    display: none;
}
.upload-spinner {
    background: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================== التجاوب مع الجوال ==================== */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    .member-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    .stat-number {
        font-size: 22px;
    }
    .toast {
        white-space: normal;
        text-align: center;
        font-size: 13px;
    }
    .floating-btn {
        width: 48px;
        height: 48px;
        bottom: 75px;
        right: 15px;
    }
    .floating-btn i {
        font-size: 24px;
    }
}