
/* ==========================================================
   AI Page Summary – Standalone Arabic CSS
   Includes complete base styling, animations, responsive
   behavior, and Arabic RTL layout.
   Load this file only for Arabic pages.
   ========================================================== */

/* ---------- Arabic drawer ---------- */
.summary-popup {
    display: flex;
    flex-direction: row;
    position: fixed;
    right: -504px;
    left: auto;
    top: 190px;
    direction: ltr;
    transition: right 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

    .summary-popup.is-open {
        right: 0;
        left: auto;
    }

    .summary-popup::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(7, 28, 36, 0.62);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 400ms ease, visibility 400ms ease;
    }

    .summary-popup.is-open::before {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

/* ---------- Arabic tab button ---------- */
.summary-btn {
    position: relative;
    z-index: 2;
    display: inline-grid;
    grid-template-columns: 26px 0fr;
    align-items: center;
    gap: 0;
    height: 66px;
    padding: 12.5px 24px;
    border: 0;
    border-radius: 4px 0px 0px 4px;
    background: linear-gradient(-90deg, #5badc2 0%, #418397 100%), linear-gradient(0deg, #ffffff, #ffffff);
    color: white;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 6px 6px 22px rgba(3, 80, 105, 0.28);
    transition: grid-template-columns 500ms cubic-bezier(0.22, 1, 0.36, 1), gap 500ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 300ms ease;
}

    .summary-btn:focus-visible {
        outline: 3px solid #ffffff;
        outline-offset: -5px;
    }

.summary-popup.is-open .summary-btn {
    grid-template-columns: 26px 0fr;
    gap: 0;
    box-shadow: none;
}

    .summary-popup.is-open .summary-btn .text {
        opacity: 0;
    }

.summary-btn::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 55%;
    background: linear-gradient( 100deg, transparent 0%, rgba(255, 255, 255, 0.38) 50%, transparent 100% );
    transform: translateX(130%) skewX(18deg);
    pointer-events: none;
    animation: aiSweepAr 4.8s ease-in-out infinite 1.2s;
}

.summary-btn .icon {
    position: relative;
    width: 26px;
    height: 24px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

    .summary-btn .icon::before,
    .summary-btn .icon::after {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        width: 26px;
        height: 26px;
        margin: -13px 0 0 -13px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.7);
        opacity: 0;
        pointer-events: none;
        animation: aiRing 2.6s ease-out infinite;
    }

    .summary-btn .icon::after {
        animation-delay: 1.3s;
    }

    .summary-btn .icon svg {
        position: relative;
        z-index: 1;
        overflow: visible;
        animation: aiStarGlow 2.6s ease-in-out infinite;
    }

        .summary-btn .icon svg path {
            transform-box: fill-box;
            transform-origin: center;
        }

            .summary-btn .icon svg path:nth-of-type(1) {
                animation: aiBigStar 2.6s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
            }

            .summary-btn .icon svg path:nth-of-type(2) {
                animation: aiSmallStar 2.6s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite 0.4s;
            }

.summary-btn:hover .icon svg path:nth-of-type(1),
.summary-btn:focus-visible .icon svg path:nth-of-type(1),
.summary-btn:hover .icon svg path:nth-of-type(2),
.summary-btn:focus-visible .icon svg path:nth-of-type(2) {
    animation-duration: 1.2s;
}

.summary-btn:hover .icon::before,
.summary-btn:hover .icon::after {
    animation-duration: 1.3s;
}

.summary-popup.is-open .summary-btn::after,
.summary-popup.is-open .summary-btn .icon::before,
.summary-popup.is-open .summary-btn .icon::after {
    animation: none;
    opacity: 0;
}

.summary-btn .text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 250ms ease;
    color: #f2f8f7;
    text-align: right;
    direction: rtl;
}

    .summary-btn .text b {
        text-transform: uppercase;
        display: block;
        font-family: Cairo;
    }

.summary-btn:hover {
    grid-template-columns: 26px max-content;
    gap: 16px;
}

    .summary-btn:hover .text {
        opacity: 1;
    }

/* ---------- Arabic summary panel ---------- */
.summary-content {
    --ai-accent: #418397;
    --ai-accent-dark: #0b6f92;
    --ai-teal: #5aacc1;
    --ai-text: #262425;
    --ai-muted: #667a82;
    --ai-surface: #eef7fa;
    --ai-border: #d5e8ee;
    display: flex;
    flex-direction: column;
    direction: rtl;
    text-align: right;
    width: 504px;
    padding: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 50%, rgba(3, 151, 201, 0.1) 100%), linear-gradient(0deg, #ffffff, #ffffff);
    border-width: 1px 1px 1px 0;
    border-style: solid;
    border-color: var(--ai-teal);
    box-shadow: 16px 0 48px rgba(3, 60, 80, 0.22);
    position: relative;
    z-index: 2;
    height: fit-content;
    overflow: hidden;
    max-height: calc(100vh - 182px);
    color: var(--ai-text);
}

    .summary-content::before {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
        height: 3px;
        background: linear-gradient(90deg, #5badc2, #418397, #7fd1e6, #418397, #5badc2);
        background-size: 200% 100%;
        animation: aiBar 4s linear infinite;
    }

    .summary-content .head {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 16px 32px 13px;
        border-bottom: 1px solid var(--ai-border);
        direction: rtl;
    }

        .summary-content .head h4 {
            margin: 0;
            color: var(--ai-accent);
            font-family: 'Cairo';
            font-weight: 700;
            font-size: 18px;
            line-height: normal;
            letter-spacing: normal;
            text-transform: none;
            text-align: right;
        }

        .summary-content .head .btn-close {
            display: grid;
            place-items: center;
            flex: none;
            width: 36px;
            height: 36px;
            padding: 0;
            border: 0;
            border-radius: 50%;
            background: none;
            opacity: 1;
            cursor: pointer;
            transition: background-color 150ms ease;
        }

            .summary-content .head .btn-close:hover {
                background: var(--ai-surface);
                opacity: 1;
            }

            .summary-content .head .btn-close:focus,
            .summary-content .head .btn-close:focus-visible {
                outline: 3px solid rgba(3, 151, 201, 0.45);
                outline-offset: 1px;
                box-shadow: none;
            }

/* ---------- Loader ---------- */
#pageSummaryLoader {
    flex: none;
    padding: 28px 32px 32px;
    text-align: center;
    direction: rtl;
}

    #pageSummaryLoader .spinner-border {
        display: inline-block;
        width: 30px;
        height: 30px;
        border: 3px solid var(--ai-border);
        border-top-color: var(--ai-accent);
        border-radius: 50%;
        animation: aiSpin 0.8s linear infinite;
    }

    #pageSummaryLoader p {
        margin: 12px 0 18px;
        font-family: "DIN", Arial, sans-serif;
        font-weight: 500;
        font-size: 17px;
        line-height: 1.7;
        background: linear-gradient(90deg, var(--ai-muted) 30%, var(--ai-accent) 50%, var(--ai-muted) 70%);
        background-size: 200% 100%;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        animation: aiTextShimmer 1.6s linear infinite;
    }

    #pageSummaryLoader .ai-skel {
        display: grid;
        gap: 12px;
        text-align: right;
    }

        #pageSummaryLoader .ai-skel i {
            display: block;
            height: 14px;
            border-radius: 7px;
            background: linear-gradient(90deg, #e3f0f5 25%, #f5fafc 50%, #e3f0f5 75%);
            background-size: 200% 100%;
            animation: aiShimmer 1.3s infinite;
        }

            #pageSummaryLoader .ai-skel i:nth-child(1) {
                width: 94%;
            }

            #pageSummaryLoader .ai-skel i:nth-child(2) {
                width: 100%;
            }

            #pageSummaryLoader .ai-skel i:nth-child(3) {
                width: 82%;
            }

            #pageSummaryLoader .ai-skel i:nth-child(4) {
                width: 90%;
            }

/* ---------- Summary body ---------- */
#pageSummaryContent {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 32px 28px;
    scrollbar-width: thin;
    scrollbar-color: var(--ai-teal) transparent;
    font-family: "DIN", Arial, sans-serif;
    color: var(--ai-text);
    direction: rtl;
    text-align: right;
    line-height: 1.8;
    unicode-bidi: plaintext;
}

    #pageSummaryContent.is-formatted {
        animation: aiFadeUp 450ms ease both;
    }

    #pageSummaryContent::-webkit-scrollbar {
        width: 8px;
    }

    #pageSummaryContent::-webkit-scrollbar-thumb {
        background: var(--ai-teal);
        border-radius: 8px;
    }

    #pageSummaryContent p,
    #pageSummaryContent li {
        margin: 0;
        color: var(--ai-text);
        direction: rtl;
        text-align: right;
        line-height: 1.8;
        unicode-bidi: plaintext;
        font-family: 'Cairo';
    }

        #pageSummaryContent p + p {
            margin-top: 12px;
        }

    #pageSummaryContent strong {
        font-weight: 700;
    }

    #pageSummaryContent h5 {
        margin: 22px 0 8px;
        color: var(--ai-accent-dark);
        font-family: "DIN", Arial, sans-serif;
        font-weight: 700;
        line-height: 1.6;
        letter-spacing: normal;
        text-align: right;
    }

    #pageSummaryContent .ai-lead {
        margin: 0 0 22px;
        padding: 16px 18px;
        background: var(--ai-surface);
        border-right: 4px solid var(--ai-accent);
        border-left: 0;
        border-radius: 4px;
    }

        #pageSummaryContent .ai-lead p {
            text-align: right;
        }

    #pageSummaryContent .ai-label {
        display: block;
        margin-bottom: 8px;
        font-family: 'Cairo';
        font-weight: 700;
        line-height: 1.6;
        letter-spacing: normal;
        text-transform: none;
        color: var(--ai-accent);
        text-align: right;
    }

    #pageSummaryContent .ai-points {
        list-style: none;
        margin: 0;
        padding: 0;
        display: grid;
        gap: 14px;
    }

        #pageSummaryContent .ai-points li {
            position: relative;
            padding-right: 28px;
            padding-left: 0;
            opacity: 0;
            animation: aiFadeUp 450ms ease forwards;
            animation-delay: calc(var(--i, 0) * 80ms + 150ms);
        }

            #pageSummaryContent .ai-points li::before {
                content: "";
                position: absolute;
                right: 2px;
                left: auto;
                top: 0.75em;
                width: 10px;
                height: 10px;
                border-radius: 50%;
                background: linear-gradient(135deg, #7fd1e6, #418397);
                box-shadow: 0 0 0 4px rgba(3, 151, 201, 0.14);
            }

    #pageSummaryContent mark {
        padding: 1px 6px;
        border-radius: 4px;
        background: rgba(3, 151, 201, 0.14);
        color: var(--ai-accent-dark);
        font-weight: 700;
    }

    #pageSummaryContent .ai-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        margin-top: 26px;
        padding-top: 16px;
        border-top: 1px solid var(--ai-border);
        direction: rtl;
    }

    #pageSummaryContent .ai-note {
        flex: 1 1 100%;
        margin: 0 0 2px;
        font-size: 13px;
        line-height: 1.8;
        color: var(--ai-muted);
        text-align: right;
    }

    #pageSummaryContent .ai-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 16px;
        border: 1px solid var(--ai-teal);
        border-radius: 4px;
        background: #ffffff;
        color: var(--ai-accent-dark);
        font-family: "DIN", Arial, sans-serif;
        font-weight: 700;
        line-height: 1.6;
        letter-spacing: normal;
        text-transform: none;
        cursor: pointer;
        transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
    }

        #pageSummaryContent .ai-btn:hover {
            background: var(--ai-accent);
            border-color: var(--ai-accent);
            color: #ffffff;
        }

        #pageSummaryContent .ai-btn:focus-visible {
            outline: 3px solid rgba(3, 151, 201, 0.45);
            outline-offset: 2px;
        }

    #pageSummaryContent .ai-error {
        padding: 16px 18px;
        background: #fff5f3;
        border-right: 4px solid #d9534f;
        border-left: 0;
        border-radius: 4px;
        text-align: right;
    }

        #pageSummaryContent .ai-error .ai-label {
            color: #b8403c;
        }

/* ---------- Animations ---------- */
@keyframes aiBigStar {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }

    35% {
        transform: scale(1.18) rotate(18deg);
    }

    70% {
        transform: scale(0.92) rotate(-8deg);
    }
}

@keyframes aiSmallStar {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    30% {
        transform: scale(0.2) rotate(-90deg);
        opacity: 0;
    }

    55% {
        transform: scale(1.45) rotate(0deg);
        opacity: 1;
    }

    80% {
        transform: scale(0.95) rotate(10deg);
        opacity: 1;
    }
}

@keyframes aiStarGlow {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
    }

    40% {
        filter: drop-shadow(0 0 7px rgba(255, 255, 255, 1)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
    }
}

@keyframes aiRing {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }

    100% {
        transform: scale(2.3);
        opacity: 0;
    }
}

@keyframes aiSweepAr {
    0%, 55% {
        transform: translateX(130%) skewX(18deg);
    }

    100% {
        transform: translateX(-260%) skewX(18deg);
    }
}

@keyframes aiBar {
    to {
        background-position: 200% 0;
    }
}

@keyframes aiSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes aiTextShimmer {
    to {
        background-position: -200% 0;
    }
}

@keyframes aiShimmer {
    to {
        background-position: -200% 0;
    }
}

@keyframes aiFadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .summary-popup {
        top: 92px;
    }

    .summary-content {
        max-height: calc(100vh - 102px);
    }

        .summary-content .head {
            padding: 15px 24px 14px;
        }

    #pageSummaryContent {
        padding: 20px 24px 24px;
    }

        #pageSummaryContent p,
        #pageSummaryContent li {
            font-size: 17px;
        }

        #pageSummaryContent h5 {
            margin: 18px 0 6px;
            font-size: 18px;
        }

    #pageSummaryLoader {
        padding: 22px 24px 28px;
    }
}

@media (max-width: 767.98px) {
    .summary-content {
        width: 474px;
    }

    .summary-popup {
        right: -474px;
        left: auto;
    }
}

@media (max-width: 575.98px) {
    .summary-popup {
        right: calc(-1 * (100vw - 68px));
        left: auto;
    }

        .summary-popup.is-open {
            right: 0;
            left: auto;
        }

    .summary-btn:hover {
        gap: 12px;
        max-width: 95vw;
        grid-template-columns: 26px minmax(0, 1fr);
    }

        .summary-btn:hover .text {
            opacity: 1;
            width: auto;
            white-space: normal;
        }

    .summary-btn {
        height: fit-content;
        padding: 10.5px 16px;
    }

    .summary-popup.is-open .summary-btn {
        height: 63px;
    }

    .summary-content {
        width: calc(100vw - 68px);
        max-width: 100vw;
        box-sizing: border-box;
    }

        .summary-content .head {
            padding: 13px 18px 12px;
        }

    #pageSummaryContent {
        padding: 16px 18px 20px;
    }

        #pageSummaryContent p,
        #pageSummaryContent li {
            font-size: 16px;
        }

    #pageSummaryLoader {
        padding: 18px 18px 24px;
    }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    .summary-btn::after,
    .summary-btn .icon::before,
    .summary-btn .icon::after,
    .summary-btn .icon svg,
    .summary-btn .icon svg path,
    .summary-content::before,
    #pageSummaryLoader .spinner-border,
    #pageSummaryLoader p,
    #pageSummaryLoader .ai-skel i,
    #pageSummaryContent.is-formatted,
    #pageSummaryContent .ai-points li {
        animation: none !important;
    }

    #pageSummaryContent .ai-points li {
        opacity: 1;
    }
}

#pageSummaryPopup,
#pageSummaryPopup * {
    caret-color: transparent !important;
	z-index:99999;
}