/**
 * Estilos Frontend - Manus Page Builder
 * Carregado globalmente para compatibilidade total
 */

/* Reset e base */
.manus-pb-text-block,
.manus-pb-gallery-block,
.manus-pb-video-block,
.manus-pb-image-block,
.manus-pb-hero-banner-block,
.manus-pb-button-block,
.manus-pb-spacer-block {
    box-sizing: border-box;
}

/* Garantia de compatibilidade global - força aplicação em qualquer página */
body .manus-pb-text-block,
body .manus-pb-gallery-block,
body .manus-pb-video-block,
body .manus-pb-image-block,
body .manus-pb-hero-banner-block,
body .manus-pb-button-block,
body .manus-pb-spacer-block {
    display: block;
    box-sizing: border-box;
}

/* Bloco de Texto */
.manus-pb-text-block {
    margin: 20px 0;
}

.manus-pb-text-title {
    margin-bottom: 15px;
    line-height: 1.2;
}

.manus-pb-text-content {
    line-height: inherit;
}

.manus-pb-text-content p {
    margin-bottom: 1em;
}

.manus-pb-text-content p:last-child {
    margin-bottom: 0;
}

/* Galeria de Imagens */
.manus-pb-gallery-block {
    margin: 30px 0;
}

.manus-pb-gallery-grid {
    display: grid;
    gap: 15px;
}

.manus-pb-gallery-item {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.manus-pb-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.manus-pb-gallery-caption {
    margin: 5px 0 0 0;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Efeitos de Hover para Galeria */
.manus-pb-hover-zoom:hover img {
    transform: scale(1.05);
}

.manus-pb-hover-darken:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.manus-pb-hover-lighten:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

/* Layout Masonry */
.manus-pb-gallery-layout-masonry .manus-pb-gallery-grid {
    column-count: 3;
    column-gap: 15px;
}

.manus-pb-gallery-layout-masonry .manus-pb-gallery-item {
    break-inside: avoid;
    margin-bottom: 15px;
}

/* Layout Justificado */
.manus-pb-gallery-layout-justified .manus-pb-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.manus-pb-gallery-layout-justified .manus-pb-gallery-item {
    flex: 1 1 auto;
    margin: 0 7.5px 15px 7.5px;
    min-width: 200px;
}

/* Bloco de Vídeo */
.manus-pb-video-block {
    margin: 30px 0;
}

.manus-pb-video-block video,
.manus-pb-video-block iframe {
    max-width: 100%;
    height: auto;
}

.manus-pb-align-left {
    text-align: left;
}

.manus-pb-align-center {
    text-align: center;
}

.manus-pb-align-right {
    text-align: right;
}

/* Bloco de Imagem */
.manus-pb-image-block {
    margin: 20px 0;
}

.manus-pb-image-block img {
    max-width: 100%;
    height: auto;
    transition: all 0.3s ease;
}

.manus-pb-image-caption {
    margin: 10px 0 0 0;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Efeitos de Hover para Imagem */
.manus-pb-image-hover-zoom:hover {
    transform: scale(1.02);
}

.manus-pb-image-hover-darken:hover {
    filter: brightness(0.8);
}

.manus-pb-image-hover-lighten:hover {
    filter: brightness(1.2);
}

/* Banner Hero */
.manus-pb-hero-banner-block {
    position: relative;
    display: flex;
    align-items: center;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 400px;
    margin: 30px 0;
}

.manus-pb-hero-banner-block h1 {
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 20px 0;
}

.manus-pb-hero-banner-block p {
    opacity: 0.9;
    line-height: 1.5;
    margin: 0 0 30px 0;
}

.manus-pb-hero-button {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 5px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.manus-pb-hero-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Bloco de Botão */
.manus-pb-button-block {
    margin: 20px 0;
}

.manus-pb-button {
    display: inline-block;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.manus-pb-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0.9;
}

.manus-pb-button:active {
    transform: translateY(0);
}

/* Bloco Espaçador */
.manus-pb-spacer-block {
    width: 100%;
    clear: both;
}

/* Responsividade */
@media (max-width: 768px) {
    .manus-pb-gallery-layout-masonry .manus-pb-gallery-grid {
        column-count: 2;
    }
    
    .manus-pb-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .manus-pb-hero-banner-block {
        min-height: 300px;
        text-align: center !important;
        justify-content: center !important;
    }
    
    .manus-pb-hero-banner-block h1 {
        font-size: 32px !important;
    }
    
    .manus-pb-hero-banner-block p {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .manus-pb-gallery-layout-masonry .manus-pb-gallery-grid {
        column-count: 1;
    }
    
    .manus-pb-gallery-grid {
        grid-template-columns: 1fr !important;
    }
    
    .manus-pb-hero-banner-block {
        min-height: 250px;
    }
    
    .manus-pb-hero-banner-block h1 {
        font-size: 24px !important;
    }
    
    .manus-pb-hero-banner-block p {
        font-size: 14px !important;
    }
    
    .manus-pb-button {
        width: 100%;
        text-align: center;
    }
}

/* Integração com Fancybox */
.manus-pb-gallery-lightbox .manus-pb-gallery-link {
    display: block;
    position: relative;
}

.manus-pb-gallery-lightbox .manus-pb-gallery-link::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manus-pb-gallery-lightbox .manus-pb-gallery-item:hover .manus-pb-gallery-link::after {
    opacity: 1;
}

/* Animações */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.manus-pb-text-block,
.manus-pb-gallery-block,
.manus-pb-video-block,
.manus-pb-image-block,
.manus-pb-button-block {
    animation: fadeInUp 0.6s ease-out;
}

/* Utilitários */
.manus-pb-clearfix::after {
    content: "";
    display: table;
    clear: both;
}

.manus-pb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}



/* Compatibilidade com Fancybox - garante funcionamento em qualquer página */
.manus-pb-gallery-lightbox .manus-pb-gallery-link {
    cursor: zoom-in;
    display: block;
    text-decoration: none;
}

.manus-pb-gallery-lightbox .manus-pb-gallery-link:hover {
    opacity: 0.9;
}

/* Correções específicas para WordPress - garante funcionamento em qualquer tema */
.wp-block-manus-page-builder-text-block,
.wp-block-manus-page-builder-image-block,
.wp-block-manus-page-builder-gallery-block,
.wp-block-manus-page-builder-hero-banner,
.wp-block-manus-page-builder-button-block,
.wp-block-manus-page-builder-spacer-block,
.wp-block-manus-page-builder-video-block {
    margin: 0;
    padding: 0;
}

/* Força aplicação dos estilos mesmo com especificidade alta de temas */
body.wp-admin .manus-pb-gallery-block,
body.wp-admin .manus-pb-text-block,
body.wp-admin .manus-pb-image-block,
body.wp-admin .manus-pb-hero-banner-block,
body.wp-admin .manus-pb-button-block,
body.wp-admin .manus-pb-spacer-block,
body.wp-admin .manus-pb-video-block,
body:not(.wp-admin) .manus-pb-gallery-block,
body:not(.wp-admin) .manus-pb-text-block,
body:not(.wp-admin) .manus-pb-image-block,
body:not(.wp-admin) .manus-pb-hero-banner-block,
body:not(.wp-admin) .manus-pb-button-block,
body:not(.wp-admin) .manus-pb-spacer-block,
body:not(.wp-admin) .manus-pb-video-block {
    display: block !important;
    box-sizing: border-box !important;
}

/* Garantia de funcionamento do lightbox em qualquer contexto */
.manus-pb-gallery-block[data-fancybox] img,
.manus-pb-gallery-block .manus-pb-gallery-link[data-fancybox] img {
    cursor: zoom-in;
    transition: all 0.3s ease;
}

.manus-pb-gallery-block[data-fancybox] img:hover,
.manus-pb-gallery-block .manus-pb-gallery-link[data-fancybox] img:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

/* Estilos para drag & drop no editor */
.block-editor-page .manus-pb-gallery-item-editor {
    border: 2px dashed #ddd;
    padding: 5px;
    position: relative;
    cursor: move;
    transition: all 0.3s ease;
}

.block-editor-page .manus-pb-gallery-item-editor:hover {
    border-color: #007cba;
    transform: scale(1.02);
}

.block-editor-page .manus-pb-remove-image {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,0,0,0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 12px;
    z-index: 10;
    transition: all 0.2s ease;
}

.block-editor-page .manus-pb-remove-image:hover {
    background: rgba(255,0,0,1);
    transform: scale(1.1);
}

/* Indicador de posição para drag & drop */
.block-editor-page .manus-pb-position-indicator {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

/* Estados de drag & drop */
.block-editor-page .manus-pb-gallery-editor.manus-pb-drag-active {
    background: rgba(0, 123, 255, 0.1);
    border: 2px dashed #007cba;
    border-radius: 5px;
    padding: 10px;
}

.block-editor-page .manus-pb-gallery-item-editor.manus-pb-dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.block-editor-page .manus-pb-gallery-preview.manus-pb-drag-over {
    background: rgba(0, 123, 255, 0.05);
}

/* Responsividade aprimorada */
@media (max-width: 768px) {
    .manus-pb-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .manus-pb-hero-banner-block {
        min-height: 300px !important;
        text-align: center !important;
    }
    
    .manus-pb-hero-banner-block h1 {
        font-size: 2rem !important;
    }
    
    .manus-pb-hero-banner-block p {
        font-size: 1rem !important;
    }
}

@media (max-width: 480px) {
    .manus-pb-gallery-grid {
        grid-template-columns: 1fr !important;
    }
    
    .manus-pb-hero-banner-block {
        min-height: 250px !important;
    }
    
    .manus-pb-hero-banner-block h1 {
        font-size: 1.5rem !important;
    }
}

/* Fallback para navegadores sem suporte a grid */
@supports not (display: grid) {
    .manus-pb-gallery-grid {
        display: flex;
        flex-wrap: wrap;
    }
    
    .manus-pb-gallery-item {
        flex: 1 1 calc(33.333% - 10px);
        margin: 5px;
    }
}

/* Animação de carregamento para imagens */
@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.manus-pb-gallery-item img[src=""] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

/* Melhorias de acessibilidade */
.manus-pb-button:focus,
.manus-pb-hero-button:focus,
.manus-pb-gallery-link:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .manus-pb-gallery-block,
    .manus-pb-video-block {
        break-inside: avoid;
    }
    
    .manus-pb-hero-banner-block {
        background-image: none !important;
        border: 1px solid #ccc;
    }
}

