/* ==========================================================================
   1. الإعدادات الأساسية
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.gfjm-meeting-room {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0f172a; /* خلفية داكنة حديثة ومريحة */
    color: #ffffff;
    height: 100vh;
    height: 100dvh;
    overflow: hidden; /* لمنع التمرير (Scroll) وجعل التطبيق بملء الشاشة */
    display: flex;
    flex-direction: column;
    direction: rtl;
}

/* ==========================================================================
   2. شاشة كلمة المرور (Overlay)
   ========================================================================== */
.overlay-screen {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 400px;
    width: 90%;
}

.overlay-content h2 { 
    margin-bottom: 10px; 
    font-size: 24px;
}
.overlay-content p { 
    margin-bottom: 20px; 
    color: #94a3b8; 
    font-size: 14px;
}
.overlay-content input {
    width: 100%;
    padding: 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #0f172a;
    color: #fff;
    margin-bottom: 20px;
    text-align: center;
}
.overlay-content .btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    transition: background 0.3s;
}
.overlay-content .btn-primary:hover { 
    background: #1d4ed8; 
}

/* ==========================================================================
   3. تخطيط الغرفة الرئيسي (Workspace)
   ========================================================================== */
#meeting-workspace {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
}

/* --- الشريط العلوي --- */
.meeting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #1e293b;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    height: 60px;
}

.meeting-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: inline-block;
}

.status-badge {
    background: #dc2626;
    color: white;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-right: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.participants-count {
    font-size: 14px;
    color: #94a3b8;
    background: #334155;
    padding: 5px 12px;
    border-radius: 20px;
}

/* ==========================================================================
   4. شبكة الفيديو (القسم الأهم)
   ========================================================================== */
.meeting-main {
    flex-grow: 1; /* يأخذ كل المساحة المتبقية بين الهيدر والفوتر */
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #0b0f19;
}

#video-grid {
    display: grid;
    gap: 15px;
    width: 100%;
    height: 100%;
    /* التوزيع التلقائي للمربعات */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-content: center;
    justify-content: center;
}

/* حاوية كل فيديو */
.video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    aspect-ratio: 16 / 9; 
    max-height: 100%;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* لملء الحاوية بالكامل دون تشويه */
    transform: scaleX(-1); /* تأثير المرآة لتظهر الحركة بشكل طبيعي للمستخدم */
}

/* منع الانعكاس عن الشاشات المشاركة (Screen Share) */
.video-container video.is-screen-share {
    transform: scaleX(1);
    object-fit: contain; 
}

.user-label {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: white;
}

/* ==========================================================================
   5. شريط أدوات التحكم السفلي
   ========================================================================== */
.meeting-footer {
    height: 80px;
    background: #1e293b;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
}

.controls-bar {
    display: flex;
    gap: 15px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #334155;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    transition: all 0.2s;
}

.control-btn:hover { 
    background: #475569; 
    transform: scale(1.05); 
}

/* حالة الزر المعطل (Muted / Camera Off) */
.control-btn.disabled { 
    background: #dc2626; 
}
.control-btn.disabled:hover { 
    background: #b91c1c; 
}

/* زر المغادرة */
.leave-btn {
    width: auto;
    border-radius: 25px;
    padding: 0 20px;
    background: #dc2626;
    font-size: 14px;
    font-weight: bold;
}
.leave-btn:hover { 
    background: #b91c1c; 
}
.leave-btn .icon { 
    margin-left: 8px; 
    font-size: 14px; 
}

/* ==========================================================================
   6. التجاوب مع شاشات الهواتف (Responsive)
   ========================================================================== */
@media (max-width: 768px) {
    #video-grid {
        grid-template-columns: 1fr; /* عرض فيديو واحد بملء العرض للموبايل لتوفير المساحة */
        padding: 10px;
        gap: 10px;
    }
    
    .meeting-header {
        padding: 10px;
        height: 50px;
    }
    
    .meeting-header h1 { 
        font-size: 15px; 
    }
    
    .meeting-footer {
        height: 70px;
        padding: 0 10px;
    }
    
    .control-btn { 
        width: 42px; 
        height: 42px; 
        font-size: 16px; 
    }
    
    .controls-bar { 
        gap: 10px; 
    }
}