:root {
    --cert-navy: #193247;
    --cert-teal: #125761;
    --cert-line: #e5d7ca;
    --cert-paper: rgba(255, 255, 255);
}

.certificate-result {
    box-sizing: border-box;
    position: relative;
    width: 100%;
    min-height: 888px;
    padding: 22px 4.5% 28px;
    color: var(--cert-navy);
}

.certificate-result__topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    direction: rtl;
    min-height: 104px;
}

.certificate-language { width: 232px; }
.certificate-language label {
    display: block;
    margin: 0 0 7px;
    color: #595959;
    font-size: 12px;
    line-height: 17px;
}

.certificate-language__select {
    position: relative;
    z-index: 20;
    direction: rtl;
}

.certificate-language__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 49px;
    padding: 0 16px 0 19px;
    border: 1px solid #eadfd5;
    border-radius: 2px;
    background: #FFFFFF;
    outline: none;
    color: var(--cert-navy);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    text-align: right;
    cursor: pointer;
}

.certificate-language__trigger:hover { border-color: #9dbfc2; }
.certificate-language__trigger:focus-visible {
    border-color: var(--cert-teal);
    box-shadow: 0 0 0 1px var(--cert-teal);
}

.certificate-language__select.is-open .certificate-language__trigger {
    border-color: var(--cert-teal);
}

.certificate-language__trigger svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: var(--cert-teal);
    stroke-width: 1.8;
    transition: transform 180ms ease;
}

.certificate-language__select.is-open .certificate-language__trigger svg { transform: rotate(180deg); }

.certificate-language__menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 7px);
    right: 0;
    left: 0;
    overflow: hidden;
    border: 1px solid #eadfd5;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(25, 50, 71, .08);
}

.certificate-language__menu[hidden] { display: none; }

.certificate-language__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    padding: 0 16px 0 18px;
    border: 0;
    background: #fff;
    color: var(--cert-navy);
    font-family: inherit;
    font-size: 15px;
    font-weight: 400;
    text-align: right;
    cursor: pointer;
}

.certificate-language__option:hover,
.certificate-language__option:focus-visible { background: #f2f7f7; outline: none; }
    .certificate-language__option.is-selected {
        background: #E7F1EF;
        font-weight: 700;
    }

.certificate-language__option svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: var(--cert-teal);
    stroke-width: 1.5;
    opacity: 0;
}

.certificate-language__option.is-selected svg { opacity: 1; }

.certificate-new-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 232px;
    height: 49px;
    margin-top: 24px;
    padding: 0 23px;
    border: 1px solid var(--cert-teal);
    border-radius: 4px;
    background: transparent;
    color: #222;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.certificate-new-search:hover {
    border-color: #00747c;
    background: #fff;
    color: #125761;
}

.certificate-new-search:active,
.certificate-new-search:focus-visible {
    border-color: #00747c;
    background: #e8f5f4;
    color: #125761;
    outline: none;
}

.certificate-new-search:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 116, 124, .18);
}

.certificate-new-search svg,
.certificate-pagination svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.certificate-book-shell {
    position: relative;
    width: 100%;
}

.certificate-book-stage {
    position: relative;
    width: min(1082px, 100%);
    height: 650px;
    margin: 0 auto;
    transform: scaleX(-1);
}

.certificate-book-stage::after {
    position: absolute;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: #08717a;
    content: "";
    pointer-events: none;
    transform: translateX(-50%);
}

.certificate-book {
    width: 100%;
    height: 650px;
    margin: 0 auto;
    cursor: default;
    touch-action: pan-y;
}

.certificate-book.can-drag-page { cursor: grab; }
.certificate-book.is-page-dragging,
.certificate-book.is-page-dragging * {
    cursor: grabbing !important;
    user-select: none;
}

.certificate-flip-page {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: rgba(252, 250, 248, 0.7);
    padding: 32px;
}

.certificate-page-content {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    transform: scaleX(-1);
}

.certificate-page-content--left { padding-right: 40px; }
.certificate-page-content--right { padding-left: 40px; }

.certificate-page__visual,
.certificate-page__details,
.certificate-column { min-width: 0; direction: rtl; }
.certificate-page__visual { display: flex; align-items: center; justify-content: center; }

.certificate-image {
    display: flex;
    width: min(365px, 100%);
    height: 500px;
    padding: 0;
    border: 0;
    background: transparent;
}

.certificate-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(25,50,71,.16));
}

.certificate-title { color: var(--cert-teal); text-align: right; }
.certificate-title--boxed {
    min-height: 120px;
    margin: 24px 0 2px;
    padding: 34px 20px 22px;
    border: 1px solid var(--cert-line);
    border-radius: 4px;
    background: var(--cert-paper);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.certificate-title h1,
.certificate-title h2 { margin: 0; font-size: 20px; line-height: 1.7; font-weight: 800; }
.certificate-title p { margin: 10px 0 0; font-size: 15px; line-height: 1.65; font-weight: 700; direction: ltr; text-align: center;}
.certificate-title p[dir="rtl"] { direction: rtl; text-align: right; }
.certificate-fields { display: grid; gap: 2px; }

.certificate-field {
    min-height: 70px;
    padding: 4px 8px 2px;
    border: 1px solid var(--cert-line);
    border-radius: 4px;
    background: var(--cert-paper);
    overflow: hidden;
}

    .certificate-field p {
        margin: 0;
        font-size: 12px;
        line-height: 26px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-bottom: 2px;
    }
.certificate-field__fa { padding-inline: 2px; border-bottom: 1px solid var(--cert-line); text-align: right; }
.certificate-field__en {
    color: #3f4650;
    text-align: left;
    padding-top: 4px;
}
.certificate-field__en[dir="rtl"] { text-align: left; }
.certificate-field__en[dir="ltr"],
.certificate-title p[dir="ltr"] { font-family: Arial, sans-serif; }
.certificate-field strong { font-weight: 700; color: var(--cert-navy); }
.certificate-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: calc(100% - 82px);
    color: var(--cert-navy);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--cert-teal) 55%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    vertical-align: middle;
    transition: color 160ms ease, text-decoration-color 160ms ease;
}
.certificate-profile-link strong {
    overflow: hidden;
    text-overflow: ellipsis;
}
.certificate-profile-link svg {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.certificate-profile-link:hover {
    color: var(--cert-teal);
    text-decoration-color: currentColor;
}
.certificate-profile-link:focus-visible {
    border-radius: 2px;
    outline: 2px solid var(--cert-teal);
    outline-offset: 2px;
}
.certificate-page__details .certificate-field { min-height: 60px; }
.certificate-column .certificate-title {
    width: 63%;
    min-width: 300px;
    margin: 25px 0 17px auto;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--cert-teal);
    padding: 0 !important;
}
.certificate-column .certificate-title h2 { font-size: 17px; }
.certificate-column .certificate-title p { margin-top: 2px; font-size: 15px; }
.certificate-column .certificate-field { min-height: 70px; }

.certificate-description-page .certificate-title { margin-bottom: 22px; }
.certificate-description {
    height: 470px;
    padding: 20px 22px;
    border: 1px solid var(--cert-line);
    border-radius: 4px;
    background: var(--cert-paper);
    color: var(--cert-navy);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--cert-teal) transparent;
    scrollbar-width: thin;
}
.certificate-description h3 {
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--cert-line);
    font-size: 15px;
    font-weight: 800;
    text-align: start;
}
.certificate-description p {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    line-height: 2.15;
    text-align: justify;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.certificate-description[dir="ltr"] { font-family: Arial, sans-serif; }
.certificate-description::-webkit-scrollbar { width: 6px; }
.certificate-description::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--cert-teal);
}

.certificate-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    margin-top: 33px;
    direction: ltr;
}

    .certificate-pagination button {
        display: flex;
        align-items: center;
        gap: 14px;
        width: max-content;
        padding: 0 20px;
        border: 0;
        background: transparent;
        color: var(--cert-teal);
        font-size: 14px;
        font-weight: 700;
        flex-direction: row-reverse;
    }
.certificate-pagination button:last-child { justify-self: end; }
.certificate-pagination button {
    transition: opacity .18s ease, background-color .18s ease, border-color .18s ease;
}
.certificate-pagination button:disabled {
    visibility: visible;
    opacity: .3;
    pointer-events: none;
}
.certificate-pagination output { color: var(--cert-teal); font-size: 14px; direction: ltr; }
.certificate-pagination output b { font-weight: 500; }

.toolsCert {
    position: fixed;
    z-index: 20;
    top: 38%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px;
    border: 1px solid rgba(7,91,100,.18);
    border-radius: 8px;
    background: rgba(255,255,255,.91);
    height: fit-content !important;
    right: 14px;
    left: auto;
}
html[dir="ltr"] .toolsCert { right: auto; left: 14px; }
.toolsCert button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 8px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--cert-teal);
}
.toolsCert button:hover { background: #edf5f4; }
.toolsCert svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.toolsCert__message { position: absolute; top: calc(100% + 7px); right: 0; width: max-content; max-width: 200px; padding: 5px 8px; border-radius: 4px; background: var(--cert-navy); color: #fff; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toolsCert__message.is-visible { opacity: 1; }
.toolsCert-toggle { display: none; }
.toolsCert-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.certificate-gallery,
.certificate-qr {
    width: min(900px, calc(100vw - 32px));
    max-width: none;
    padding: 42px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    color: var(--cert-navy);
}
.certificate-gallery::backdrop,
.certificate-qr::backdrop { background: rgba(13,31,46,.78); }
.certificate-gallery { height: min(820px, calc(100vh - 40px)); }
.certificate-gallery img { width: 100%; height: 100%; object-fit: contain; }
.certificate-dialog__close { position: absolute; z-index: 2; top: 8px; right: 12px; width: 34px; height: 34px; border: 0; background: transparent; color: var(--cert-navy); font-size: 30px; line-height: 1; }
.certificate-gallery__arrow { position: absolute; z-index: 2; top: 50%; width: 40px; height: 52px; border: 0; border-radius: 4px; background: rgba(25,50,71,.82); color: #fff; font-size: 34px; }
.certificate-gallery__arrow--previous { left: 10px; }
.certificate-gallery__arrow--next { right: 10px; }
.certificate-qr { width: min(520px, calc(100vw - 32px)); text-align: center; }
.certificate-qr h2 { font-size: 18px; }

@media (max-width: 900px) {
    .certificate-result { min-height: auto; padding: 20px 20px 28px; }
    .certificate-result__topbar { gap: 16px; min-height: 100px; }
    .certificate-book-stage { width: min(541px, 100%); }
    .certificate-book-stage::after { display: none; }
    .certificate-page-content--left,
    .certificate-page-content--right { padding-inline: 20px; }
    .certificate-image { height: min(70vh, 560px); }
    .certificate-column .certificate-title { width: 80%; }
    .certificate-pagination { margin-top: 28px; }
    html[dir] .toolsCert {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        width: max-content;
        margin: -12px auto 16px;
        transform: none;
        flex-direction: row;
    }
    .toolsCert button { width: 44px; height: 44px; padding: 11px; touch-action: manipulation; }

}

@media (max-width: 560px) {
    .certificate-result { padding: 16px 14px 82px; }
    .certificate-book-shell { width: min(360px, 100%); margin-inline: auto; }
    .certificate-book-stage {
        width: 100%;
        height: clamp(560px, calc((100vw - 28px) * 2), 720px);
        transform: none;
    }
    .certificate-book { height: 100%; }
    .certificate-flip-page { padding: 0; }
    .certificate-page-content { transform: none; }
    .certificate-result__topbar { align-items: flex-end; min-height: 0; margin-bottom: 26px; }
    .certificate-language { width: calc(50% - 6px); }
    .certificate-new-search { width: calc(50% - 6px); height: 46px; margin: 0; padding: 0 10px; font-size: 12px; }
    .certificate-language label { font-size: 10px; }
    .certificate-language__trigger { height: 46px; padding-inline: 12px 10px; font-size: 13px; }
    .certificate-language__option { min-height: 46px; padding-inline: 12px 10px; font-size: 13px; }
    .certificate-title--boxed { margin-top: 0; padding: 24px 12px; min-height: 135px; }
    .certificate-title h1 { font-size: 17px; }
    .certificate-title p { font-size: 13px; }
    .certificate-image { height: 100%; max-height: 440px; }
    .certificate-page__details,
    .certificate-column {
        min-height: 0;
        padding-bottom: 0;
        overflow: visible;
        touch-action: auto;
    }
    .certificate-column .certificate-title { width: 100%; min-width: 0; margin-top: 0; text-align: center; }
    .certificate-field,
    .certificate-column .certificate-field,
    .certificate-page__details .certificate-field {
        min-height: 0;
        padding: 7px 8px;
    }
    .certificate-title h1, .certificate-title h2 {
        text-align: center;
    }
    .certificate-field p {
        font-size: 11px;
        line-height: 1.75;
        white-space: normal;
        overflow: visible;
        overflow-wrap: anywhere;
        text-overflow: clip;
    }
    .certificate-description-page {
        display: flex;
        overflow: hidden;
        flex-direction: column;
    }
    .certificate-description-page .certificate-title { flex: 0 0 auto; }
    .certificate-description {
        min-height: 0;
        height: auto;
        flex: 1 1 auto;
    }
    .certificate-pagination {
        position: absolute;
        z-index: 60;
        top: 0;
        right: auto;
        bottom: auto;
        left: 50%;
        width: 100vw;
        height: 100%;
        margin: 0;
        padding: 0;
        pointer-events: none;
        transform: translateX(-50%);
    }
    .certificate-pagination button {
        width: 44px;
        min-height: 48px;
        padding: 0;
        border: 1px solid rgba(18,87,97,.22);
        border-radius: 0 8px 8px 0;
        justify-content: center;
        background: rgba(255,255,255,.9);
        pointer-events: auto;
        touch-action: manipulation;
        backdrop-filter: blur(5px);
    }
    .certificate-pagination button:last-child { border-radius: 8px 0 0 8px; }
    .certificate-pagination button span { display: none; }
    .certificate-pagination svg { width: 22px; height: 22px; }
    .certificate-pagination output {
        position: absolute;
        bottom: 52px;
        left: 50%;
        padding: 4px 10px;
        border-radius: 999px;
        background: rgba(255,255,255,.88);
        box-shadow: 0 2px 10px rgba(25,50,71,.08);
        transform: translateX(-50%);
    }
    .toolsCert-toggle {
        position: fixed;
        z-index: 31;
        top: 86%;
        right: 0;
        display: grid;
        place-items: center;
        width: 44px;
        height: 50px;
        padding: 0;
        border: 1px solid rgba(7,91,100,.28);
        border-right: 0;
        border-radius: 8px 0 0 8px;
        background: rgba(255,255,255,.96);
        color: var(--cert-teal);
        transform: translateY(-50%);
        box-shadow: 0 4px 18px rgba(18,56,71,.12);
    }
    .toolsCert-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
    html[dir] .toolsCert {
        position: fixed;
        z-index: 30;
        top: 86%;
        right: 52px;
        bottom: auto;
        left: auto;
        width: max-content;
        margin: 0;
        flex-direction: row;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translate(28px, -50%);
        transition: opacity .2s ease, transform .25s ease, visibility .2s;
    }
    html[dir] .toolsCert.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translate(0, -50%);
    }
    .certificate-gallery { padding: 40px 12px 12px; }
    .certificate-dialog__close { width: 44px; height: 44px; top: 2px; right: 4px; }
    .certificate-gallery__arrow { width: 44px; height: 56px; }
    .certificate-profile-link { min-height: 28px; max-width: calc(100% - 70px); }
}

@media (max-width: 380px) {
    .certificate-result__topbar { display: grid; grid-template-columns: 1fr; gap: 12px; }
    .certificate-language,
    .certificate-new-search { width: 100%; }
    .certificate-new-search { order: 2; }
    .certificate-language { order: 1; }
    .certificate-title h1 { font-size: 15px; }
    .certificate-title p { font-size: 12px; }
    .certificate-page-content--left,
    .certificate-page-content--right { padding-inline: 14px; }
}

@media print {
    header, footer, .certificate-result__topbar, .toolsCert, .certificate-pagination { display: none !important; }
    .site-main { background: #fff !important; }
    .certificate-result { padding: 0; min-height: 0; }
    .certificate-flip-page { display: block !important; break-after: page; height: 95vh; }
    .certificate-description { height: auto; overflow: visible; }
}
