/* Full-screen template preview modal */
html.no-scroll, body.no-scroll {
    overflow: hidden;
    height: 100%;
}

.template-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 99999;
    display: none;
}

.template-modal.is-open {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    opacity: 0;
    visibility: visible;
    pointer-events: none;
    transition: opacity 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.template-modal.is-open.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.template-modal__bar {
    height: 56px;
    background: #f5f5f5;
    border-bottom: 1px solid #e5e5e5;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    padding: 0 16px;
    -webkit-box-flex: 0;
    -ms-flex: 0 0 56px;
    flex: 0 0 56px;
    transform: translateY(-8px);
    opacity: 0;
    transition: transform 450ms cubic-bezier(0.22, 1, 0.36, 1), opacity 450ms cubic-bezier(0.22, 1, 0.36, 1);
}

.template-modal__title {
    font-family: 'Raleway', sans serif;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 16px;
    color: #787878;
}

.template-modal__title, .template-modal__center, .template-modal__actions {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 0;
    flex: 1 1 0;
}

.template-modal__center {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 8px;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.template-modal__device {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
}

.template-modal__device svg {
    display: block;
    fill: #787878;
}

.template-modal__device.is-active, .template-modal__device:hover {
    background: #ececec;
}

.template-modal__actions {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: end;
    -ms-flex-pack: end;
    justify-content: flex-end;
}

.template-modal__actions a, .template-modal__actions button {
    margin-left: 8px;
}

/* Compact icon-only close button */
.template-modal__close--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    min-width: 36px;
    height: 36px;
    line-height: 0;
}
.template-modal__close--icon svg { width: 18px; height: 18px; fill: #787878; }

.template-modal__viewport {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    height: calc(100vh - 56px);
    overflow: hidden;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    background-color: #d9d9d9;
    transform: scale(0.985);
    opacity: 0.95;
    transition: transform 480ms cubic-bezier(0.22, 1, 0.36, 1), opacity 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.template-modal__iframe {
    border: 0;
    height: 100%;
    width: 100%;
    max-width: 100%;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1), max-width 300ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width;
}

.template-modal__backdrop {
    display: none;
}

/* Device modes (controls viewport width) */
.template-modal--desktop .template-modal__iframe {
    width: 100%;
    max-width: 100%;
}

.template-modal--tablet .template-modal__iframe {
    width: 1024px;
}

.template-modal--mobile-landscape .template-modal__iframe {
    width: 812px;
}

.template-modal--mobile-portrait .template-modal__iframe {
    width: 375px;
}

/* Visible state animations */
.template-modal.is-open.is-visible .template-modal__bar {
    transform: translateY(0);
    opacity: 1;
}
.template-modal.is-open.is-visible .template-modal__viewport {
    transform: scale(1);
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .template-modal.is-open { transition: none; }
    .template-modal__bar,
    .template-modal__viewport,
    .template-modal__iframe { transition: none; }
}

/* Responsive adjustments for small screens */
@media (max-width: 768px) {
    .template-modal__center { display: none !important; }
    .template-modal__title { font-size: 14px; letter-spacing: 1px; }
    .template-modal__bar { height: 48px; padding: 0 10px; }
    .template-modal__viewport { height: calc(100vh - 48px); }
    .template-modal__actions a.btn_usarplantilla { padding: 10px 12px; font-size: 14px; }
    .template-modal__close--icon { min-width: 32px; height: 32px; padding: 6px; }
    .template-modal__close--icon svg { width: 16px; height: 16px; }
}
