/* ==========================================================
   MATCH EVENTS
========================================================== */

.match-events {
    width: 100%;

    direction: rtl;

    background: #fff;

    border: 1px solid #e8ebee;

    border-radius: 14px;

    padding: 22px 24px;

    box-sizing: border-box;

    margin-bottom: 18px;
}


/* ==========================================================
   EMPTY
========================================================== */

.match-events-empty {
    padding: 35px 20px;

    text-align: center;

    color: #777;

    font-size: 14px;
}


/* ==========================================================
   TIMELINE
========================================================== */

.match-events-timeline {
    position: relative;

    width: 100%;

    padding: 20px 0;
}


/* الخط الأوسط */

.match-events-timeline::before {
    content: "";

    position: absolute;

    top: 0;
    bottom: 0;

    right: 50%;

    width: 1px;

    background: #e5e7eb;

    transform: translateX(50%);
}


/* ==========================================================
   EVENT ROW
========================================================== */

.match-event-row {
    position: relative;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        58px
        minmax(0, 1fr);

    align-items: center;

    min-height: 58px;

    margin-bottom: 7px;

    z-index: 1;
}


.match-event-row:last-child {
    margin-bottom: 0;
}


/* ==========================================================
   SIDES
========================================================== */

.match-event-side {
    min-width: 0;
}


.match-event-side--home {
    min-width: 0;

    padding: 0;

    text-align: right;
}


.match-event-side--away {
    min-width: 0;

    padding: 0;

    text-align: left;
}

/* ==========================================================
   CONTENT
========================================================== */

.match-event-content {
    display: grid;

    align-items: center;

    width: max-content;

    max-width: 100%;

    gap: 7px;

    padding: 3px 0;
}


.match-event-side--home
.match-event-content {
    grid-template-columns:
        max-content
        24px;

    margin-left: auto;
}

.match-event-side--home
.match-event-icon,
.match-event-side--home
.match-event-card-icon {
    grid-column: 2;
}


.match-event-side--home
.match-event-player {
    grid-column: 1;
}


.match-event-side--away
.match-event-content {
    grid-template-columns:
        24px
        max-content;

    margin-right: auto;
}


.match-event-side--away
.match-event-icon,
.match-event-side--away
.match-event-card-icon {
    grid-column: 1;
}


.match-event-side--away
.match-event-player {
    grid-column: 2;
}


/* ==========================================================
   PLAYER
========================================================== */

.match-event-player {
    display: flex;

    flex-direction: column;

    gap: 2px;

    min-width: 0;
}

.match-event-player {
    width: max-content;

    max-width: 180px;
}

.match-event-side--home {
    min-width: 0;

    padding-right: 10px;

    text-align: right;
}

.match-event-side--away {
    min-width: 0;

    padding-left: 10px;

    text-align: left;
}

.match-event-player strong {
    display: block;

    color: #222;

    font-size: 13px;

    font-weight: 500;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.match-event-player span {
    display: block;

    color: #8b8f95;

    font-size: 11px;
}


/* ==========================================================
   MINUTE
========================================================== */

.match-event-minute {
    position: relative;

    display: flex;

    align-items: center;

    justify-content: center;

    width: 42px;
    height: 42px;

    margin: 0 auto;

    border-radius: 50%;

    background: #fff;

    border: 1px solid #e5e7eb;

    color: #4b5563;

    font-size: 11px;

    font-weight: 600;

    z-index: 3;
}


/* ==========================================================
   BALL
========================================================== */

.match-event-icon {
    display: flex;

    align-items: center;

    justify-content: center;

    width: 24px;
    height: 24px;

    flex: 0 0 24px;

    font-size: 15px;
}


/* ==========================================================
   CARD
========================================================== */

.match-event-card-icon {
    display: block;

    width: 10px;
    height: 17px;

    flex: 0 0 10px;

    border-radius: 2px;
}


.match-event-card-icon--yellow {
    background: #facc15;
}


.match-event-card-icon--red {
    background: #ef4444;
}


/* ==========================================================
   HOVER
========================================================== */

.match-event-content {
    transition:
        transform .2s ease;
}


.match-event-content:hover {
    transform: translateY(-1px);
}


/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 700px) {

    .match-events-timeline {
        padding: 15px 0;
    }


    .match-event-row {
        grid-template-columns:
            minmax(0, 1fr)
            55px
            minmax(0, 1fr);

        min-height: 54px;
    }


    .match-event-side--home {
        padding-left: 10px;
    }


    .match-event-side--away {
        padding-right: 10px;
    }


    .match-event-player strong {
        font-size: 12px;
    }


    .match-event-player span {
        font-size: 10px;
    }


    .match-event-minute {
        width: 36px;
        height: 36px;

        font-size: 10px;
    }


    .match-events-timeline::before {
        right: 50%;
    }

}

/* ==========================================================
   SUBSTITUTIONS
========================================================== */

.match-event-substitution {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.match-event-substitution__in {
    order: 1;
}

.match-event-substitution__out {
    order: 2;
}


.match-event-substitution__out strong {
    color: #dc2626;

    font-size: 12px;

    font-weight: 500;
}


.match-event-substitution__in strong {
    color: #16a34a;

    font-size: 12px;

    font-weight: 500;
}


/* ==========================================================
   SUBSTITUTION ICON BESIDE MINUTE
========================================================== */

.match-event-minute--substitution {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 7px;

    width: auto;
    min-width: 66px;

    height: 42px;

    padding: 0 7px;

    background: transparent;

    border: 0;

    border-radius: 0;

    box-sizing: border-box;
}


.match-event-minute--substitution
.match-event-minute__value {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;

    border-radius: 50%;

    background: #fff;

    border: 1px solid #e5e7eb;

    color: #4b5563;

    font-size: 11px;

    font-weight: 600;
}


.match-event-substitution-icon {
    color: #7c828a;

    font-size: 12px;

    flex: 0 0 auto;
}


/* ==========================================================
   EVENT ICONS
========================================================== */

.match-event-icon i {
    font-size: 13px;
}


.match-event-icon--ball {
    color: #666;
}


.match-event-icon--own-goal {
    color: #777;
}


.match-event-icon--penalty-missed {
    color: #777;
}


/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 700px) {

    .match-events {
        padding: 18px 14px;
    }

    .match-event-substitution__out strong,
    .match-event-substitution__in strong {
        font-size: 11px;
    }

}

/* ==========================================================
   FINAL FOTMOB STYLE EVENT ALIGNMENT
========================================================== */

/* الصف كله: فريق يسار — دقيقة — فريق يمين */
.match-event-row {
    direction: rtl;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        70px
        minmax(0, 1fr);

    align-items: center;
}


/* ==========================================================
   SIDES
========================================================== */

.match-event-side--home,
.match-event-side--away {
    width: 100%;
    min-width: 0;

    padding: 0;
}


/* ==========================================================
   HOME = الجهة اليسرى
========================================================== */

.match-event-side--home {
    display: flex;
    justify-content: flex-end;

    text-align: right;
}

.match-event-side--home .match-event-content {
    width: 180px;
    max-width: 180px;

    margin-left: 0;
    margin-right: 0;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        24px;

    align-items: center;

    gap: 7px;
}


/* اسم اللاعب */
.match-event-side--home .match-event-player {
    grid-column: 1;

    width: 100%;
    max-width: none;

    text-align: right;

    direction: rtl;
}


/* الأيقونة */
.match-event-side--home .match-event-icon,
.match-event-side--home .match-event-card-icon {
    grid-column: 2;

    justify-self: center;
}


/* ==========================================================
   AWAY = الجهة اليمنى
========================================================== */

.match-event-side--away {
    display: flex;
    justify-content: flex-start;

    text-align: left;
}

.match-event-side--away .match-event-content {
    width: 180px;
    max-width: 180px;

    margin-left: 0;
    margin-right: 0;

    display: grid;

    grid-template-columns:
        24px
        minmax(0, 1fr);

    align-items: center;

    gap: 7px;
}


/* الأيقونة */
.match-event-side--away .match-event-icon,
.match-event-side--away .match-event-card-icon {
    grid-column: 1;

    justify-self: center;
}


/* اسم اللاعب */
.match-event-side--away .match-event-player {
    grid-column: 2;

    width: 100%;
    max-width: none;

    text-align: left;

    direction: rtl;
}


/* ==========================================================
   PLAYER TEXT
========================================================== */

.match-event-player {
    min-width: 0;

    width: 100%;
}


.match-event-player strong,
.match-event-player span {
    display: block;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* ==========================================================
   EVENT ICONS
========================================================== */

.match-event-icon {
    width: 22px;
    height: 22px;

    display: flex;

    align-items: center;
    justify-content: center;

    flex: 0 0 22px;
}


.match-event-card-icon {
    width: 4px;
    height: 16px;
    flex: 0 0 7px;
    justify-self: center;
}


/* ==========================================================
   CENTER MINUTE
========================================================== */

.match-event-minute {
    width: 42px;
    height: 42px;

    margin: 0 auto;

    z-index: 3;
}


/* ==========================================================
   SUBSTITUTION
========================================================== */

.match-event-substitution {
    width: 100%;
}

.match-event-substitution__out,
.match-event-substitution__in {
    display: block;
}


/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 700px) {

    .match-event-row {
        grid-template-columns:
            minmax(0, 1fr)
            58px
            minmax(0, 1fr);
    }

    .match-event-side--home .match-event-content,
    .match-event-side--away .match-event-content {
        width: 140px;
        max-width: 140px;
    }

}

/* ==========================================================
   FINAL EVENT ALIGNMENT
========================================================== */


/* ----------------------------------------------------------
   تقليل المسافة بين الاسم والأيقونة
---------------------------------------------------------- */

.match-event-side--home .match-event-content,
.match-event-side--away .match-event-content {
    width: max-content;
    max-width: none;

    gap: 9px;
}


/* صاحب الأرض: الاسم ثم الأيقونة */
.match-event-side--home .match-event-content {
    grid-template-columns:
        max-content
        22px;
}


/* الضيف: الأيقونة ثم الاسم */
.match-event-side--away .match-event-content {
    grid-template-columns:
        22px
        max-content;
}


/* ----------------------------------------------------------
   الاسم
---------------------------------------------------------- */

.match-event-side--home .match-event-player,
.match-event-side--away .match-event-player {
    width: max-content;

    max-width: 180px;
}


/* ----------------------------------------------------------
   أيقونات الأحداث والبطاقات
---------------------------------------------------------- */

.match-event-side--home .match-event-icon,
.match-event-side--home .match-event-card-icon,
.match-event-side--away .match-event-icon,
.match-event-side--away .match-event-card-icon {
    width: 20px;

    justify-self: center;
}


/* ----------------------------------------------------------
   أيقونة التبديل
---------------------------------------------------------- */

.match-event-row {
    position: relative;
}


.match-event-minute--substitution
.match-event-substitution-icon {
    position: absolute;
    top: 50%;
    margin: 0;
    transform: translateY(-50%);

    width: 18px;
    height: 18px;

    font-size: 0;
    color: transparent;
}

.match-event-minute--substitution
.match-event-substitution-icon::before,
.match-event-minute--substitution
.match-event-substitution-icon::after {
    content: "\f362";

    position: absolute;
    inset: 0;

    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 12px;
    line-height: 18px;

    text-align: center;
}

.match-event-minute--substitution
.match-event-substitution-icon::before {
    color: #16a34a;

    clip-path: inset(0 0 50% 0);
}

.match-event-minute--substitution
.match-event-substitution-icon::after {
    color: #dc2626;

    clip-path: inset(50% 0 0 0);
}


/* صاحب الأرض = يسار دائرة الدقيقة */
.match-event-row--home
.match-event-minute--substitution
.match-event-substitution-icon {
    left: calc(50% + 42px);
}


/* الضيف = يمين دائرة الدقيقة */
.match-event-row--away
.match-event-minute--substitution
.match-event-substitution-icon {
    right: calc(50% + 38px);
}


/* نخلي دائرة الدقيقة نفسها بدون المسافة الإضافية */
.match-event-minute--substitution {
    min-width: 42px;

    width: 42px;

    padding: 0;

    gap: 0;
}


/* الأيقونة داخل الدقيقة لا تتحرك مع الدائرة */
.match-event-minute--substitution
.match-event-substitution-icon {
    flex: none;
}

/* ==========================================================
   EVENT LABEL ALIGNMENT
========================================================== */

/* صاحب الأرض */
.match-event-side--home .match-event-player {
    text-align: right;
    align-items: flex-start;
}

/* الفريق الضيف */
.match-event-side--away .match-event-player {
    text-align: left;
    align-items: flex-start;
}


/* اسم اللاعب والوصف يبدأان من نفس المحاذاة */
.match-event-side--home .match-event-player strong,
.match-event-side--home .match-event-player span {
    width: 100%;
    text-align: right;
}

.match-event-side--away .match-event-player strong,
.match-event-side--away .match-event-player span {
    width: 100%;
    text-align: left;
}

.match-event-side--home .match-event-player,
.match-event-side--away .match-event-player {
    width: max-content;
}

/* ==========================================================
   ALIGN PLAYER NAME + EVENT LABEL
========================================================== */

.match-event-player {
    display: flex;

    flex-direction: column;

    width: max-content;

    max-width: 180px;

    gap: 2px;

    direction: ltr;

    align-items: flex-start;
}


/* النص العربي يبقى RTL */
.match-event-player strong,
.match-event-player span {
    display: block;

    width: auto;

    max-width: 100%;

    direction: rtl;

    text-align: left;

    margin: 0;
}

/* ==========================================================
   FIX — PLAYER NAME / LABEL ALIGNMENT
========================================================== */

/* صاحب الأرض */
.match-event-side--home .match-event-player {
    direction: rtl;

    align-items: flex-end;

    text-align: right;
}


/* الضيف */
.match-event-side--away .match-event-player {
    direction: rtl;

    align-items: flex-start;

    text-align: left;
}


/* النصوص نفسها */
.match-event-side--home .match-event-player strong,
.match-event-side--home .match-event-player span {
    width: auto;

    margin: 0;

    text-align: right;
}


.match-event-side--away .match-event-player strong,
.match-event-side--away .match-event-player span {
    width: auto;

    margin: 0;

    text-align: left;
}
/* ==========================================================
   SUBSTITUTION ARROWS
========================================================== */

.match-event-substitution__out,
.match-event-substitution__in {
    display: flex;
    align-items: center;
    gap: 5px;
}


/* اللاعب الخارج */
.match-event-substitution__out {
    color: #dc2626;
}


/* اللاعب الداخل */
.match-event-substitution__in {
    color: #16a34a;
}


/* سهم الخارج */
.match-event-substitution__out i {
    color: #dc2626;
    font-size: 10px;
}


/* سهم الداخل */
.match-event-substitution__in i {
    color: #16a34a;
    font-size: 10px;
}

.match-event-side--home .match-event-card-icon,
.match-event-side--away .match-event-card-icon {
    width: 12px;
    min-width: 7px;
    max-width: 12px;
    height: 16px;
    flex: 0 0 7px;
    border-radius: 2px;
}

/* =========================================
   بطاقة الأحداث - توحيد العرض على الهاتف
========================================= */

@media (max-width: 768px) {

    .match-page .match-content .match-events {
        width: calc(100vw - 30px) !important;
        max-width: none !important;
        min-width: 0 !important;

        margin-left: calc((100% - (100vw - 30px)) / 2) !important;
        margin-right: calc((100% - (100vw - 30px)) / 2) !important;

        box-sizing: border-box !important;
    }

}

/* ==========================================================
   FRENCH / LTR — FINAL
========================================================== */

.match-events--fr {
    direction: ltr;
    text-align: left;
}


/* ==========================================================
   TIMELINE
========================================================== */

.match-events--fr .match-events-timeline::before {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}


/* ==========================================================
   ROW
========================================================== */

.match-events--fr .match-event-row {
    direction: ltr;

    grid-template-columns:
        minmax(0, 1fr)
        70px
        minmax(0, 1fr);
}


/* Home = LEFT */
.match-events--fr .match-event-side--home {
    grid-column: 1;
    grid-row: 1;

    display: flex;
    justify-content: flex-end;

    direction: ltr;
    text-align: right;
}


/* Minute = CENTER */
.match-events--fr .match-event-minute {
    grid-column: 2;
    grid-row: 1;
}


/* Away = RIGHT */
.match-events--fr .match-event-side--away {
    grid-column: 3;
    grid-row: 1;

    display: flex;
    justify-content: flex-start;

    direction: ltr;
    text-align: left;
}


/* ==========================================================
   HOME CONTENT
   الاسم ← البطاقة ← المنتصف
========================================================== */

.match-events--fr .match-event-side--home .match-event-content {
    display: grid;

    grid-template-columns:
        max-content
        22px;

    direction: ltr;

    width: max-content;
    max-width: 180px;

    margin: 0;
}


/* Home player */
.match-events--fr .match-event-side--home .match-event-player {
    grid-column: 1;

    direction: ltr;

    text-align: right;
    align-items: flex-end;

    width: max-content;
}


/* Home card/icon */
.match-events--fr .match-event-side--home .match-event-icon,
.match-events--fr .match-event-side--home .match-event-card-icon {
    grid-column: 2;

    justify-self: center;
}


/* ==========================================================
   AWAY CONTENT
   المنتصف ← البطاقة ← الاسم
========================================================== */

.match-events--fr .match-event-side--away .match-event-content {
    display: grid;

    grid-template-columns:
        22px
        max-content;

    direction: ltr;

    width: max-content;
    max-width: 180px;

    margin: 0;
}


/* Away card/icon */
.match-events--fr .match-event-side--away .match-event-icon,
.match-events--fr .match-event-side--away .match-event-card-icon {
    grid-column: 1;

    justify-self: center;
}


/* Away player */
.match-events--fr .match-event-side--away .match-event-player {
    grid-column: 2;

    direction: ltr;

    text-align: left;
    align-items: flex-start;

    width: max-content;
}


/* ==========================================================
   TEXT
========================================================== */

.match-events--fr .match-event-player strong,
.match-events--fr .match-event-player span {
    direction: ltr;
}


/* ==========================================================
   CARDS
========================================================== */

.match-events--fr .match-event-card-icon {
    width: 12px !important;
    min-width: 7px !important;
    max-width: 12px !important;

    height: 16px;

    flex: 0 0 7px;

    margin: 0 !important;
}


/* ==========================================================
   SUBSTITUTION
========================================================== */

.match-events--fr .match-event-substitution {
    direction: ltr;
}

.match-events--fr .match-event-substitution__out,
.match-events--fr .match-event-substitution__in {
    direction: ltr;
    text-align: left;
}


/* ==========================================================
   FRENCH — SUBSTITUTION ICON POSITION
========================================================== */

/* Home = الأيقونة على يسار دائرة الدقيقة */
.match-events--fr .match-event-row--home
.match-event-minute--substitution
.match-event-substitution-icon {
    right: calc(50% + 42px) !important;
    left: auto !important;
}


/* Away = الأيقونة على يمين دائرة الدقيقة */
.match-events--fr .match-event-row--away
.match-event-minute--substitution
.match-event-substitution-icon {
    left: calc(50% + 38px) !important;
    right: auto !important;
}


/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 700px) {

    .match-events--fr .match-event-row {
        grid-template-columns:
            minmax(0, 1fr)
            58px
            minmax(0, 1fr);
    }

    .match-events--fr .match-event-side--home {
        padding-right: 10px;
        padding-left: 0;
    }

    .match-events--fr .match-event-side--away {
        padding-left: 10px;
        padding-right: 0;
    }

    .match-events--fr .match-events-timeline::before {
        left: 50%;
        right: auto;
    }

}