.api-post-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--modal-z-index, 99999999);
    display: none;
    overflow: hidden !important;
    background: var(--modal-bg, #fff);
    will-change: opacity, visibility;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    pointer-events: none; 
}

.api-post-modal.active {
    display: block;
    pointer-events: auto; 
    animation: modalFadeIn 0.2s ease-out forwards;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        visibility: hidden;
    }
    to {
        opacity: 1;
        visibility: visible;
    }
}

.api-post-modal.fullscreen-mode {
    display: block;
}

.api-post-modal-content {
    position: fixed;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.api-post-modal-header,
.api-post-modal.fullscreen-mode .api-post-modal-header {
    position: static;
    
    top: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    height: 44px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 0;
    width: 100%;
    transition: all 0.3s ease;
}

.api-post-modal.fullscreen-mode .api-post-modal-header {
    position: fixed;
    z-index: 999999;
}

.api-post-modal-header::before {
    content: '';
    grid-column: 2;
    min-width: 100px;
    
}

.api-post-modal-header::after,
.api-post-modal.fullscreen-mode .api-post-modal-header::after {
    content: '';
    flex: 1;
    min-width: 300px;
    height: 1px;
}

.api-post-modal-preview-buttons,
.api-post-modal.fullscreen-mode .api-post-modal-preview-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
    flex: 0 0 auto;
    margin-right: auto;
    grid-column: 1;
    justify-self: start;
}

.api-post-modal-preview-buttons .preview-button,
.api-post-modal.fullscreen-mode .api-post-modal-preview-buttons .preview-button {
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.api-post-modal-preview-buttons .preview-button:hover {
    background-color: transparent !important;
}

.api-post-modal-preview-buttons .preview-button.active {
    background-color: transparent !important;
}

.api-post-modal-close,
.api-post-modal.fullscreen-mode .api-post-modal-close {
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: auto;
    margin-right: 20px;
    flex: 0 0 auto;
    grid-column: 3;
    justify-self: end;
    z-index: 10000001;
}

.api-post-modal-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.api-post-modal-body,
.api-post-modal.fullscreen-mode .api-post-modal-body {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: #fff;
    overflow: auto;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.api-post-modal .api-post-modal-body {
    top: 44px;
    
}

.api-post-modal.fullscreen-mode .api-post-modal-body {
    top: 70px;
    
}

.api-post-modal-iframe {
    position: relative;
    width: 100%;
    height: 100%;
    border: none;
}

.elementor-section.elementor-section-boxed .api-post-modal-header {
    max-width: var(--container-max-width, 1140px);
    margin: 0 auto;
    width: 100%;
    padding: 0;
}

.elementor-section.elementor-section-boxed .api-post-modal-preview-buttons {
    margin-left: var(--container-padding, 20px);
    flex: 0 0 auto;
}

.elementor-section.elementor-section-boxed .api-post-modal-close {
    margin-right: var(--container-padding, 20px);
    flex: 0 0 auto;
}

.elementor-section.elementor-section-boxed .api-post-modal-header::after {
    content: '';
    flex: 1;
    min-width: 200px;
}

@media (max-width: 1024px) {
    .elementor-section.elementor-section-boxed .api-post-modal-header {
        max-width: var(--container-max-width-tablet, 1024px);
        padding: 0 var(--container-padding-tablet, 15px);
    }
}

@media (max-width: 767px) {
    .elementor-section.elementor-section-boxed .api-post-modal-header {
        max-width: var(--container-max-width-mobile, 767px);
        padding: 0 var(--container-padding-mobile, 10px);
    }
}

@media (max-width: 767px) {

    .api-post-modal-header,
    .api-post-modal.fullscreen-mode .api-post-modal-header {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        padding: 0 10px !important;
        overflow: visible !important;
        height: 50px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .api-post-modal-header::before,
    .api-post-modal-header::after,
    .api-post-modal.fullscreen-mode .api-post-modal-header::before,
    .api-post-modal.fullscreen-mode .api-post-modal-header::after {
        display: none !important;
    }

    .api-post-modal-preview-buttons,
    .api-post-modal.fullscreen-mode .api-post-modal-preview-buttons {
        flex: 0 1 auto !important;
        margin-left: 5px !important;
        margin-right: 0 !important;
        max-width: 65% !important;
        overflow-x: auto !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    .api-post-modal-close,
    .api-post-modal.fullscreen-mode .api-post-modal-close {
        position: static !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-width: 40px !important;
        min-height: 40px !important;
        margin-left: auto !important;
        margin-right: 5px !important;
    }
}

@media (max-width: 375px) {
    .api-post-modal-preview-buttons {
        max-width: 55% !important;
        
    }

    .api-post-modal-close {
        padding: 8px 5px !important;
        
    }
}

@media (max-width: 767px) {
    .api-post-modal-header {
        height: 50px !important;
        padding: 0 10px !important;
    }
    
    .api-post-modal-preview-buttons {
        max-width: 65% !important;
    }
}

body.modal-open {
    overflow: hidden !important;
    padding-right: var(--scrollbar-width, 0px);
}

.api-post-modal {
    --device-icon-color: currentColor;
    --device-icon-hover-color: currentColor;
    --device-icon-active-color: currentColor;
    --close-icon-color: currentColor;
    --close-icon-hover-color: currentColor;
    --icon-size: 24px;
    --transition-speed: 0.3s;
    --spinner-size: 50px;
    --spinner-border-width: 2px;
    --spinner-border-color: rgba(0, 0, 0, 0.1); 
    --spinner-border-top-color: #3498db;
}

.api-post-modal .icon-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

body .api-post-modal .preview-button .icon-container i,
body #modal-api-post-grid .preview-button .icon-container i {
    color: inherit !important;
}

body .api-post-modal .preview-button .icon-container svg,
body .api-post-modal .preview-button .icon-container svg path,
body #modal-api-post-grid .preview-button .icon-container svg,
body #modal-api-post-grid .preview-button .icon-container svg path {
    fill: currentColor !important;
}

body .api-post-modal .api-post-modal-close .icon-container i,
body #modal-api-post-grid .api-post-modal-close .icon-container i {
    color: inherit !important;
}

body .api-post-modal .api-post-modal-close .icon-container svg,
body .api-post-modal .api-post-modal-close .icon-container svg path,
body #modal-api-post-grid .api-post-modal-close .icon-container svg,
body #modal-api-post-grid .api-post-modal-close .icon-container svg path {
    fill: currentColor !important;
}

.api-post-modal .icon-container svg[style],
.api-post-modal .icon-container svg *[style] {
    fill: inherit !important;
    color: inherit !important;
}

.elementor-editor-active .api-post-modal .icon-container svg.svg-processed,
.elementor-editor-active .api-post-modal .icon-container svg.svg-processed * {
    fill: inherit !important;
    stroke: inherit !important;
    color: inherit !important;
}

.api-post-modal .icon-container svg[style],
.api-post-modal .icon-container svg *[style] {
    fill: inherit !important;
    stroke: inherit !important;
    color: inherit !important;
}

.api-post-modal .icon-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--loading-bg, rgba(255, 255, 255, 0.98));
    z-index: var(--loading-z-index, 99999);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal-loading.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.modal-loading-spinner {
    width: var(--spinner-size, 50px);
    height: var(--spinner-size, 50px);
    border: var(--spinner-border-width, 3px) solid rgba(0, 0, 0, 0.1); 
    border-top-color: var(--spinner-color, #3498db) !important;
    border-radius: 50%;
    animation: spin 1.5s linear infinite, pulse 1.5s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.modal-loading-progress {
    width: var(--progress-width, 200px);
    height: var(--progress-height, 4px);
    background: #f3f3f3;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
}

.modal-loading-progress::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 40%;
    background: var(--progress-color, #3498db);
    animation: progress 1s ease-in-out infinite;
}

@keyframes progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

.modal-loading-custom-image {
    width: var(--custom-image-width, 200px);
    height: auto;
    margin-bottom: 15px;
    animation: imagePulse 1.5s ease-in-out infinite;
}

@keyframes imagePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.95); opacity: 0.8; }
}

.modal-loading-text {
    color: var(--loading-text-color, inherit);
    font-size: var(--loading-text-size, inherit);
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    position: relative; 
    opacity: 0.6;
}

.modal-loading-text::after {
    content: '';
    position: absolute;
    left: 100%; 
    margin-left: 5px; 
    top: 50%; 
    transform: translateY(-50%); 
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

.modal-loading-progress {
    width: var(--progress-width, 200px);
    height: var(--progress-height, 4px);
    background: #f3f3f3;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
}

.modal-loading-progress .progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: var(--progress-color, #3498db);
    transition: width 0.3s linear;
}

.modal-loading-custom-image {
    width: var(--custom-image-width, 200px);
    height: auto;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-loading-custom-image img {
    max-width: 100%;
    height: auto;
    animation: imagePulse 1.5s ease-in-out infinite;
}

.modal-loading-custom-image lottie-player {
    width: var(--custom-image-width, 200px);
    height: var(--custom-image-width, 200px);
    animation: none;
}

.api-post-modal[data-active-layout="layout1"] .modal-loading {
    --loading-layout: spinner;
}

.api-post-modal[data-active-layout="layout2"] .modal-loading {
    --loading-layout: progress;
}

.api-post-modal[data-active-layout="layout3"] .modal-loading {
    --loading-layout: custom;
}

.api-post-modal[data-active-layout="layout3"] .modal-loading-text,
.api-post-modal[data-active-layout="layout3"] .modal-loading-text::after {
    display: none !important;
    animation: none !important;
}

.api-post-modal[data-active-layout="layout3"] .modal-loading-text {
    display: none !important;
}