/* Reset e configurações globais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
    margin: 0;
    /* Prevent layout shifts */
    overflow-x: hidden;
}

/* Performance optimizations */
img {
    max-width: 100%;
    height: auto;
    /* Prevent layout shift from images */
    display: block;
}

/* Header do site */
.site-header {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
    padding: 1rem 0;
    /* Fixed header prevents shifts */
    position: relative;
    z-index: 10;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
}

.logo-icon {
    background: white;
    color: #8B5CF6;
    padding: 0.5rem;
    margin-right: 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
    /* Prevent text shifting */
    line-height: 1;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.3s ease;
    /* Prevent layout shift on hover */
    transform: translateZ(0);
}

.nav-menu a:hover {
    background: rgba(255,255,255,0.1);
}

.nav-highlight {
    background: #F59E0B !important;
}

/* Container principal */
.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    /* Prevent content jumping */
    min-height: 100vh;
}

/* Header do artigo */
.article-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    /* Prevent font loading shifts */
    font-display: swap;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.breadcrumb {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 1rem;
}

.breadcrumb a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: white;
}

/* Conteúdo */
.content {
    padding: 2rem 1.5rem;
}

h2 {
    color: #2c3e50;
    font-size: 1.8rem;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #667eea;
    /* Prevent font loading shifts */
    font-display: swap;
}

h3 {
    color: #34495e;
    font-size: 1.4rem;
    margin: 1.5rem 0 0.8rem 0;
    font-display: swap;
}

h4 {
    color: #495057;
    font-size: 1.2rem;
    margin: 1.2rem 0 0.6rem 0;
    font-display: swap;
}

p {
    margin-bottom: 1rem;
    text-align: justify;
}

/* Boxes de destaque */
.highlight {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0 5px 5px 0;
}

.tip {
    background: #d4edda;
    border-left: 4px solid #28a745;
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0 5px 5px 0;
}

.warning {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0 5px 5px 0;
}

.info {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0 5px 5px 0;
}

/* Listas */
ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* ==================== CORREÇÃO CRÍTICA PARA ADSENSE ==================== */
.ad-container {
    margin: 2rem 0;
    text-align: center;
    /* RESERVA ESPAÇO PARA EVITAR CLS */
    min-height: 280px;
    
    /* CORRIGIDO: Removido display flex que conflitava com AdSense */
    /* CORRIGIDO: Removido contain: layout que impedia cálculo de dimensões */
    
    /* Mantém prevenção de layout shifts sem interferir no AdSense */
    position: relative;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    
    /* Permite que o AdSense calcule dimensões corretamente */
    width: 100%;
    max-width: 100%;
    overflow: visible;
    
    /* Otimização para performance */
    content-visibility: auto;
    contain-intrinsic-size: 320px 250px;
}

/* IMPORTANTE: AdSense precisa de elementos inline-block ou block */
.ad-container .adsbygoogle {
    /* Força o elemento a ter dimensões calculáveis */
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
    
    /* Remove qualquer isolamento de layout */
    position: static;
    z-index: auto;
    
    /* Garante que tenha dimensões mínimas */
    min-width: 300px;
    min-height: 200px;
}

/* Placeholder para anúncios carregando */
.ad-container::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0.3;
    pointer-events: none;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Remove placeholder quando anúncio carrega */
.ad-container .adsbygoogle[data-adsbygoogle-status="done"] ~ ::before,
.ad-container .adsbygoogle[data-ad-status="filled"] ~ ::before {
    display: none;
}

/* Tamanhos específicos para diferentes tipos de anúncio */
.ad-container.ad-topo {
    min-height: 250px;
}

.ad-container.ad-topo .adsbygoogle {
    min-height: 200px;
}

.ad-container.ad-meio {
    min-height: 280px;
}

.ad-container.ad-meio .adsbygoogle {
    min-height: 250px;
}

.ad-container.ad-final {
    min-height: 250px;
}

.ad-container.ad-final .adsbygoogle {
    min-height: 200px;
}

/* CORREÇÃO PARA OVERLAYS - não interferir nos controles */
[data-google-av-ctype],
.google-auto-placed,
[id*="google_ads_iframe"] {
    /* Remove qualquer interferência nossa */
    contain: none !important;
    position: relative !important;
    z-index: auto !important;
}

/* Garante que botões de fechar funcionem */
[data-google-av-ctype] button,
.google-auto-placed button,
[id*="google_ads_iframe"] button,
[aria-label*="close"],
[title*="close"] {
    pointer-events: auto !important;
    z-index: 999999 !important;
    position: relative !important;
    cursor: pointer !important;
}

/* CTAs */
.cta-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 10px;
    margin: 2rem 0;
    text-align: center;
}

.cta-box h3 {
    color: white;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 12px 30px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 1rem;
    transition: background 0.3s ease;
    /* Prevent layout shift on hover */
    transform: translateZ(0);
}

.btn:hover {
    background: #218838;
    /* Use transform instead of changing properties that affect layout */
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-1px);
}

/* Tabelas */
.table-responsive {
    overflow-x: auto;
    margin: 1.5rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    /* Prevent table layout shifts */
    table-layout: fixed;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    /* Prevent text overflow shifts */
    word-wrap: break-word;
}

th {
    background: #f8f9fa;
    font-weight: bold;
    color: #495057;
}

tr:hover {
    background: #f8f9fa;
}

/* Citações */
blockquote {
    border-left: 4px solid #667eea;
    padding: 1rem;
    margin: 1.5rem 0;
    background: #f8f9fa;
    font-style: italic;
}

/* Códigos */
code {
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    /* Prevent font shifts */
    font-display: swap;
}

pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1rem 0;
}

/* Footer do site */
.site-footer {
    background: #F3F4F6;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 1rem;
}

.footer-logo {
    background: #8B5CF6;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    max-width: 120px;
    /* Prevent shifting */
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-links a {
    color: #6B7280;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #8B5CF6;
}

/* Componentes adicionais */
.card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 1rem 0;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    background: #667eea;
    color: white;
    border-radius: 3px;
    margin: 0.2rem;
}

.text-center {
    text-align: center;
}

.text-bold {
    font-weight: bold;
}

.text-muted {
    color: #6c757d;
}

.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }

/* OTIMIZAÇÕES DE PERFORMANCE */

/* Prevent unnecessary repaints */
.nav-menu a,
.btn,
.footer-links a {
    will-change: background-color;
}

/* Optimize animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Responsividade OTIMIZADA */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .content {
        padding: 1.5rem 1rem;
    }
    
    .article-header {
        padding: 1.5rem 1rem;
    }
    
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }
    
    .footer-container {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    
    .cta-box {
        padding: 1.5rem 1rem;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 8px;
    }
    
    /* Mobile ad optimization */
    .ad-container {
        min-height: 250px;
        margin: 1.5rem 0;
    }
    
    .ad-container .adsbygoogle {
        min-width: 300px;
        min-height: 200px;
    }
    
    .ad-container.ad-meio {
        min-height: 280px;
    }
    
    .ad-container.ad-meio .adsbygoogle {
        min-height: 250px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .content {
        padding: 1rem;
    }
    
    .nav-menu {
        flex-direction: column;
        align-items: center;
    }
    
    /* Smaller ads on very small screens */
    .ad-container {
        min-height: 200px;
        margin: 1rem 0;
    }
    
    .ad-container .adsbygoogle {
        min-width: 280px;
        min-height: 150px;
    }
}

/* CRITICAL OPTIMIZATIONS FOR CORE WEB VITALS */

/* Prevent layout shifts from loading content - CORRIGIDO */
.container > *:not(.ad-container) {
    contain: layout;
}

/* Optimize critical rendering path */
.site-header,
.article-header,
.content {
    contain: layout style;
}

/* Prevent cumulative layout shift from dynamic content */
[data-loading] {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}