/* ==========================================================================
   Public CSS for Score Tank Leagues Add-on - Single League Standings Tab
   ========================================================================== */

.standings-table {
    /* يمكنك استخدام نفس تنسيقات .btolat-stats-table العامة */
    /* أو إضافة تخصيصات هنا */
    font-size: 0.9em; /* تصغير الخط قليلاً للجدول */
}

/* تخصيص عمود اسم الفريق */
.standings-table td.team-name-cell {
    text-align: right; /* RTL */
    font-weight: 500;
    white-space: nowrap; /* منع التفاف اسم الفريق الطويل مبدئيًا */
}

.standings-table td.team-name-cell img {
    width: 24px; /* حجم الشعار في الجدول */
    height: 24px;
    margin-inline-end: 8px; /* RTL */
    vertical-align: middle;
}
.standings-table td.team-name-cell span {
     vertical-align: middle;
}


/* تمييز النقاط */
.standings-table td:last-child strong {
    color: #0073aa; /* لون مميز للنقاط */
}

/* مؤشر النتيجة المباشرة */
.live-score-badge {
    display: inline-block;
    background-color: #e74c3c; /* لون أحمر */
    color: #fff;
    font-size: 0.8em;
    padding: 2px 5px;
    border-radius: 3px;
    margin-inline-start: 8px; /* RTL */
    font-weight: bold;
    vertical-align: middle;
    line-height: 1;
}


/* تنسيقات الاستجابة للجدول */
@media (max-width: 768px) {
    .standings-table {
        display: block; /* تحويل الجدول لسلوك البلوكات */
        overflow-x: auto; /* إضافة شريط تمرير أفقي */
        white-space: nowrap; /* منع التفاف المحتوى داخل الخلايا */
        border: none; /* إزالة الحدود الخارجية */
        box-shadow: none;
    }
     .standings-table thead {
         display: none; /* إخفاء الرأس التقليدي */
     }
     .standings-table tbody,
     .standings-table tr,
     .standings-table td {
         display: block; /* كل العناصر تصبح بلوكات */
         width: 100% !important; /* تأخذ العرض الكامل */
         box-sizing: border-box;
         border: none;
         text-align: right !important; /* محاذاة لليمين RTL */
         padding: 8px 10px;
         border-bottom: 1px solid #eee; /* خط فاصل بين "الصفوف" */
     }
     .standings-table tr {
         margin-bottom: 10px; /* مسافة بين "البطاقات" */
         border: 1px solid #eee;
         border-radius: 4px;
         padding-bottom: 0; /* إزالة الحشو السفلي للـ TR */
     }
      .standings-table tr:last-child { margin-bottom: 0; }
      .standings-table tbody tr:last-child td:last-child { border-bottom: none;}


     /* إضافة عناوين الأعمدة قبل كل خلية باستخدام ::before */
     .standings-table td::before {
         content: attr(data-label); /* النص سيأتي من data-label */
         float: left; /* عرض العنوان على اليسار RTL */
         font-weight: bold;
         margin-inline-end: 10px; /* مسافة بين العنوان والقيمة */
         color: #555;
     }

      /* إضافة data-label للخلايا (يجب إضافته في JS) */
      /* أو يمكننا إضافته هنا باستخدام nth-child - أقل مرونة */
      .standings-table td:nth-of-type(1)::before { content: "#"; }
      .standings-table td:nth-of-type(2)::before { content: "الفريق:"; }
      .standings-table td:nth-of-type(3)::before { content: "لعب:"; }
      .standings-table td:nth-of-type(4)::before { content: "ف:"; }
      .standings-table td:nth-of-type(5)::before { content: "ت:"; }
      .standings-table td:nth-of-type(6)::before { content: "خ:"; }
      .standings-table td:nth-of-type(7)::before { content: "له:"; }
      .standings-table td:nth-of-type(8)::before { content: "عليه:"; }
      .standings-table td:nth-of-type(9)::before { content: "الفرق:"; }
      .standings-table td:nth-of-type(10)::before { content: "النقاط:"; }

      /* تنسيق خاص لخلية اسم الفريق في الجوال */
      .standings-table td.team-name-cell {
         white-space: normal; /* السماح بالتفاف اسم الفريق الطويل */
      }
       .standings-table td.team-name-cell::before {
         display: none; /* إخفاء العنوان المكرر لاسم الفريق */
       }

} /* نهاية @media */

/* --- 3. إصلاح جداول الترتيب والهدافين (Table-Cell أفقي) --- */
    
    /* إلغاء التمرير */
    #tab-standings,
    #tab-scorers {
        overflow-x: visible !important;
    }

    /* إجبار الجدول على شغل 100% من العرض بنظام ثابت */
    .standings-table,
    .scorers-table {
        display: table !important;
        overflow-x: visible !important;
        border: 1px solid #e2e2e2 !important; 
        box-shadow: 0 2px 5px rgba(0,0,0,0.05) !important;
        min-width: 100% !important;
        width: 100% !important;
        table-layout: fixed !important; /* ★ الأهم: إجبار الأعمدة على الالتزام بالنسب */
    }

    /* استعادة الرأس */
    .standings-table thead, .scorers-table thead { display: table-header-group !important; }
    .standings-table tbody, .scorers-table tbody { display: table-row-group !important; }
    .standings-table tr, .scorers-table tr { display: table-row !important; }
    
    /* ★ استعادة الخلايا الأفقية (إلغاء display: flex/block) */
    .standings-table td, .scorers-table td,
    .standings-table th, .scorers-table th {
        display: table-cell !important; /* ★ الأهم: استعادة سلوك الخلية */
        width: auto !important; /* إلغاء العرض 100% */
        border: none !important;
        border-bottom: 1px solid #e2e2e2 !important;
        text-align: center !important;
        padding: 8px 2px !important; /* حشو صغير جداً */
        vertical-align: middle !important;
        font-size: 10px; /* خط صغير جداً */
        white-space: normal; /* السماح بالالتفاف الضروري */
        word-break: break-word; /* قص الكلمات الطويلة */
        /* إلغاء أي خصائص flex */
        flex-direction: unset !important;
        align-items: unset !important;
        justify-content: unset !important;
        gap: unset !important;
    }
    /* إلغاء العناوين المخفية (data-label) */
    .standings-table td::before,
    .scorers-table td::before {
        content: none !important;
    }

    /* ★ استعادة الشكل الأفقي (شعار بجوار اسم) وتصغيره */
    .standings-table td.team-name-cell,
    .scorers-table td.player-name-cell,
    .scorers-table td.team-name-cell {
        text-align: right !important; /* محاذاة لليمين */
        white-space: normal !important; /* السماح بالالتفاف */
    }
    .standings-table td.team-name-cell img,
    .scorers-table td.player-name-cell img.player-logo,
    .scorers-table td.team-name-cell img.team-logo-small {
        width: 18px !important;
        height: 18px !important;
        margin: 0 0 0 4px !important; /* هامش لليسار (RTL) */
        vertical-align: middle;
    }

    /* --- توزيع النسب المئوية (جدول الترتيب) --- */
    .standings-table th:nth-child(1), .standings-table td:nth-child(1) { width: 7%; }  /* # */
    .standings-table th:nth-child(2), .standings-table td:nth-child(2) { width: 28%; } /* الفريق */
    .standings-table th:nth-child(3), .standings-table td:nth-child(3) { width: 7%; }  /* لعب */
    .standings-table th:nth-child(4), .standings-table td:nth-child(4) { width: 7%; }  /* ف */
    .standings-table th:nth-child(5), .standings-table td:nth-child(5) { width: 7%; }  /* ت */
    .standings-table th:nth-child(6), .standings-table td:nth-child(6) { width: 7%; }  /* خ */
    .standings-table th:nth-child(7), .standings-table td:nth-child(7) { width: 7%; }  /* له */
    .standings-table th:nth-child(8), .standings-table td:nth-child(8) { width: 7%; }  /* عليه */
    .standings-table th:nth-child(9), .standings-table td:nth-child(9) { width: 7%; }  /* الفرق */
    .standings-table th:nth-child(10),.standings-table td:nth-child(10){ width: 9%; font-weight: bold; } /* النقاط */

    /* --- توزيع النسب المئوية (جدول الهدافين) --- */
    .scorers-table th:nth-child(1), .scorers-table td:nth-child(1) { width: 10%; } /* # */
    .scorers-table th:nth-child(2), .scorers-table td:nth-child(2) { width: 40%; } /* اللاعب */
    .scorers-table th:nth-child(3), .scorers-table td:nth-child(3) { width: 35%; } /* الفريق */
    .scorers-table th:nth-child(4), .scorers-table td:nth-child(4) { width: 15%; font-weight: bold; } /* الأهداف */
}