/**
 * ============================================================
 * ESPAÇO DO POVO - CORREÇÕES CSS v2.0.1
 * ============================================================
 * 
 * PROBLEMAS IDENTIFICADOS E CORRIGIDOS:
 * 
 * 1. Variáveis CSS não definidas (--text-body, --text-h1, etc)
 * 2. Conflitos de grid no posts-grid (3 colunas vs auto-fill)
 * 3. z-index sem hierarquia clara
 * 4. search-form-wrapper sobrepondo conteúdo
 * 5. Admin bar quebrando header sticky
 * 6. Dark mode inconsistente
 * 7. Layout mobile quebrado
 * 8. Overflow horizontal
 * 
 * COMO USAR:
 * Substitua o conteúdo do arquivo fixes.css por este arquivo
 * OU adicione este conteúdo no final do style.css
 * 
 * @package EspacoDoPovo
 * @version 2.0.1
 * @date 25/12/2024
 */

/* ==========================================================================
   1. VARIÁVEIS CSS FALTANTES
   ========================================================================== */

:root {
    /* Typography Sizes - ADICIONADAS */
    --text-tiny: 0.75rem;      /* 12px */
    --text-small: 0.875rem;    /* 14px */
    --text-body: 1rem;         /* 16px */
    --text-body-lg: 1.125rem;  /* 18px */
    --text-h3: 1.25rem;        /* 20px */
    --text-h2: 1.5rem;         /* 24px */
    --text-h1: 2rem;           /* 32px */
    
    /* Z-index Scale - ADICIONADA */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-tooltip: 600;
    
    /* Border Radius full */
    --radius-full: 9999px;
}

/* ==========================================================================
   2. FIX ADMIN BAR + HEADER STICKY
   ========================================================================== */

body.admin-bar .site-header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .site-header {
        top: 46px;
    }
}

body.admin-bar .reading-progress {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .reading-progress {
        top: 46px;
    }
}

/* ==========================================================================
   3. FIX SEARCH FORM WRAPPER (OVERLAY)
   ========================================================================== */

.search-form-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(1, 17, 43, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.search-form-wrapper.active {
    display: flex;
}

.search-form-container {
    width: 100%;
    max-width: 700px;
    position: relative;
}

.search-form-wrapper .search-close {
    position: absolute;
    top: -60px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    padding: 10px;
    line-height: 1;
    transition: transform 0.2s;
}

.search-form-wrapper .search-close:hover {
    transform: scale(1.2);
}

.search-form-wrapper .search-form {
    display: flex;
    gap: 12px;
    width: 100%;
}

.search-form-wrapper .search-field {
    flex: 1;
    padding: 18px 24px;
    font-size: 1.125rem;
    border: 2px solid var(--color-primary);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.search-form-wrapper .search-field::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-form-wrapper .search-field:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
}

.search-form-wrapper .search-submit {
    padding: 18px 32px;
    background: var(--color-primary);
    color: var(--color-secondary);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.search-form-wrapper .search-submit:hover {
    background: white;
}

@media (max-width: 600px) {
    .search-form-wrapper .search-form {
        flex-direction: column;
    }
    
    .search-form-wrapper .search-submit {
        width: 100%;
        justify-content: center;
    }
}

body.admin-bar .search-form-wrapper {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .search-form-wrapper {
        top: 46px;
    }
}

/* ==========================================================================
   4. FIX POSTS-GRID - CONFLITO RESOLVIDO
   ========================================================================== */

/* Reset do grid para evitar conflitos */
.posts-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 24px !important;
    margin: 0 !important;
}

@media (max-width: 991px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
}

@media (max-width: 600px) {
    .posts-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* ==========================================================================
   5. FIX Z-INDEX HIERARCHY
   ========================================================================== */

.site-container {
    position: relative;
    z-index: 1;
}

.site-header {
    z-index: 200;
}

.reading-progress {
    z-index: 201;
}

.nav-overlay {
    z-index: 298;
}

.primary-navigation {
    z-index: 299;
}

.search-form-wrapper {
    z-index: 500;
}

.video-modal {
    z-index: 510;
}

.accessibility-toolbar {
    z-index: 600;
}

/* ==========================================================================
   6. FIX NAV CLOSE BUTTON
   ========================================================================== */

.nav-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s;
    z-index: 1;
}

.nav-close:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
}

/* ==========================================================================
   7. FIX HEADER CONTAINER
   ========================================================================== */

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    max-width: var(--container-max-width);
    margin: 0 auto;
    gap: 16px;
}

.site-logo {
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ==========================================================================
   8. FIX HERO SECTION RESPONSIVO
   Nota: Esses estilos são para o hero-section/hero-image (design antigo)
   NÃO devem afetar o .hero-post da front-page
   ========================================================================== */

.hero-section {
    margin-bottom: 48px;
}

.hero-section .hero-image,
.hero-image {
    position: relative;
    height: 70vh;
    min-height: 500px;
    max-height: 700px;
    overflow: hidden;
}

.hero-section .hero-image img,
.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(transparent 30%, rgba(1, 17, 43, 0.95));
    pointer-events: none;
}

/* Estilos para hero-section (design com overlay) */
.hero-section .hero-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 48px 0;
    color: white;
}

.hero-section .hero-title {
    font-size: clamp(1.75rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
    margin: 0 0 16px;
    max-width: 800px;
}

.hero-section .hero-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    opacity: 0.8;
    flex-wrap: wrap;
}

/* HERO POST - Front Page (texto ABAIXO da imagem) */
.hero-post .hero-content {
    position: static !important;
    padding: 24px !important;
    color: inherit !important;
    background: white !important;
}

.hero-post .hero-title {
    font-size: 2rem !important;
    line-height: 1.2 !important;
    margin: 0 0 12px !important;
    color: #1a1a1a !important;
    max-width: none !important;
}

.hero-post .hero-excerpt {
    font-size: 1.125rem !important;
    line-height: 1.7 !important;
    color: #4a4a4a !important;
    margin: 0 0 16px !important;
}

.hero-post .hero-meta {
    font-size: 0.875rem !important;
    color: #4a4a4a !important;
    opacity: 1 !important;
}

body.dark-mode .hero-post .hero-content {
    background: var(--color-surface) !important;
}

body.dark-mode .hero-post .hero-title {
    color: var(--color-text-primary) !important;
}

body.dark-mode .hero-post .hero-excerpt,
body.dark-mode .hero-post .hero-meta {
    color: var(--color-text-secondary) !important;
}

@media (max-width: 768px) {
    .hero-section .hero-image,
    .hero-image {
        height: 60vh;
        min-height: 400px;
    }
    
    .hero-section .hero-content {
        padding: 32px 0;
    }
    
    .hero-post .hero-title {
        font-size: 1.5rem !important;
    }
}

/* ==========================================================================
   9. FIX POST-CARD CONSISTÊNCIA
   ========================================================================== */

.post-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.15s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-color: var(--color-primary);
}

.card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.card-thumbnail {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    flex-shrink: 0;
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-card:hover .card-thumbnail img {
    transform: scale(1.05);
}

.category-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 1;
}

.card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: auto;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--color-text-primary);
}

.card-meta {
    display: flex;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    align-items: center;
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
}

/* ==========================================================================
   10. FIX READING TIME
   ========================================================================== */

.reading-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.reading-time svg,
.reading-time .icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ==========================================================================
   11. FIX SECTION HEADER RESPONSIVO
   ========================================================================== */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--color-secondary);
}

.title-bar {
    width: 4px;
    height: 28px;
    background: var(--color-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.section-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.section-link:hover {
    color: var(--color-accent);
}

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        align-items: center;
    }
}

/* ==========================================================================
   12. FIX FOOTER SOCIAL ICONS
   ========================================================================== */

.site-footer .social-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.site-footer .social-links a {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    transition: all 0.2s ease;
}

.site-footer .social-links a:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
    transform: translateY(-3px);
}

.site-footer .social-links .icon {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   13. DARK MODE FIXES
   ========================================================================== */

body.dark-mode .post-card {
    background: var(--color-surface);
    border-color: var(--color-border);
}

body.dark-mode .card-title {
    color: var(--color-text-primary);
}

body.dark-mode .hero-content {
    color: white;
}

body.dark-mode .section-title {
    color: var(--color-text-primary);
}

body.dark-mode .section-link {
    color: var(--color-text-primary);
}

body.dark-mode .widget {
    background: var(--color-surface);
}

body.dark-mode .category-badge {
    background: var(--color-primary);
    color: var(--color-secondary);
}

/* ==========================================================================
   14. ACESSIBILIDADE - FOCUS VISIBLE
   ========================================================================== */

:focus-visible {
    outline: 3px solid var(--color-primary) !important;
    outline-offset: 2px !important;
}

:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--color-primary) !important;
    outline-offset: 2px !important;
}

/* ==========================================================================
   15. FIX OVERFLOW HORIZONTAL
   ========================================================================== */

html, body {
    overflow-x: hidden;
    width: 100%;
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   16. FIX SVG ICONS
   ========================================================================== */

.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.icon-whatsapp,
.icon-facebook,
.icon-twitter,
.icon-telegram {
    fill: currentColor;
    stroke: none;
}

/* ==========================================================================
   17. FIX IMAGENS
   ========================================================================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.wp-post-image {
    width: 100%;
    height: auto;
}

/* ==========================================================================
   18. FIX AD ZONES
   ========================================================================== */

.ad-zone {
    min-height: 0;
    overflow: hidden;
}

.ad-zone:empty {
    display: none;
}

.ad-leaderboard {
    max-width: 728px;
    margin: 0 auto;
    padding: 16px 0;
}

/* ==========================================================================
   19. VIDEOS SECTION FIX
   ========================================================================== */

.videos-section {
    background: var(--color-secondary);
    padding: 48px 0;
}

.videos-section .section-title,
.videos-section .section-link {
    color: white;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 991px) {
    .videos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .videos-grid .video-featured {
        grid-column: span 2;
        grid-row: span 1;
    }
}

@media (max-width: 600px) {
    .videos-grid {
        grid-template-columns: 1fr;
    }
    
    .videos-grid .video-featured {
        grid-column: span 1;
    }
}

/* ==========================================================================
   20. VIDEO MODAL FIX
   ========================================================================== */

.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 510;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-modal[hidden] {
    display: none;
}

.video-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
}

.video-modal-container {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    z-index: 1;
}

.video-modal-close {
    position: absolute;
    top: -48px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}

.video-modal-body {
    width: 100%;
    height: 100%;
}

.video-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   21. PRINT STYLES
   ========================================================================== */

@media print {
    .site-header,
    .primary-navigation,
    .nav-overlay,
    .search-form-wrapper,
    .accessibility-toolbar,
    .ad-zone,
    .social-links,
    .floating-share-bar,
    #wpadminbar {
        display: none !important;
    }
    
    .hero-image {
        height: auto;
        max-height: 400px;
    }
    
    .post-card {
        break-inside: avoid;
    }
}

/* ==========================================================================
   22. PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

.post-card,
.card-thumbnail img,
.site-header {
    will-change: transform;
}

/* ==========================================================================
   23. CORREÇÕES CRÍTICAS v8 - HOME
   ========================================================================== */

/* --- HEADER HOME COM FUNDO VERDE --- */
body.home .site-header,
body.front-page .site-header,
.site-header.home-header {
    background: #DBFF00 !important;
    border-bottom-color: #DBFF00 !important;
}

body.home .site-header *,
body.front-page .site-header *,
.site-header.home-header * {
    color: #01112B !important;
}

body.home .site-header .menu-toggle:hover,
body.home .site-header .search-toggle:hover,
body.home .site-header .dark-mode-toggle:hover {
    opacity: 0.7 !important;
}

/* --- FIX CONTEÚDO VAZANDO NO FOOTER --- */
.site-footer {
    position: relative !important;
    z-index: 100 !important;
    clear: both !important;
    margin-top: 0 !important;
}

/* Clearfix para o main content */
main#main-content::after,
.site-content::after {
    content: "" !important;
    display: block !important;
    clear: both !important;
    height: 0 !important;
}

/* Garantir que hero e posts não vazem */
.hero-post,
article.post-card {
    position: relative !important;
    z-index: 1 !important;
    contain: layout !important;
}

/* ==========================================================================
   24. NEWSLETTER WIDGET - ESTILO CONSISTENTE
   ========================================================================== */

.newsletter-widget,
.widget.newsletter-widget {
    background: #01112B !important;
    color: white !important;
    padding: 24px !important;
    border-radius: 12px !important;
    border: none !important;
}

.newsletter-widget .widget-title,
.newsletter-widget .newsletter-title,
.newsletter-title {
    color: #DBFF00 !important;
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    border: none !important;
}

.newsletter-widget .newsletter-description,
.newsletter-description {
    font-size: 0.875rem !important;
    color: rgba(255,255,255,0.85) !important;
    margin: 0 0 16px !important;
    line-height: 1.5 !important;
}

.newsletter-widget .newsletter-form,
.newsletter-form {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.newsletter-widget .newsletter-form input[type="email"],
.newsletter-widget .newsletter-form input[type="text"],
.newsletter-form input[type="email"],
.newsletter-form input[type="text"] {
    padding: 12px !important;
    border: 2px solid #DBFF00 !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    background: transparent !important;
    color: white !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.newsletter-widget .newsletter-form input::placeholder,
.newsletter-form input::placeholder {
    color: rgba(255,255,255,0.6) !important;
}

.newsletter-widget .newsletter-form button,
.newsletter-widget .newsletter-form input[type="submit"],
.newsletter-form button,
.newsletter-form input[type="submit"] {
    padding: 12px 24px !important;
    background: #DBFF00 !important;
    color: #01112B !important;
    border: none !important;
    border-radius: 4px !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    width: 100% !important;
}

.newsletter-widget .newsletter-form button:hover,
.newsletter-widget .newsletter-form input[type="submit"]:hover,
.newsletter-form button:hover,
.newsletter-form input[type="submit"]:hover {
    background: white !important;
    transform: translateY(-2px) !important;
}

/* MailPoet integration */
.newsletter-widget .mailpoet_form {
    padding: 0 !important;
    background: transparent !important;
}

.newsletter-widget .mailpoet_text_label {
    display: none !important;
}

.newsletter-widget .mailpoet_form input[type="email"],
.newsletter-widget .mailpoet_form input[type="text"] {
    padding: 12px !important;
    border: 2px solid #DBFF00 !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    background: transparent !important;
    color: white !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.newsletter-widget .mailpoet_form input::placeholder {
    color: rgba(255,255,255,0.6) !important;
}

.newsletter-widget .mailpoet_form input[type="submit"],
.newsletter-widget .mailpoet_form button {
    padding: 12px 24px !important;
    background: #DBFF00 !important;
    color: #01112B !important;
    border: none !important;
    border-radius: 4px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    width: 100% !important;
    margin-top: 8px !important;
}

.newsletter-widget .mailpoet_form input[type="submit"]:hover,
.newsletter-widget .mailpoet_form button:hover {
    background: white !important;
}

/* ==========================================================================
   FIM DAS CORREÇÕES
   ========================================================================== */
