/* Public CSS for Score Tank Leagues Add-on */

.scoretank-leagues-display-wrapper {
    margin: 20px auto;
    padding: 0 15px;
    max-width: 1200px; /* أو العرض المناسب لموقعك */
    font-family: sans-serif; /* اختر الخط المناسب */
}

.league-category-section {
    margin-bottom: 40px;
}

.league-category-title {
    text-align: center;
    font-size: 2em;
    margin-bottom: 25px;
    color: #333;
    border-bottom: 2px solid #0073aa; /* لون مميز */
    padding-bottom: 10px;
    position: relative;
}
/* خط سفلي مزخرف (اختياري) */
.league-category-title::after {
   content: '';
   position: absolute;
   bottom: -5px;
   left: 50%;
   transform: translateX(-50%);
   width: 50px;
   height: 3px;
   background-color: #00a0d2;
}


.leagues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* شبكة مرنة */
    gap: 25px; /* مسافات بين الإطارات */
}

.league-item-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* لإخفاء أي تجاوز */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex; /* لترتيب العناصر الداخلية */
    flex-direction: column;
}

.league-item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.league-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100%; /* لجعل الرابط يملأ البطاقة */
    align-items: center; /* توسيط المحتوى */
    text-align: center;
}


.league-item-logo {
    height: 80px; /* حجم أكبر للشعار */
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.league-item-logo img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}
.league-item-logo .league-no-logo {
    display: block;
    width: 60px;
    height: 60px;
    background-color: #f0f0f0;
    border-radius: 50%;
    line-height: 60px;
    text-align: center;
    color: #aaa;
    font-size: 0.8em;
     /* يمكنك إضافة أيقونة هنا كـ background-image */
}


.league-item-name {
    font-size: 1.1em;
    font-weight: 600;
    margin-top: auto; /* يدفع الاسم للأسفل قليلاً */
    margin-bottom: 15px; /* مسافة قبل الزر */
    line-height: 1.4;
    min-height: 2.8em; /* ارتفاع سطرين تقريبًا */
     overflow: hidden; /* تجنبًا لتجاوز النص الطويل جدًا */
     display: -webkit-box;
     -webkit-line-clamp: 2; /* حد أقصى سطرين */
     -webkit-box-orient: vertical;
}

.league-item-details-button.button {
    display: inline-block;
    background-color: #0073aa;
    color: #fff;
    padding: 8px 18px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
    border: none;
    cursor: pointer;
    margin-top: auto; /* يدفع الزر للأسفل */
}

.league-item-details-button.button:hover {
    background-color: #005a87;
}

/* === Styles for League iFrame Tab (V2 - Auto Height) === */

/* 1. الحاوية (لا تغيير) */
.btolat-match-tab-content#league-details-tab {
    padding: 0;
    margin: 0;
    min-height: 500px; /* ارتفاع مبدئي أثناء التحميل */
    overflow: hidden; 
}

/* 2. تنسيق الفريم (التغيير الأهم) */
.btolat-league-iframe {
    width: 100%;
    /* ★ إزالة الارتفاع الثابت (height: 1200px) ★ */
    min-height: 500px; /* ارتفاع مبدئي (سيتم تحديثه بـ JS) */
    border: none;
    display: block;
    margin: 0;
    padding: 0;
    overflow: hidden; /* ★★★ هذا السطر هو الأهم لإخفاء السكرول ★★★ */
    transition: height 0.2s ease-out; /* حركة ناعمة عند تغيير الارتفاع */
}

/* 3. تنسيق مؤشر التحميل (لا تغيير) */
.loading-league-iframe {
    display: flex; 
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 1.1em;
}

.loading-league-iframe .spinner {
    margin: 0 0 0 10px; 
    float: none;
    display: inline-block;
    vertical-align: middle;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .leagues-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
    }
    .league-category-title {
        font-size: 1.8em;
    }
    .league-item-logo {
        height: 60px;
    }
     .league-item-name {
        font-size: 1em;
    }
     .league-item-details-button.button {
        padding: 6px 14px;
     }
}
 @media (max-width: 480px) {
    .leagues-grid {
        grid-template-columns: repeat(2, 1fr); /* عمودين في الشاشات الصغيرة جدًا */
        gap: 15px;
    }
 }

/*
--------------------------------------------------------------
# (إصلاح v3) الهاتف: تنسيقات أفقية دقيقة (Grid + Table-Cell)
--------------------------------------------------------------
*/

@media (max-width: 768px) {

    /* --- 1. إصلاح التبويبات (تظل مرنة وتتقلص) --- */
    
    .btolat-stats-tabs-nav {
        flex-direction: row !important;
        align-items: center !important;
        border-bottom: 2px solid #ddd !important;
    }
    .btolat-stats-tabs-nav li {
        width: auto !important;
        margin: 0 2px !important;
        flex: 1 1 0 !important; /* تتقلص وتتشارك المساحة */
    }
    .btolat-stats-tabs-nav a.tab-button {
        width: 100% !important;
        text-align: center !important;
        padding: 10px 5px !important;
        font-size: 0.85em !important;
        white-space: nowrap;
        border: none !important;
        border-bottom: 3px solid transparent !important;
        margin-bottom: -2px !important;
    }
    .btolat-stats-tabs-nav a.tab-button.active {
        background-color: transparent !important;
        border-bottom-color: #0073aa !important;
    }

    /* --- 2. إصلاح جدول المباريات (باستخدام CSS Grid) --- */
    
    /* إلغاء أي تمرير أو عرض أدنى */
    #league-fixtures-container {
        overflow-x: visible !important;
        min-width: 100% !important;
    }
    #league-fixtures-container .fixtures-table {
         min-width: 100% !important;
         border: none !important;
         box-shadow: none !important;
         background: none !important;
    }
    
    /* ★ تطبيق Grid على الصف (لتنفيذ طلبك بدقة) */
    .fixture-match-info-v2 {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr !important; /* Team1 | Center | Team2 */
        grid-template-rows: auto auto; /* الصف 1 للشعار، الصف 2 للاسم */
        align-items: center !important;
        justify-items: center !important; /* توسيط كل العناصر */
        padding: 10px 5px !important;
        gap: 5px !important;
        border: 1px solid #eee !important;
        border-radius: 5px !important;
        margin-bottom: 10px !important;
        background: #fff !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
        /* إلغاء خصائص Flex السابقة */
        flex-wrap: unset !important;
        justify-content: unset !important;
    }

    /* ★ توزيع العناصر على الشبكة (Grid) */
    
    /* الفريق الأول (شعار فوق اسم) */
    .fixture-match-info-v2 .logo-team1  { grid-column: 1; grid-row: 1; }
    .fixture-match-info-v2 .team-name-1 { grid-column: 1; grid-row: 2; }
    
    /* المنتصف (يشغل الصفين عمودياً) */
    .fixture-match-info-v2 .match-center-info { 
        grid-column: 2; 
        grid-row: 1 / span 2; /* ★ هذا يضعه في المنتصف عمودياً */
        /* استعادة تنسيق flex *الداخلي* للمنتصف */
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex: 0 1 auto !important;
        order: unset !important;
        margin: 0 !important;
        padding: 0 5px !important; /* إضافة حشو للمنتصف */
        border: none !important;
        min-width: 80px !important;
    }
    
    /* الفريق الثاني (شعار فوق اسم) */
    .fixture-match-info-v2 .logo-team2  { grid-column: 3; grid-row: 1; }
    .fixture-match-info-v2 .team-name-2 { grid-column: 3; grid-row: 2; }

    /* تصغير العناصر الفردية */
    .fixture-match-info-v2 .team-name {
        font-size: 0.8em !important;
        text-align: center !important;
    }
    .fixture-match-info-v2 .team-logo img {
        width: 25px !important;
        height: 25px !important;
    }
    .fixture-match-info-v2 .team-score { font-size: 1.1em !important; padding: 0 4px !important; }
    .fixture-match-info-v2 .match-status-time { font-size: 0.7em !important; }