/* ==========================================================================
   Score Tank - Final Botolat Standings (Aligned Live Scores & Responsive)
   ========================================================================== */

/* --- 1. التنسيق العام (الوضع الفاتح الافتراضي) --- */
.standings-group-wrapper {
    direction: rtl !important;
    background-color: #ffffff !important;
    border: 1px solid #f0f0f0 !important;
    border-radius: 4px !important;
    margin-bottom: 25px !important;
    overflow: hidden !important;
}

.group-title {
    background-color: #fcfcfc !important;
    padding: 12px 15px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #333333 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    border-right: 4px solid #0073aa !important;
    margin: 0 !important;
}

.standings-table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: fixed !important; /* إجبار المتصفح على احترام العرض */
    background-color: #ffffff !important;
}

/* تنسيق رؤوس الأعمدة (أسماء الأعمدة) */
.standings-table thead th {
    background-color: #ffffff !important;
    color: #999999 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 15px 5px !important;
    text-align: center !important;
    border-bottom: 2px solid #f7f7f7 !important;
}

.standings-table tbody tr {
    border-bottom: 1px solid #f7f7f7 !important;
    transition: background-color 0.2s ease;
}

.standings-table td {
    padding: 10px 4px !important;
    font-size: 13px !important;
    color: #444444 !important;
    text-align: center !important;
    background-color: transparent !important;
    vertical-align: middle !important;
}

/* --- تنسيق خلية الفريق (الجزء المهم للمحاذاة) --- */
.standings-table td.team-name-cell {
    display: flex !important;       /* تفعيل المرونة */
    align-items: center !important; /* محاذاة عمودية */
    text-align: right !important;
    gap: 8px;                       /* مسافة بين الشعار والاسم */
    position: relative !important;
}

/* الشعار */
.standings-table td.team-name-cell img {
    width: 24px !important;
    height: 24px !important;
    object-fit: contain;
    flex-shrink: 0; /* منع انكماش الشعار */
}

/* اسم الفريق */
.standings-table td.team-name-cell .t-name {
    white-space: nowrap !important; 
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    max-width: 120px; /* حد أقصى لعرض الاسم لمنع تداخل النتيجة */
}

/* عمود النقاط */
.standings-table td:last-child {
    font-weight: 800 !important;
    color: #000000 !important;
    background-color: #fafafa !important;
}

/* --- 2. تنسيقات النتيجة المباشرة (Live Score) --- */

/* حاوية النتيجة - التعديل هنا للمحاذاة */
.live-score-container {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    
    /* ★★★ السحر للمحاذاة: دفع النتيجة لأقصى اليسار ★★★ */
    margin-right: auto !important; 
    padding-left: 2px;
    
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    font-size: 10px;
    direction: ltr; /* الأرقام إنجليزي */
}

/* المربع الملون للنتيجة (تصغير الحجم) */
.live-score-badge {
    display: inline-block;
    padding: 1px 0; /* تقليل الحشو */
    border-radius: 3px;
    color: #fff;
    min-width: 18px; /* عرض ثابت لضمان المحاذاة */
    text-align: center;
    line-height: 1.4;
    font-size: 10px; /* خط أصغر */
}



/* ألوان النتائج */
.live-score-badge.win { background-color: #27ae60 !important; } /* أخضر */
.live-score-badge.loss { background-color: #e74c3c !important; } /* أحمر */
.live-score-badge.draw { background-color: #95a5a6 !important; } /* رمادي */

/* الفاصل بين النتيجتين */
.score-separator {
    color: #555;
    font-weight: normal;
    padding: 0 1px;
    font-size: 10px;
}

/* تأثير الوميض للصف الجاري */
@keyframes blinkRow {
    0% { background-color: rgba(231, 76, 60, 0.05); }
    50% { background-color: rgba(231, 76, 60, 0.15); }
    100% { background-color: rgba(231, 76, 60, 0.05); }
}

tr.live-match-row {
    animation: blinkRow 2s infinite;
}

/* خط جانبي لتمييز الصف الجاري */
tr.live-match-row td:first-child {
    border-right: 3px solid #e74c3c !important;
}

/* --- 3. التحكم الصارم في عرض الأعمدة (الكمبيوتر Desktop) --- */
@media (min-width: 769px) {
    .standings-table th:nth-child(1), .standings-table td:nth-child(1) { width: 40px !important; } /* # */
    /* زيادة عرض عمود الفريق لاستيعاب الاسم والنتيجة براحة */
    .standings-table th:nth-child(2), .standings-table td:nth-child(2) { width: auto !important; min-width: 200px !important; } 
    
    .standings-table th:nth-child(3), .standings-table td:nth-child(3) { width: 40px !important; } /* P */
    .standings-table th:nth-child(4), .standings-table td:nth-child(4) { width: 35px !important; } /* W */
    .standings-table th:nth-child(5), .standings-table td:nth-child(5) { width: 35px !important; } /* D */
    .standings-table th:nth-child(6), .standings-table td:nth-child(6) { width: 35px !important; } /* L */
    .standings-table th:nth-child(7), .standings-table td:nth-child(7) { width: 35px !important; } /* GF */
    .standings-table th:nth-child(8), .standings-table td:nth-child(8) { width: 35px !important; } /* GA */
    .standings-table th:nth-child(9), .standings-table td:nth-child(9) { width: 40px !important; } /* GD */
    .standings-table th:last-child, .standings-table td:last-child { width: 50px !important; } /* Pts */
    
    /* تحسين عرض الاسم في الديسك توب */
    .standings-table td.team-name-cell .t-name {
        max-width: 140px; 
    }
}

/* --- 4. الوضع الليلي (Dark Mode) --- */
@media (prefers-color-scheme: dark) {
    .standings-group-wrapper { background-color: #1a1a1a !important; border-color: #333 !important; }
    .group-title { background-color: #222 !important; color: #eee !important; border-bottom-color: #333 !important; }
    .standings-table { background-color: #1a1a1a !important; }
    .standings-table thead th { background-color: #222 !important; color: #888 !important; border-bottom-color: #2d2d2d !important; }
    .standings-table tbody tr { border-bottom-color: #2d2d2d !important; }
    .standings-table td { color: #ddd !important; }
    .standings-table td.team-name-cell { color: #fff !important; }
    .standings-table td:last-child { background-color: #222 !important; color: #fff !important; }
    .score-separator { color: #aaa; }
    
    @keyframes blinkRow {
        0% { background-color: rgba(231, 76, 60, 0.1); }
        50% { background-color: rgba(231, 76, 60, 0.25); }
        100% { background-color: rgba(231, 76, 60, 0.1); }
    }
}

/* دعم كلاس .dark-mode */
body.dark-mode .standings-group-wrapper { background-color: #1a1a1a !important; border-color: #333 !important; }
body.dark-mode .group-title { background-color: #222 !important; color: #eee !important; }
body.dark-mode .standings-table { background-color: #1a1a1a !important; }
body.dark-mode .standings-table td { color: #ddd !important; }
body.dark-mode tr.live-match-row { animation: blinkRow 2s infinite; }

/* --- 5. وضع الهاتف (Mobile) --- */
@media (max-width: 768px) {
    .standings-table th, 
    .standings-table td {
        font-size: 9px !important;
        padding: 8px 2px !important; 
        white-space: nowrap !important;
        letter-spacing: -0.2px; 
    }

    /* تصغير الشعار في الموبايل */
    .standings-table td.team-name-cell img {
        width: 16px !important; 
        height: 16px !important;
        margin-left: 2px !important;
    }
    
    /* تقليص عرض اسم الفريق في الموبايل لترك مساحة للنتيجة */
    .standings-table td.team-name-cell .t-name {
        max-width: 65px; 
        font-size: 9px;
    }

    /* إخفاء الأعمدة الثانوية لتوفير المساحة */
    .standings-table th:nth-child(7), .standings-table td:nth-child(7), /* له */
    .standings-table th:nth-child(8), .standings-table td:nth-child(8), /* عليه */
    .standings-table th:nth-child(9), .standings-table td:nth-child(9)  /* الفرق */
    { display: none !important; }

    /* ضبط عروض الأعمدة للموبايل */
    .standings-table th:nth-child(1), .standings-table td:nth-child(1) { width: 20px !important; } /* # */
    /* زيادة عرض عمود الفريق ليأخذ المساحة المتبقية */
    .standings-table th:nth-child(2), .standings-table td:nth-child(2) { width: auto !important; } 
    .standings-table th:nth-child(3), .standings-table td:nth-child(3) { width: 22px !important; }
    .standings-table th:nth-child(4), .standings-table td:nth-child(4) { width: 22px !important; }
    .standings-table th:nth-child(5), .standings-table td:nth-child(5) { width: 22px !important; }
    .standings-table th:nth-child(6), .standings-table td:nth-child(6) { width: 22px !important; }
    .standings-table th:last-child, .standings-table td:last-child { width: 30px !important; }

    /* تصغير النتيجة في الموبايل */
    .live-score-badge {
        min-width: 14px;
        font-size: 8px;
        padding: 0 2px;
    }
    .score-separator { font-size: 8px; }
}