:root {
    --wps-color-bg: #FFFFFF;
    --wps-color-surface: #F9F9F9;
    --wps-color-border: #EAEAEA;
    --wps-color-text-primary: #1A1A1A;
    --wps-color-text-secondary: #666666;
    --wps-color-accent: #1A1A1A;
}


.wps-metabox-wrapper {
    padding: 10px;
}

.wps-source-type-selector {
    border-bottom: 1px solid var(--wps-color-border);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.wps-source-type-selector label {
    margin-left: 15px;
}

.wps-source-section p {
    margin-top: 0;
}

#wps_pdf_external_url {
    direction: ltr;
}

.wps-file-info {
    margin-top: 10px;
    font-size: 0.9em;
}

#wps_upload_pdf_button {
    vertical-align: middle;
}

.wps-relation-controls {
    margin-bottom: 15px;
}

.wps-relation-controls label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
}

.wps-relation-controls select {
    width: 100%;
}

.wps-relation-selected h4 {
    margin: 15px 0 5px;
    font-size: 1.1em;
}

.wps-relation-selected ul {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--wps-color-border);
    background-color: var(--wps-color-surface);
    min-height: 50px;
    border-radius: 0;
}

.wps-relation-selected li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--wps-color-bg);
    padding: 5px 8px;
    border: 1px solid var(--wps-color-border);
    border-radius: 0;
    margin-bottom: 5px;
}

.wps-relation-selected .wps-remove-relation {
    cursor: pointer;
    color: #a00;
    border: none;
    background: none;
    font-weight: 700;
    font-size: 1.2em;
    padding: 0 5px;
}

/* === اصلاح شده: افزایش حداکثر عرض نمایشگر اصلی به 90% کادر والد === */
.wps-pdf-viewer-wrapper {
    width: 100%;
    max-width: 90%;
    /* حفظ ۹۰٪ برای دسکتاپ برای ظاهر بهتر */
    margin: 0rem auto;
    border: 0px solid var(--wps-color-border);
    box-shadow: none;
    border-radius: 2px;
    overflow: hidden;
    background: var(--wps-color-bg);
    aspect-ratio: 2 / 3;
    max-height: 85vh;
    position: relative;
}

.wps-viewer-cover,
.wps-viewer-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.wps-viewer-cover {
    z-index: 2;
    cursor: pointer;
    overflow: hidden;
    background: var(--wps-color-surface);
}

.wps-viewer-content {
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.wps-viewer-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.wps-viewer-cover:hover img {
    transform: scale(1.05);
}

.wps-cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wps-viewer-cover:hover .wps-cover-overlay {
    opacity: 1;
}

.wps-cover-overlay span {
    margin-top: 15px;
    font-size: 1.1em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.wps-cover-icon {
    width: 60px;
    height: 60px;
    border: 1px solid #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.wps-cover-icon::before {
    content: '';
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 18px solid #fff;
    margin-left: 5px;
}

.wps-viewer-main {
    position: relative;
    width: 100%;
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    flex-grow: 1;
    min-height: 0;
    /* اصلاح: رفع مشکل ارتفاع فلکس باکس در سافاری */
}

.wps-viewer-background {
    display: block;
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background-size: cover;
    background-position: center;
    filter: blur(15px) brightness(0.7);
    z-index: 1;
}

.wps-pdf-viewer-wrapper.fit-mode .wps-viewer-background {
    display: none;
}

.wps-pdf-viewer-wrapper.fit-mode .wps-viewer-main {
    background: var(--wps-color-surface);
}

.wps-viewer-main canvas {
    position: relative;
    z-index: 2;
    max-width: 100%;
    max-height: 100%;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
	transition: opacity 0.2s ease-in-out;
}

.wps-viewer-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3;
    font-size: 1.1em;
}

.wps-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: wps-spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.wps-viewer-controls {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: var(--wps-color-bg);
    border-top: 1px solid var(--wps-color-border);
}

.wps-viewer-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

.wps-viewer-btn:hover:not(:disabled) {
    background-color: var(--wps-color-surface);
}

.wps-viewer-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.wps-viewer-btn:focus {
    background: #ddc29b;
    color: #fff !important;
}

.wps-viewer-btn:focus-visible {
    background: #ddc29b;
    color: #fff !important;

}

.wps-icon {
    display: block;
}

.wps-icon::before {
    font-family: 'heroiconsolid' !important;
    font-weight: normal;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    font-size: 20px;
    color: var(--wps-color-text-primary);
}

.wps-icon-prev::before {
    content: "\e914";
}

.wps-icon-next::before {
    content: "\e913";
}

.wps-icon-fullscreen::before {
    content: "\e922";
}

.wps-icon-zoom-in::before {
    content: "\e906";
}

.wps-icon-zoom-out::before {
    content: "\e907";
}


.wps-page-counter {
    margin: 0 15px;
    font-size: 0.9em;
    color: var(--wps-color-text-secondary);
    white-space: nowrap;
}

.wps-controls-spacer {
    flex-grow: 1;
}

.wps-viewer-scrubber {
    padding: 10px 15px;
    background: var(--wps-color-bg);
    border-top: 1px solid var(--wps-color-border);
}

.wps-scrubber-track {
    width: 100%;
    height: 4px;
    background-color: var(--wps-color-border);
    border-radius: 0;
    position: relative;
    cursor: pointer;
}

.wps-scrubber-thumb {
    position: absolute;
    top: 50%;
    right: 0;
    left: auto;
    transform: translate(50%, -50%);
    width: 14px;
    height: 14px;
    background-color: var(--wps-color-accent);
    border-radius: 50%;
    box-shadow: none;
    transition: transform 0.2s ease;
}

.wps-viewer-scrubber.scrubbing .wps-scrubber-thumb,
.wps-viewer-scrubber:hover .wps-scrubber-thumb {
    transform: translate(50%, -50%) scale(1.2);
}

.wps-pdf-page-count {
    font-weight: 400;
}

.wps-pdf-progress-bar {
    width: 100%;
    height: 2px;
    background-color: var(--wps-color-border);
    border-radius: 0;
    overflow: hidden;
    margin: 0px 0px;
}

.wps-pdf-progress-bar-inner {
    width: 0;
    height: 100%;
    background-color: var(--wps-color-accent);
    border-radius: 0;
    transition: width 0.3s ease-in-out;
}

body.wps-pdf-lightbox-active {
    overflow: hidden;
}

.wps-pdf-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wps-pdf-lightbox-container {
    position: relative;
    width: 95%;
    height: 95%;
    max-width: 900px;
    background-color: #333;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    box-shadow: none;
}

.wps-pdf-lightbox-header {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.2);
}

.wps-pdf-lightbox-header a,
.wps-pdf-lightbox-header button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.wps-pdf-lightbox-header a:hover,
.wps-pdf-lightbox-header button:hover {
    opacity: 1;
}

.wps-pdf-lightbox-header svg {
    width: 24px;
    height: 24px;
}

.wps-pdf-lightbox-download {
    margin-right: 10px;
}

.wps-pdf-lightbox-controls {
    display: flex;
    margin-right: auto;
}

.wps-pdf-lightbox-controls .wps-viewer-btn {
    width: 38px;
    height: 38px;
    color: #fff;
}

.wps-pdf-lightbox-controls .wps-icon::before {
    color: #fff;
}

.wps-pdf-lightbox-content {
    flex-grow: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.wps-pdf-lightbox-content canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.wps-pdf-lightbox-content .wps-viewer-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3;
    font-size: 1.1em;
}


.wps-catalog-preview-button {
    cursor: pointer;
}

.wps-catalog-download-link,
.wps-button-default-style {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--wps-color-accent);
    color: var(--wps-color-bg);
    text-decoration: none;
    border: 1px solid var(--wps-color-accent);
    border-radius: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 1em;
    transition: background-color 0.2s, color 0.2s;
}

.wps-catalog-download-link:hover,
.wps-button-default-style:hover {
    background-color: var(--wps-color-bg);
    color: var(--wps-color-accent);
}

@media (max-width: 767px) {
    .wps-pdf-lightbox-container {
        width: 95vw;
        height: 85vh;
        max-width: 95%;
        max-height: 85%;
    }

    .wps-pdf-lightbox-content {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {

    .wps-viewer-controls,
    .wps-viewer-scrubber {
        padding: 8px;
    }

    .wps-page-counter {
        margin: 0 8px;
        font-size: 0.8em;
    }

    .wps-viewer-btn {
        width: 34px;
        height: 34px;
    }

    .wps-pdf-viewer-wrapper {
        width: 100%;
        max-width: 100%;
        /* اصلاح: تضمین تمام عرض بودن در موبایل */
        max-height: 85vh;
        /* تضمین فضای کافی */
        position: relative;
    }
}

.wps-pdf-viewer-wrapper:fullscreen {
    width: 100%;
    height: 100% !important;
    max-width: 100%;
    max-height: 100% !important;
    aspect-ratio: auto;
    display: flex;
    flex-direction: column;
    background-color: #222;
    border: none;
    border-radius: 0;
}

.wps-pdf-viewer-wrapper:fullscreen .wps-viewer-content {
    position: static;
    flex-grow: 1;
    min-height: 0;
}

.wps-pdf-viewer-wrapper:fullscreen .wps-viewer-controls,
.wps-pdf-viewer-wrapper:fullscreen .wps-viewer-scrubber {
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

/* فایل: pdf-system.css */

.wps-viewer-main canvas, 
.wps-pdf-lightbox-content canvas {
    /* اطمینان از قرارگیری در بالای پس‌زمینه */
    position: relative; 
    z-index: 2; 
    /* اضافه کردن Transition برای حرکت نرم‌تر */
	transition: opacity 0.2s ease-in-out;
}

.wps-viewer-background {
    /* لایه پس‌زمینه بلور شده */
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1; /* زیر کانواس */
    background-size: cover;
    background-repeat: no-repeat;
    /* این خاصیت برای blur شدن استفاده می‌شود که باید در فایل CSS شما وجود داشته باشد */
    /* filter: blur(10px); */ 
}

/* برای لایت‌باکس: اطمینان از داشتن پس‌زمینه سفید */
.wps-pdf-lightbox-content {
    background-color: #ffffff; /* پس‌زمینه سفید برای زمان پنهان بودن کانواس */
    position: relative;
}