:root {
    --seg-purple: #4B0082;
    --seg-purple-dark: #34005f;
    --seg-soft: #f7f3fb;
    --seg-text: #202124;
    --seg-muted: #666;
    --seg-border: rgba(75, 0, 130, .14);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Cairo", "Tajawal", Arial, sans-serif;
}

.ak-main-wrap,
.block1 {
    margin-top: 120px;
}

.fixed-top-iframe {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 120px;
    z-index: 10;
    border: 0;
}

.ads-container {
    text-align: center;
    margin: 20px auto;
    max-width: 1100px;
    min-height: 90px;
}

.tawjihi-search-message {
    margin: 14px auto 20px;
    padding: 14px 18px;
    border: 1px solid var(--seg-border);
    border-radius: 16px;
    background: #fff;
    color: var(--seg-text);
    line-height: 1.9;
    text-align: center;
}

.tawjihi-error {
    color: #b42318;
    background: #fff4f2;
    border-color: rgba(180, 35, 24, .2);
}

.tawjihi-empty {
    padding: 25px;
    text-align: center;
    color: var(--seg-muted);
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--seg-border);
}

.tawjihi-loader {
    width: 34px;
    height: 34px;
    border: 4px solid rgba(75,0,130,.15);
    border-top-color: var(--seg-purple);
    display: inline-block;
    border-radius: 999px;
    animation: tawjihi-spin .8s linear infinite;
}

@keyframes tawjihi-spin {
    to {
        transform: rotate(360deg);
    }
}

.tawjihi-result-card {
    margin-bottom: 28px;
    scroll-margin-top: 150px;
}

.tawjihi-student-main .status-failed {
    font-size: 26px;
}

.tawjihi-toppers-section {
    margin-bottom: 26px;
}

.tawjihi-toppers-section h2,
.tawjihi-result-card h2 {
    color: var(--seg-purple);
}

#sawtelghad-radio-player,
#sawtelghad-global-radio-player {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 999999;
    width: min(380px, calc(100vw - 32px));
    background: linear-gradient(135deg, var(--seg-purple), var(--seg-purple-dark));
    color: #fff;
    border-radius: 20px;
    box-shadow: 0 18px 55px rgba(0,0,0,.24);
    padding: 12px;
    direction: rtl;
    font-family: "Cairo", "Tajawal", Arial, sans-serif;
}

.seg-radio-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
}

.seg-radio-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.seg-radio-dot {
    width: 9px;
    height: 9px;
    background: #2ee66b;
    border-radius: 999px;
    box-shadow: 0 0 0 6px rgba(46,230,107,.16);
}

.seg-radio-start {
    border: 0;
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 700;
    cursor: pointer;
    background: #fff;
    color: var(--seg-purple);
}

#sawtelghad-radio-player audio,
#sawtelghad-global-radio-player audio {
    width: 100%;
    height: 34px;
    display: block;
}

@media (max-width: 720px) {
    .fixed-top-iframe {
        height: 90px;
    }

    .ak-main-wrap,
    .block1 {
        margin-top: 90px;
    }

    #sawtelghad-radio-player,
    #sawtelghad-global-radio-player {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        border-radius: 16px;
    }

    .seg-radio-head {
        font-size: 13px;
    }
}

/* Tawjihi result rank rows: keep labels in one line */
.tawjihi-result-card .item:not(.tawjihi-student-main) {
    display: grid !important;
    grid-template-columns: minmax(190px, 220px) minmax(0, 1fr) !important;
    align-items: center !important;
}

.tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
    white-space: nowrap !important;
    min-width: 190px !important;
    line-height: 1.5 !important;
}

.tawjihi-result-card .item:not(.tawjihi-student-main) .item-title {
    min-width: 0 !important;
}

@media (max-width: 720px) {
    .tawjihi-result-card .item:not(.tawjihi-student-main) {
        grid-template-columns: minmax(150px, 42%) minmax(0, 1fr) !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
        min-width: 150px !important;
        font-size: 15px !important;
    }
}

/* Tawjihi result first row: align seat-number column with rank-label column */
.tawjihi-result-card .tawjihi-student-main {
    display: grid !important;
    grid-template-columns:
        minmax(190px, 220px)
        minmax(220px, 1fr)
        minmax(130px, 160px)
        minmax(260px, 1.25fr)
        minmax(70px, 90px) !important;
    align-items: center !important;
}

.tawjihi-result-card .tawjihi-student-main .item-id {
    min-width: 190px !important;
    white-space: nowrap !important;
    text-align: center !important;
}

.tawjihi-result-card .tawjihi-student-main .item-title,
.tawjihi-result-card .tawjihi-student-main .item-avg {
    min-width: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.tawjihi-result-card .tawjihi-student-main .item-avg {
    text-align: center !important;
    font-weight: 900 !important;
}

/* Keep all result rows visually aligned */
.tawjihi-result-card .item {
    overflow: hidden !important;
}

@media (max-width: 920px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns:
            minmax(150px, 42%)
            minmax(0, 1fr) !important;
        row-gap: 0 !important;
    }

    .tawjihi-result-card .tawjihi-student-main .item-id {
        min-width: 150px !important;
    }

    .tawjihi-result-card .tawjihi-student-main .item-title,
    .tawjihi-result-card .tawjihi-student-main .item-avg {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
}

/* FINAL Tawjihi student row columns:
   RTL visual order:
   رقم الجلوس | الفرع | المديرية | المدرسة | المعدل
*/
.tawjihi-result-card .tawjihi-student-main {
    display: grid !important;
    direction: rtl !important;
    grid-template-columns:
        155px
        135px
        175px
        minmax(320px, 1fr)
        86px !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

.tawjihi-result-card .tawjihi-student-main > div {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    padding: 0 10px !important;
    white-space: nowrap !important;
    line-height: 1.45 !important;
}

/* رقم الجلوس */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(1) {
    font-weight: 700 !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* الفرع: صغير ومناسب لكل الفروع */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(2) {
    font-size: 18px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* المديرية / المحافظة: ممنوع تنقص لأول حرف */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(3) {
    font-size: 18px !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* المدرسة: أكبر عمود */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(4) {
    justify-content: center !important;
    font-size: 17px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* المعدل */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(5) {
    font-size: 29px !important;
    font-weight: 900 !important;
    overflow: visible !important;
    text-overflow: clip !important;
    padding: 0 8px !important;
}

/* rank rows stay aligned and readable */
.tawjihi-result-card .item:not(.tawjihi-student-main) {
    display: grid !important;
    direction: rtl !important;
    grid-template-columns: 190px minmax(0, 1fr) !important;
    align-items: center !important;
}

.tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    min-width: 190px !important;
}

/* Tablet */
@media (max-width: 1050px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns:
            140px
            125px
            155px
            minmax(240px, 1fr)
            78px !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div:nth-child(2),
    .tawjihi-result-card .tawjihi-student-main > div:nth-child(3) {
        font-size: 16px !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div:nth-child(4) {
        font-size: 15px !important;
    }
}

/* Mobile: stack cleanly instead of clipping */
@media (max-width: 720px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns: 1fr !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div {
        justify-content: center !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        padding: 9px 12px !important;
        border-bottom: 1px solid rgba(0,0,0,.06) !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div:last-child {
        border-bottom: 0 !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) {
        grid-template-columns: 155px minmax(0, 1fr) !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
        min-width: 155px !important;
        font-size: 15px !important;
    }
}

/* FINAL alignment: everything right, average centered */
.tawjihi-result-card,
.tawjihi-result-card .items,
.tawjihi-result-card .item {
    direction: rtl !important;
    text-align: right !important;
}

/* First student row: all cells right-aligned */
.tawjihi-result-card .tawjihi-student-main > div {
    justify-content: flex-start !important;
    text-align: right !important;
    direction: rtl !important;
}

/* Seat number, branch, directorate, school: right */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(1),
.tawjihi-result-card .tawjihi-student-main > div:nth-child(2),
.tawjihi-result-card .tawjihi-student-main > div:nth-child(3),
.tawjihi-result-card .tawjihi-student-main > div:nth-child(4) {
    justify-content: flex-start !important;
    text-align: right !important;
}

/* Average only: centered */
.tawjihi-result-card .tawjihi-student-main > div:nth-child(5),
.tawjihi-result-card .tawjihi-student-main .item-avg {
    justify-content: center !important;
    text-align: center !important;
}

/* Rank/status rows: labels and values right-aligned */
.tawjihi-result-card .item:not(.tawjihi-student-main) .item-id,
.tawjihi-result-card .item:not(.tawjihi-student-main) .item-title {
    justify-content: flex-start !important;
    text-align: right !important;
    direction: rtl !important;
    padding-right: 18px !important;
    padding-left: 10px !important;
}

/* Preserve readable label column width */
.tawjihi-result-card .item:not(.tawjihi-student-main) {
    grid-template-columns: 200px minmax(0, 1fr) !important;
}

/* Prevent old inline text-align from forcing weird behavior */
.tawjihi-result-card .item-id[style],
.tawjihi-result-card .item-title[style] {
    text-align: right !important;
}

/* Mobile remains clean */
@media (max-width: 720px) {
    .tawjihi-result-card .tawjihi-student-main > div {
        justify-content: flex-start !important;
        text-align: right !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div:nth-child(5),
    .tawjihi-result-card .tawjihi-student-main .item-avg {
        justify-content: center !important;
        text-align: center !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) {
        grid-template-columns: 165px minmax(0, 1fr) !important;
    }
}

/* HARD FINAL student row layout using explicit classes */
.tawjihi-result-card .tawjihi-student-main {
    display: grid !important;
    direction: rtl !important;
    grid-template-columns:
        160px     /* رقم الجلوس */
        185px     /* الفرع */
        185px     /* المديرية */
        minmax(360px, 1fr) /* المدرسة */
        92px      /* المعدل */
        !important;
    align-items: center !important;
    width: 100% !important;
    overflow: hidden !important;
}

.tawjihi-result-card .tawjihi-student-main .tawjihi-seat,
.tawjihi-result-card .tawjihi-student-main .tawjihi-branch,
.tawjihi-result-card .tawjihi-student-main .tawjihi-directorate,
.tawjihi-result-card .tawjihi-student-main .tawjihi-school {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: right !important;
    direction: rtl !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 14px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* رقم الجلوس واضح */
.tawjihi-result-card .tawjihi-student-main .tawjihi-seat {
    font-weight: 800 !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* الفرع يأخذ حقه وما ينخنق */
.tawjihi-result-card .tawjihi-student-main .tawjihi-branch {
    font-size: 18px !important;
    font-weight: 500 !important;
}

/* المديرية تأخذ حقها */
.tawjihi-result-card .tawjihi-student-main .tawjihi-directorate {
    font-size: 18px !important;
    font-weight: 500 !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* المدرسة أكبر عمود */
.tawjihi-result-card .tawjihi-student-main .tawjihi-school {
    font-size: 17px !important;
    font-weight: 500 !important;
}

/* المعدل فقط سنتر */
.tawjihi-result-card .tawjihi-student-main .tawjihi-average {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    direction: ltr !important;
    font-size: 29px !important;
    font-weight: 900 !important;
    padding: 0 8px !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* rank rows */
.tawjihi-result-card .item:not(.tawjihi-student-main) {
    display: grid !important;
    direction: rtl !important;
    grid-template-columns: 205px minmax(0, 1fr) !important;
    align-items: center !important;
}

.tawjihi-result-card .item:not(.tawjihi-student-main) .item-id,
.tawjihi-result-card .item:not(.tawjihi-student-main) .item-title {
    text-align: right !important;
    justify-content: flex-start !important;
    direction: rtl !important;
    white-space: nowrap !important;
    padding-right: 18px !important;
    padding-left: 10px !important;
}

/* medium screens */
@media (max-width: 1100px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns:
            145px
            165px
            165px
            minmax(270px, 1fr)
            86px
            !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-branch,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-directorate {
        font-size: 16px !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-school {
        font-size: 15px !important;
    }
}

/* mobile: vertical readable */
@media (max-width: 720px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns: 1fr !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-seat,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-branch,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-directorate,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-school {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        padding: 10px 14px !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-average {
        padding: 10px 14px !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) {
        grid-template-columns: 170px minmax(0, 1fr) !important;
    }
}

/* FINAL background correction:
   Student info row must be visually uniform.
   Seat number must NOT inherit old .item-id gray background.
*/
.tawjihi-result-card .tawjihi-student-main,
.tawjihi-result-card .tawjihi-student-main > div,
.tawjihi-result-card .tawjihi-student-main .tawjihi-seat,
.tawjihi-result-card .tawjihi-student-main .tawjihi-branch,
.tawjihi-result-card .tawjihi-student-main .tawjihi-directorate,
.tawjihi-result-card .tawjihi-student-main .tawjihi-school {
    background: #ffffff !important;
}

/* Seat number: same background as branch/directorate/school */
.tawjihi-result-card .tawjihi-student-main .tawjihi-seat {
    background-color: #ffffff !important;
    color: #000 !important;
}

/* Average only stays centered and visually strong */
.tawjihi-result-card .tawjihi-student-main .tawjihi-average {
    background: #ffffff !important;
    text-align: center !important;
    justify-content: center !important;
    color: #000 !important;
}

/* Keep separators soft and consistent inside the first row */
.tawjihi-result-card .tawjihi-student-main > div {
    border-left: 1px solid rgba(0,0,0,.07) !important;
}

.tawjihi-result-card .tawjihi-student-main > div:first-child {
    border-right: 0 !important;
}

.tawjihi-result-card .tawjihi-student-main > div:last-child {
    border-left: 0 !important;
}

/* Do not affect rank/status label cells */
.tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
    background: inherit;
}

/* FINAL RESTORE:
   Right-side first column background returns like original design.
   Other student data columns stay white.
   Average remains centered.
*/
.tawjihi-result-card {
    --tawjihi-label-bg: #f1f2f6;
    --tawjihi-cell-bg: #ffffff;
    --tawjihi-separator: rgba(0,0,0,.075);
}

/* Main student row grid */
.tawjihi-result-card .tawjihi-student-main {
    display: grid !important;
    direction: rtl !important;
    grid-template-columns:
        165px                 /* رقم الجلوس */
        190px                 /* الفرع */
        190px                 /* المديرية */
        minmax(390px, 1fr)    /* المدرسة */
        92px                  /* المعدل */
        !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    background: var(--tawjihi-cell-bg) !important;
}

/* Default student cells */
.tawjihi-result-card .tawjihi-student-main > div {
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    height: auto !important;
    line-height: 1.45 !important;
    padding: 0 14px !important;
    border-left: 1px solid var(--tawjihi-separator) !important;
    color: #000 !important;
}

/* رقم الجلوس: same gray background as labels column */
.tawjihi-result-card .tawjihi-student-main .tawjihi-seat {
    background: var(--tawjihi-label-bg) !important;
    justify-content: flex-start !important;
    text-align: right !important;
    direction: rtl !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-weight: 900 !important;
}

/* الفرع */
.tawjihi-result-card .tawjihi-student-main .tawjihi-branch {
    background: var(--tawjihi-cell-bg) !important;
    justify-content: flex-start !important;
    text-align: right !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 18px !important;
}

/* المديرية */
.tawjihi-result-card .tawjihi-student-main .tawjihi-directorate {
    background: var(--tawjihi-cell-bg) !important;
    justify-content: flex-start !important;
    text-align: right !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 18px !important;
}

/* المدرسة: largest space */
.tawjihi-result-card .tawjihi-student-main .tawjihi-school {
    background: var(--tawjihi-cell-bg) !important;
    justify-content: flex-start !important;
    text-align: right !important;
    direction: rtl !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 17px !important;
}

/* المعدل فقط سنتر */
.tawjihi-result-card .tawjihi-student-main .tawjihi-average {
    background: var(--tawjihi-cell-bg) !important;
    justify-content: center !important;
    text-align: center !important;
    direction: ltr !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 29px !important;
    font-weight: 900 !important;
    padding: 0 8px !important;
    border-left: 0 !important;
}

/* Rank/status rows: first/right label column gray */
.tawjihi-result-card .item:not(.tawjihi-student-main) {
    display: grid !important;
    direction: rtl !important;
    grid-template-columns: 205px minmax(0, 1fr) !important;
    align-items: stretch !important;
    background: var(--tawjihi-cell-bg) !important;
    overflow: hidden !important;
}

.tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
    background: var(--tawjihi-label-bg) !important;
    color: #000 !important;
    text-align: right !important;
    justify-content: flex-start !important;
    direction: rtl !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    min-width: 205px !important;
    padding-right: 18px !important;
    padding-left: 10px !important;
    box-sizing: border-box !important;
}

.tawjihi-result-card .item:not(.tawjihi-student-main) .item-title {
    background: var(--tawjihi-cell-bg) !important;
    color: #000 !important;
    text-align: right !important;
    justify-content: flex-start !important;
    direction: rtl !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    padding-right: 18px !important;
    padding-left: 10px !important;
    box-sizing: border-box !important;
}

/* Medium screens */
@media (max-width: 1100px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns:
            150px
            175px
            175px
            minmax(300px, 1fr)
            86px
            !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-branch,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-directorate {
        font-size: 16px !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-school {
        font-size: 15px !important;
    }
}

/* Mobile */
@media (max-width: 720px) {
    .tawjihi-result-card .tawjihi-student-main {
        grid-template-columns: 1fr !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-seat {
        background: var(--tawjihi-label-bg) !important;
    }

    .tawjihi-result-card .tawjihi-student-main .tawjihi-branch,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-directorate,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-school,
    .tawjihi-result-card .tawjihi-student-main .tawjihi-average {
        background: var(--tawjihi-cell-bg) !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        padding: 10px 14px !important;
        border-left: 0 !important;
        border-bottom: 1px solid var(--tawjihi-separator) !important;
    }

    .tawjihi-result-card .tawjihi-student-main > div:last-child {
        border-bottom: 0 !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) {
        grid-template-columns: 175px minmax(0, 1fr) !important;
    }

    .tawjihi-result-card .item:not(.tawjihi-student-main) .item-id {
        min-width: 175px !important;
    }
}
