/* =========================================================
   LWFG Magazine Reader
   ========================================================= */

.magazine-reader-page {
    width: 100%;
    min-height: calc(100vh - 120px);
    background: #f3f4f6;
    padding: 30px 20px 50px;
    box-sizing: border-box;
}


/* =========================================================
   Header
   ========================================================= */

.magazine-reader-page__header {
    width: min(1200px, 100%);
    margin: 0 auto 22px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;

    padding: 16px 20px;

    box-sizing: border-box;
}


.magazine-reader-page__title {
    display: flex;
    flex-direction: column;
    gap: 4px;

    min-width: 0;
}


.magazine-reader-page__title strong {
    color: #111827;

    font-size: 17px;
    font-weight: 700;

    line-height: 1.5;
}


.magazine-reader-page__title span {
    color: #6b7280;

    font-size: 13px;
    font-weight: 500;
}


.magazine-reader-page__back {
    flex-shrink: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 38px;
    padding: 0 15px;

    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 9px;

    color: #FB0000;

    font-size: 13px;
    font-weight: 600;

    text-decoration: none;

    transition:
        background .2s ease,
        border-color .2s ease,
        color .2s ease;
}


.magazine-reader-page__back:hover {
    background: #FB0000;
  
    color: #ffffff;
}


/* =========================================================
   Reader
   ========================================================= */

.magazine-reader {
    width: min(1200px, 100%);
    margin: 0 auto;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 16px;

    overflow: hidden;

    box-shadow:
        0 8px 30px rgba(15, 23, 42, .07);
}


/* =========================================================
   Toolbar
   ========================================================= */

.magazine-reader__toolbar {
    min-height: 62px;

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

    gap: 8px;

    padding: 10px 14px;

    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;

    box-sizing: border-box;

    direction: rtl;
}


.magazine-reader__toolbar button {
    appearance: none;

    min-width: 42px;
    height: 40px;

    padding: 0 12px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid #d1d5db;
    border-radius: 9px;

    background: #ffffff;

    color: #374151;

    font-family: inherit;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background .18s ease,
        border-color .18s ease,
        color .18s ease,
        transform .18s ease;
}


.magazine-reader__toolbar button:hover:not(:disabled) {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}


.magazine-reader__toolbar button:active:not(:disabled) {
    transform: scale(.96);
}


.magazine-reader__toolbar button:disabled {
    opacity: .4;
    cursor: not-allowed;
}


/* =========================================================
   Page Counter
   ========================================================= */

.magazine-reader__page {
    min-width: 70px;
    height: 40px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 10px;

    background: #f9fafb;

    border: 1px solid #e5e7eb;
    border-radius: 9px;

    color: #374151;

    font-size: 13px;
    font-weight: 600;

    direction: ltr;
}


#magazine-page-current {
    color: #166534;
    font-weight: 700;
}


#magazine-page-total {
    color: #6b7280;
}


/* =========================================================
   Special buttons
   ========================================================= */

#magazine-zoom-out,
#magazine-zoom-in,
#magazine-fullscreen {
    font-size: 18px;
    font-weight: 500;

    padding: 0;
}


#magazine-fullscreen {
    margin-right: 4px;
}


/* =========================================================
   Reader Stage
   ========================================================= */

.magazine-reader__stage {
    position: relative;
    width: 100%;
    min-height: 650px;

    display: flex;
    align-items: flex-start;
    justify-content: center;

    padding: 0 28px;

    background: #e5e7eb;
    box-sizing: border-box;
    overflow: auto;

    /* إخفاء الـScrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.magazine-reader__stage::-webkit-scrollbar {
    display: none;
}


/* =========================================================
   PDF Canvas
   ========================================================= */

#magazine-reader-canvas {
    display: block;

    max-width: none;

    background: #ffffff;

    border-radius: 2px;

    box-shadow:
        0 8px 25px rgba(15, 23, 42, .18);

    margin: 0 auto;
}


/* =========================================================
   Loading
   ========================================================= */

.magazine-reader__loading {
    position: absolute;

    top: 50%;
    left: 50%;

    transform: translate(-50%, -50%);

    z-index: 10;

    padding: 12px 18px;

    background: rgba(17, 24, 39, .92);

    border-radius: 10px;

    color: #ffffff;

    font-size: 13px;
    font-weight: 500;

    white-space: nowrap;

    box-shadow:
        0 8px 25px rgba(0, 0, 0, .15);
}


.magazine-reader__loading::before {
    content: '';

    display: inline-block;

    width: 14px;
    height: 14px;

    margin-left: 8px;

    vertical-align: -2px;

    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #ffffff;

    border-radius: 50%;

    animation: magazine-reader-spin .7s linear infinite;
}


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


/* =========================================================
   Error
   ========================================================= */

.magazine-reader__error {
    width: min(500px, calc(100% - 40px));

    margin: 40px auto;

    padding: 18px 20px;

    background: #fef2f2;

    border: 1px solid #fecaca;
    border-radius: 12px;

    color: #991b1b;

    text-align: center;

    font-size: 14px;
    line-height: 1.7;

    box-sizing: border-box;
}


/* =========================================================
   Fullscreen
   ========================================================= */

.magazine-reader-page:fullscreen {
    width: 100%;
    height: 100%;

    padding: 0;

    background: #111827;
}


.magazine-reader-page:fullscreen .magazine-reader-page__header {
    display: none;
}


.magazine-reader-page:fullscreen .magazine-reader {
    width: 100%;
    height: 100%;

    border: 0;
    border-radius: 0;

    box-shadow: none;
}


.magazine-reader-page:fullscreen .magazine-reader__stage {
    height: calc(100vh - 62px);
    min-height: 0;

    background: #111827;

    padding: 30px;
}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 768px) {

    .magazine-reader-page {
        padding: 15px 10px 30px;
    }


    .magazine-reader-page__header {
        align-items: stretch;

        flex-direction: column;

        padding: 14px;

        border-radius: 12px;
    }


    .magazine-reader-page__back {
        width: 100%;
    }


    .magazine-reader {
        border-radius: 12px;
    }


    .magazine-reader__toolbar {
        justify-content: center;

        gap: 5px;

        padding: 8px;
    }


    .magazine-reader__toolbar button {
        min-width: 38px;
        height: 38px;

        padding: 0 8px;

        font-size: 12px;
    }


    .magazine-reader__page {
        min-width: 58px;
        height: 38px;

        padding: 0 6px;
    }


 .magazine-reader__stage {
    min-height: 500px;
   padding: 0 8px 0;
}


    #magazine-reader-canvas {
        max-width: none;
    }

}


/* =========================================================
   Very Small Screens
   ========================================================= */

@media (max-width: 480px) {

    .magazine-reader-page__title strong {
        font-size: 15px;
    }


    .magazine-reader__toolbar {
        flex-wrap: wrap;
    }


    .magazine-reader__stage {
        padding: 10px 4px;
    }

}

.magazine-reader-page__back {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.magazine-reader-page__back:hover {
    background: #b91c1c;
    color: #fff;
    border-color: #b91c1c;
}

/* إخفاء شريط التمرير مع إبقاء التمرير فعالًا */
.magazine-reader__stage {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.magazine-reader__stage::-webkit-scrollbar {
    display: none;
}

/* =========================================================
   مجلات أخرى
   ========================================================= */

.magazine-other {
    margin-top: 28px;
    margin-bottom: 28px;
}

.magazine-other__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.magazine-other__header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.magazine-other__all {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    font-size: 14px;
    font-weight: 600;
    color: #00843d;

    text-decoration: none;

    transition:
        color 0.2s ease,
        gap 0.2s ease;
}

.magazine-other__all:hover {
    color: #006b31;
    gap: 10px;
}

.magazine-other__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.magazine-other__card {
    overflow: hidden;

    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;



    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.magazine-other__card:hover {
    transform: translateY(-3px);
   
}


/* الغلاف */

.magazine-other__cover {
    display: block;

    aspect-ratio: 16 / 10;

    overflow: hidden;

    background: #f3f4f6;
}

.magazine-other__cover img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    transition: transform 0.3s ease;
}

.magazine-other__card:hover .magazine-other__cover img {
    transform: scale(1.025);
}

.magazine-other__no-cover {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    background: #006b35;

    color: #ffffff;

    font-size: 18px;
    font-weight: 700;
}


/* المحتوى */

.magazine-other__content {
    padding: 15px;
}

.magazine-other__issue {
    display: inline-block;

    margin-bottom: 7px;

    font-size: 13px;
    font-weight: 700;

    color: #00843d;
}

.magazine-other__title {
    margin: 0 0 7px;

    font-size: 17px;
    line-height: 1.5;
    font-weight: 700;
}

.magazine-other__title a {
    color: #111827;
    text-decoration: none;
}

.magazine-other__title a:hover {
    color: #00843d;
}

.magazine-other__season {
    margin-bottom: 13px;

    font-size: 13px;
    color: #6b7280;
}


/* زر القراءة */

.magazine-other__read {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 38px;
    padding: 0 14px;

    border-radius: 8px;

    background: #00843d;
    color: #ffffff;

    font-size: 13px;
    font-weight: 700;

    text-decoration: none;

    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.magazine-other__read:hover {
    background: #006b31;
    color: #ffffff;
    transform: translateY(-1px);
}

@media (max-width: 768px) {

    .magazine-other {
        margin-top: 24px;
    }

    .magazine-other__header {
        align-items: center;
    }

    .magazine-other__header h2 {
        font-size: 18px;
    }

    .magazine-other__all {
        font-size: 13px;
    }

    .magazine-other__grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .magazine-other__card {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }

    .magazine-other__cover {
        flex: 0 0 130px;
        aspect-ratio: auto;
        min-height: 165px;
    }

    .magazine-other__content {
        display: flex;
        flex-direction: column;
        justify-content: center;

        min-width: 0;
        padding: 13px;
    }

    .magazine-other__title {
        font-size: 15px;
    }

    .magazine-other__season {
        font-size: 12px;
        margin-bottom: 10px;
    }

    .magazine-other__read {
        align-self: flex-start;
        min-height: 35px;
        padding: 0 12px;
        font-size: 12px;
    }
}

/* =========================================================
   مجلات أخرى — نفس عرض بطاقة المجلة
   ========================================================= */

.magazine-other {
    width: 100%;
    max-width: 1000px;

    margin: 20px auto 0;
    padding: 0;

    box-sizing: border-box;
}

.magazine-other__grid {
    width: 100%;
    max-width: 100%;

    box-sizing: border-box;
}

/* زر جميع الأعداد */
.magazine-other__all {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    padding: 9px 15px;

    background: #dc2626;
    border: 1px solid #dc2626;
    border-radius: 10px;

    color: #ffffff;
    font-size: 14px;
    font-weight: 600;

    text-decoration: none;
    transition: all 0.2s ease;
}

.magazine-other__all:hover {
    background: #00a651;
    border-color: #00a651;
    color: #ffffff;
}

.magazine-other__card {
    display: flex;
    flex-direction: column;
}

.magazine-other__content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.magazine-other__read {
    margin-top: auto;
}

/* =========================================================
   مجلات أخرى — تصميم الهاتف
   ========================================================= */

@media (max-width: 767px) {

    .magazine-other__grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .magazine-other__card {
        display: flex;
        flex-direction: row;
        align-items: stretch;

        min-height: 150px;
        overflow: hidden;
    }

    /* الغلاف — جهة اليمين */
    .magazine-other__cover {
        flex: 0 0 38%;
        width: 38%;
        aspect-ratio: auto;
    }

    .magazine-other__cover img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* المعلومات — جهة اليسار */
    .magazine-other__content {
        flex: 1;
        min-width: 0;

        display: flex;
        flex-direction: column;

        padding: 14px 12px;
        text-align: right;
    }

    .magazine-other__issue {
        margin-bottom: 6px;
    }

    .magazine-other__title {
        margin: 0 0 6px;
        font-size: 15px;
        line-height: 1.5;
    }

    .magazine-other__season {
        font-size: 12px;
        line-height: 1.5;
    }

    .magazine-other__read {
        margin-top: auto;
        align-self: flex-start;

        padding: 8px 13px;
        font-size: 13px;
    }
}

@media (max-width: 768px) {

    /* مسافة جانبية للمجلة الرئيسية */
    .magazine-reader {
        width: calc(100% - 2px);
        margin-left: auto;
        margin-right: auto;
    }

    /* مسافة جانبية لقسم مجلات أخرى */
    .magazine-other {
        width: calc(100% - 40px);
        margin-left: auto;
        margin-right: auto;
    }

}

/* إزالة الكارد الأبيض من صفحة المجلة */
.magazine-single-card {
    background: transparent;
    border: none;
    box-shadow: none;
}

/* تثبيت بطاقات مجلات أخرى */
.magazine-other__card {
    transform: none !important;
    transition: none !important;
}

/* إلغاء الحركة والـ shadow عند تمرير الماوس */
.magazine-other__card:hover {
    transform: none !important;
    box-shadow: none !important;
}

.magazine-reader-page__meta {
    display: flex;
    align-items: center;
   justify-content: flex-start;
    gap: 4px;
    margin-top: 8px;

    font-size: 13px;
    color: #6b7280;
    flex-wrap: wrap;
}

.magazine-reader-page__meta span {
    white-space: nowrap;
}

.magazine-reader-page__meta span:not(:last-child)::after {
    content: " — ";
   
}