/* ==========================================
   إعدادات وحسابات عامة
   ========================================== */
:root {
    --primary-color: #1e90ff;
    --primary-dark: #0066cc;
    --bg-main: #f4f7fa;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', Tahoma, sans-serif;
}

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-main) !important;
    color: var(--text-primary) !important;
    overflow-x: hidden;
}

body {
    padding: 20px 10px 50px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* إصلاح شامل للصور عامة */
img {
    max-width: 100%;
    display: block;
}

/* ==========================================
   حاوية البروفايل المتوسطة (Clean Centered Layout)
   ========================================== */
.single-profile-container {
    width: 100%;
    max-width: 680px; /* عرض ممتاز جداً ومريح للعين على الكمبيوتر والجوال */
    margin: 0 auto;
}

.profile-wrapper {
    background: var(--card-bg) !important;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.profile-cover {
    height: 160px;
    background: linear-gradient(135deg, #1e90ff 0%, #0047ab 100%);
}

.avatar-container {
    position: relative;
    padding: 0 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: -55px;
    margin-bottom: 15px;
}

.profile-avatar {
    width: 115px;
    height: 115px;
    border-radius: 50%;
    border: 4px solid #ffffff;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.profile-avatar:hover {
    transform: scale(1.03);
}

.cover-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.user-info-section {
    padding: 0 25px 25px;
}

.user-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.join-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* الشبكة الإحصائية */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    margin: 20px 0 10px;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none;
}

.clickable-stat {
    background: #ffffff;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.clickable-stat:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.stat-item .val {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-color);
}

.stat-item .lbl {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* زر الإعلانات الرئيسي */
.user-ads-btn-box {
    margin-bottom: 15px;
}

.btn-ads-main {
    width: 100%;
    background: #f0f7ff;
    color: var(--primary-color);
    border: 1.5px dashed var(--primary-color);
    font-size: 0.95rem;
    padding: 12px;
    border-radius: 12px;
}

.btn-ads-main:hover {
    background: var(--primary-color);
    color: #fff;
}

.management-panel {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.nav-back-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.unread-badge {
    background: #fff;
    color: var(--primary-color);
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* ==========================================
   الأزرار العامة (Buttons)
   ========================================== */
.btn,
a.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1eb956; }
.btn-outline { background: transparent; border: 1.5px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ==========================================
   النافذة المنبثقة للصورة (Modal)
   ========================================== */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
}

.close-modal-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
}

/* ==========================================
   تنسيقات صفحة تسجيل الدخول والنماذج (Login & Forms)
   ========================================== */

/* الحاوية المتوسطة للنموذج */
.container {
    width: 100%;
    max-width: 420px;
    background: #ffffff !important;
    padding: 30px 25px;
    margin: 50px auto;
    border-radius: var(--radius, 16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color, #e2e8f0);
    text-align: center;
}

/* العناوين */
.container h2,
.container h3 {
    margin-bottom: 25px;
    color: var(--text-primary, #0f172a);
    font-size: 1.6rem;
    font-weight: 800;
}

/* حقول المدخلات والعناصر المشتركة */
input, textarea, select,
.container input[type="text"],
.container input[type="password"],
.container input[type="email"] {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 15px;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--text-primary, #0f172a);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

input:focus, textarea:focus, select:focus,
.container input:focus {
    background: #ffffff;
    border-color: var(--primary-color, #1e90ff);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.15);
}

/* زر Submit للنماذج */
button,
.container button[type="submit"] {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    background: var(--primary-color, #1e90ff);
    color: #ffffff;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

button:hover,
.container button[type="submit"]:hover {
    background: var(--primary-dark, #0066cc);
    transform: translateY(-1px);
}

/* صناديق الرسائل والرسائل الدعائية والخطأ */
.dua,
.error {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.dua {
    background: #f0f7ff;
    color: var(--primary-dark);
    border: 1px solid #cce5ff;
}

.error {
    background: #fef2f2;
    color: #ef4444 !important;
    border: 1px solid #fee2e2;
    font-weight: 600;
}

/* الصور الشخصية العامة والإعلانات */
.profile-pic {
    width: 120px;
    height: 120px;
    background: #f8fafc;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 45px;
    color: var(--primary-color);
    border: 2px solid var(--border-color);
}

.ad-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    background: #e2e8f0;
}

/* صندوق التقييم بالنجوم */
.profile-rating-box {
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    text-align: center;
}

.stars-display {
    font-size: 32px;
    margin: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.star {
    font-size: 32px;
    color: #cbd5e1;
    margin: 0 3px;
    display: inline-block;
}

.star.filled {
    color: #ffd700;
}

.rating-count {
    font-size: 16px;
    color: var(--text-muted);
}

/* الروابط أسفل النموذج */
.footer-text {
    font-size: 0.9rem;
    color: var(--text-muted, #64748b);
    margin-top: 12px;
}

.footer-text a {
    color: var(--primary-color, #1e90ff);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}

.footer-text a:hover {
    color: var(--primary-dark, #0066cc);
    text-decoration: underline;
}

/* ==========================================
   التجاوب للشاشات الصغيرة للبروفايل والنماذج
   ========================================== */
@media (max-width: 600px) {
    body {
        padding: 10px 5px 30px;
    }

    .avatar-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .cover-actions {
        margin-top: 15px;
        justify-content: center;
        width: 100%;
    }

    .user-info-section {
        text-align: center;
    }

    .user-name {
        justify-content: center;
    }

    .management-panel, .nav-back-actions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 20px auto;
        padding: 25px 18px;
    }

    input, button, a.action-btn {
        font-size: 15px;
        padding: 12px;
    }

    .dua {
        font-size: 14px;
        padding: 14px;
    }
}

/* ==========================================
   تنسيقات صفحة صندوق الرسائل (Inbox.php)
   (تمت إضافتها حديثاً لترتيب شكل الرسائل)
   ========================================== */

/* الحاوية الرئيسية */
.inbox-container {
    width: 100%;
    max-width: 680px; 
    margin: 0 auto;
}

.inbox-wrapper {
    background: var(--card-bg) !important;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* ترويسة الصندوق */
.inbox-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfcfc;
}

.inbox-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.inbox-header .unread-count {
    background: #ef4444;
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* قائمة الرسائل */
.inbox-list {
    display: flex;
    flex-direction: column;
}

/* عنصر الرسالة الواحدة */
.msg-item {
    display: flex;
    align-items: center;
    padding: 18px 25px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    background: var(--card-bg);
    transition: background 0.2s ease, padding-right 0.2s ease;
}

.msg-item:last-child {
    border-bottom: none;
}

.msg-item:hover {
    background: #f8fafc;
}

/* الرسائل غير المقروءة (تمييز لوني وخط عريض) */
.msg-item.unread {
    background: #f0f7ff;
    border-right: 4px solid var(--primary-color);
}

.msg-item.unread:hover {
    background: #e6f2ff;
}

/* صورة المرسل */
.msg-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.msg-item.unread .msg-avatar {
    border-color: var(--primary-color);
}

/* محتوى الرسالة */
.msg-content {
    flex-grow: 1;
    margin-right: 15px; 
    overflow: hidden;
}

.msg-header-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.msg-sender {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.msg-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* مقتطف نص الرسالة */
.msg-snippet {
    font-size: 0.95rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
    display: block;
}

/* تغيير لون النص للرسائل غير المقروءة لتبدو بارزة أكثر */
.msg-item.unread .msg-sender {
    color: var(--primary-dark);
}

.msg-item.unread .msg-snippet {
    color: var(--text-primary);
    font-weight: 700;
}

/* ==========================================
   التجاوب مع شاشات الجوال (خاص بصندوق الرسائل)
   ========================================== */
@media (max-width: 600px) {
    .inbox-header {
        padding: 15px 20px;
    }
    
    .inbox-header h2 {
        font-size: 1.2rem;
    }

    .msg-item {
        padding: 15px 20px;
    }

    .msg-avatar {
        width: 45px;
        height: 45px;
    }

    .msg-content {
        margin-right: 12px;
    }

    .msg-sender {
        font-size: 0.95rem;
    }

    .msg-snippet {
        font-size: 0.85rem;
    }
}