/* ==========================================================
   ✨ نظام التصميم الجمالي الموحد لشبكة الحياة (Premium UI v3.5)
   ========================================================== */

/* 1. إعدادات المتغيرات العامة للألوان والخطوط */
:root {
    --primary-color: #1877f2;
    --primary-hover: #166fe5;
    --primary-light: #e7f3ff;
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #1c1e21;
    --text-muted: #65676b;
    --border-color: #e4e6eb;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. التصفير والتأسيس العام */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, Tahoma, Arial, sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* دمج نظام صفحة الهبوط (الخلفية الجانبية المخصصة للموقع) */
    background-image: url('uploads/landing-side-bg.jpg'); /* ضع مسار صورتك المفضلة هنا */
    background-attachment: fixed; /* الخلفية ثابتة مريحة للعين أثناء التمرير */
    background-position: center top;
    background-repeat: no-repeat;
    background-size: cover;
    background-color: var(--bg-main); /* لون احتياطي مستقر لحين تحميل الصورة */
}

/* 3. شريط التنقل العلوي المتطور (Navbar) */
.navbar {
    background: rgba(24, 119, 242, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo {
    color: #ffffff;
    font-size: 26px;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.5px;
    transition: var(--transition);
}

.logo:hover {
    transform: scale(1.03);
    opacity: 0.95;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    margin-right: 18px;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

/* 4. توزيع وهيكل الصفحات (Layout Grid) */
.main-wrapper {
    max-width: 1050px; /* تم زيادة العرض قليلاً ليناسب مظهر التغذية الذكية المطور والبار الجانبي */
    margin: 30px auto; /* تركيز في المنتصف مع مسافة لبروز خلفية صفحة الهبوط جانباً */
    display: flex;
    gap: 25px;
    padding: 0 20px;
    position: relative;
    z-index: 2; /* لرفع المحتوى فوق الروابط الخلفية للإعلانات إن وُجدت */
}

.sidebar-left {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 90px;
    height: fit-content;
}

.main-content {
    flex: 1;
    max-width: 680px;
    margin: 0;
}

.container {
    max-width: 620px;
    margin: 25px auto;
    padding: 0 15px;
}

/* 5. الكروت والبطاقات العامة (Cards) */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md); /* تعميق الظل لبروز المنشورات فوق خلفية صفحة الهبوط */
    border: 1px solid rgba(0, 0, 0, 0.03);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

/* 6. القائمة الجانبية الاحترافية المحدثة (Sidebar) */
.sidebar-card.card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 18px 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.sidebar-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 15px;
    padding: 0 14px 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 700;
}

.sidebar-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 14.5px;
    border-radius: 10px;
    transition: var(--transition);
    border-right: 4px solid transparent;
}

.sidebar-link-item:hover {
    background-color: var(--primary-light);
    color: var(--primary-color) !important;
    padding-right: 20px;
    border-right-color: var(--primary-color);
}

.sidebar-link-item[style*="background"] {
    background-color: var(--primary-light) !important;
    color: var(--primary-color) !important;
    font-weight: 700;
    border-right-color: var(--primary-color);
}

/* 7. نموذج تسجيل الدخول والترحيب (Auth) */
.auth-container {
    max-width: 420px;
    margin: 70px auto;
    background: var(--bg-card);
    padding: 45px 35px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 2;
}

.auth-container h1 {
    margin-bottom: 25px;
    color: var(--primary-color);
    font-weight: 800;
    font-size: 28px;
}

.auth-container form input {
    width: 100%;
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background-color: #f8f9fa;
    transition: var(--transition);
}

.auth-container form input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.15);
}

/* 8. الأزرار الاحترافية الموحدة (Buttons) */
.auth-container form button,
.post-actions button,
.comment-form button,
.search-form button,
.edit-profile button,
.contacts-actions button,
.copy-link button,
.invite-form button {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-container form button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 10px;
}

.auth-container form button:hover,
.post-actions button:hover,
.comment-form button:hover,
.search-form button:hover,
.edit-profile button:hover,
.contacts-actions button:hover,
.copy-link button:hover,
.invite-form button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.auth-container p { margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-container a { color: var(--primary-color); text-decoration: none; font-weight: 600; }
.auth-container a:hover { text-decoration: underline; }

.error {
    background: #ffebe9;
    color: #ff3b30;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
    border-right: 4px solid #ff3b30;
}

/* 9. حقول النصوص وصندوق النشر (Create Post & Textareas) */
.create-post.card {
    padding: 20px;
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.create-post textarea,
.comment-form textarea,
.edit-profile textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #f8f9fa;
    resize: none;
    min-height: 70px;
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
}

.create-post textarea:focus,
.comment-form textarea:focus,
.edit-profile textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.post-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
}

.btn-gallery-upload {
    background: #f0f2f5 !important;
    color: #4b4b4b !important;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-gallery-upload:hover {
    background: #e4e6eb !important;
}

.btn-submit-post {
    background: var(--primary-color) !important;
    color: white !important;
    border: none;
    padding: 8px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-submit-post:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-1px);
}

/* 10. المنشورات وعناصرها والتحكم بالصور العارمة */
.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.upload-btn {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
}
.upload-btn:hover { color: var(--primary-hover); }

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.post-header a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color); }
.avatar-small { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.username { color: var(--text-muted); font-size: 13px; }
.time { color: var(--text-muted); font-size: 12px; margin-right: auto; }

.post-content p { font-size: 15px; color: var(--text-main); margin-bottom: 12px; white-space: pre-wrap; }

.post-content img.post-image {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-top: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: zoom-in;
    transition: var(--transition);
}

.post-content img.post-image:hover {
    filter: brightness(0.95);
    transform: scale(1.005);
}

.post-footer {
    display: flex;
    gap: 24px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    margin-top: 14px;
}

.btn-like, .btn-comment { 
    text-decoration: none; 
    color: var(--text-muted); 
    font-size: 14px; 
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.btn-like:hover { color: #e74c3c; }
.btn-comment:hover { color: var(--primary-color); }
.btn-like.liked { color: #e74c3c; }

/* 11. الملف الشخصي ومفاتيح الأفعال (Profile UI) */
.profile-header { text-align: center; padding: 20px 0; }
.profile-avatar { width: 125px; height: 125px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: var(--shadow-md); margin-bottom: 15px; }
.profile-stats { display: flex; justify-content: center; gap: 35px; margin: 20px 0; }
.profile-stats span { font-size: 14px; color: var(--text-muted); }
.profile-stats strong { color: var(--text-main); font-size: 16px; }

.profile-actions { display: flex; gap: 12px; justify-content: center; margin-top: 15px; flex-wrap: wrap; align-items: center; }

.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: var(--transition);
}
.btn-follow { background: var(--primary-color); color: white; }
.btn-follow:hover { background: var(--primary-hover); }
.btn-unfollow { background: #e4e6eb; color: #050505; }
.btn-unfollow:hover { background: #d8dadf; }

.btn-message {
    background-color: #0084ff;
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.btn-message:hover { background-color: #006dd2; transform: translateY(-1px); }

.btn-friend {
    background-color: #007bff;
    color: white;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 13px;
    transition: var(--transition);
}
.btn-friend.pending { background-color: #6c757d; }
.btn-friend.accept { background-color: #28a745; }
.btn-friend.friends { background-color: #e4e6eb; color: #050505; border: 1px solid var(--border-color); }

/* 12. معرض الألبومات والصور (Gallery) */
.gallery-card { background: var(--bg-card); padding: 22px; border-radius: var(--radius-md); margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 18px; }
.gallery-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius-sm); cursor: zoom-in; transition: var(--transition); border: 1px solid rgba(0,0,0,0.05); }
.gallery-grid img:hover { transform: translateY(-2px) scale(1.03); box-shadow: var(--shadow-md); }

.btn-gallery-upload {
    background: #28a745;
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    display: inline-block;
    margin-top: 5px;
    transition: var(--transition);
}
.btn-gallery-upload:hover { background: #218838; }

/* 13. التعليقات (Comments) */
.comments-section h3 { margin-bottom: 15px; font-size: 16px; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.comment a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; margin-bottom: 5px; font-weight: 600; }
.comment p { padding-right: 40px; font-size: 14.5px; color: var(--text-main); }

/* 14. المحادثات والرسائل (Inbox & Chat) */
.conversation-link { text-decoration: none; color: inherit; }
.conversation-item { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius-sm); transition: var(--transition); border-bottom: 1px solid #f8f9fa; }
.conversation-item:hover { background: #f8f9fa; }
.conversation-item.unread { background: var(--primary-light); }
.conversation-info { flex: 1; }
.conversation-info strong { display: block; font-size: 15px; color: var(--text-main); margin-bottom: 2px; }
.last-message { color: var(--text-muted); font-size: 13px; }
.conversation-meta { text-align: left; }

.badge {
    background: #ff3b30;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

/* 15. نظام البحث والدعوات (Search & Invitations) */
.search-form { display: flex; gap: 10px; }
.search-form input { flex: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background-color: #f8f9fa; font-size: 14px; }
.search-result { padding: 14px 10px; border-bottom: 1px solid var(--border-color); }
.search-result a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }

.invite-form { display: flex; gap: 10px; }
.invite-form input { flex: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 14px; }
.hint { color: var(--text-muted); font-size: 13px; margin: 8px 0; }

.contacts-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin: 15px 0; background: #f8f9fa; }
.contact-item { padding: 12px; border-bottom: 1px solid #eee; }
.contact-item label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.contact-item span { color: var(--text-muted); font-size: 13px; }
.contacts-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; }

.copy-link { display: flex; gap: 10px; margin-top: 15px; }
.copy-link input { flex: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 13px; background: #f1f3f4; direction: ltr; }

/* 16. نافذة التكبير السينمائية المنبثقة (Lightbox Overlay) */
.image-viewer-overlay { display: none; position: fixed; z-index: 10000; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.92); backdrop-filter: blur(8px); justify-content: center; align-items: center; }
.image-viewer-overlay img { max-width: 92%; max-height: 88%; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); animation: zoomIn 0.2s ease-out; }
.image-viewer-close { position: absolute; top: 25px; right: 35px; color: rgba(255, 255, 255, 0.7); font-size: 42px; font-weight: 300; cursor: pointer; user-select: none; transition: var(--transition); }
.image-viewer-close:hover { color: #fff; transform: rotate(90deg); }

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 17. التوافق والاستجابة مع المحمول (Responsive) */
@media (max-width: 1150px) {
    body {
        /* إخفاء خلفية صفحة الهبوط في شاشات التابلت والمحمول لأن الفراغات الجانبية تنعدم */
        background-image: none !important;
        background-color: var(--bg-main);
    }
    .main-wrapper { 
        margin: 15px auto; 
    }
}

@media (max-width: 768px) {
    .main-wrapper { flex-direction: column; gap: 0; padding: 0 10px; margin: 15px auto; }
    .sidebar-left { display: none !important; }
    .nav-container { padding: 0 15px; }
    .nav-links a { margin-right: 10px; font-size: 13px; padding: 4px 6px; }
    .profile-stats { gap: 20px; }
    .auth-container { margin: 30px auto; padding: 30px 20px; }
}