/**
 * MIRB Grid Frontend Styles
 * 
 * @package MIRB_GRID
 * @since 1.0.0
 */

.mirb-grid-wrapper {
    max-width: 100%;
    margin: 0 auto 40px;
    padding: 0;
    display: block;
}

/* Prevent ad injection */
.mirb-grid-wrapper.mirb-grid-single-block {
    position: relative;
}

.mirb-grid-title {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 15px;
    color: #212121;
    display: block;
}

.mirb-grid-subtitle {
    text-align: center;
    font-size: 16px;
    color: #666;
    margin: 0 0 30px;
    display: block;
}

.mirb-grid-container {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 0;
}

/* Column configurations */
.mirb-grid-cols-1 {
    grid-template-columns: 1fr;
}

.mirb-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.mirb-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.mirb-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Grid Item */
.mirb-grid-item {
    display: block;
    text-decoration: none;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.mirb-grid-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.mirb-grid-item-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
}

.mirb-grid-item-image {
    width: 100%;
    height: 250px;
    overflow: hidden;
    position: relative;
    background: #f5f5f5;
    display: block;
}

.mirb-grid-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.mirb-grid-item:hover .mirb-grid-item-image img {
    transform: scale(1.05);
}

.mirb-grid-item-title {
    padding: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #212121;
    background: #fff;
    display: block;
}

/* Grid Footer */
.mirb-grid-footer {
    margin-top: 30px;
    padding: 25px 20px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    display: block;
}

.mirb-grid-footer-line,
.mirb-grid-footer-highlight {
    display: block;
    margin: 5px 0;
    font-size: 15px;
    color: #555;
    line-height: 1.6;
}

.mirb-grid-footer-line:first-child {
    font-size: 16px;
    color: #333;
}

.mirb-grid-footer-highlight {
    font-weight: 600;
    color: #2271b1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
    font-size: 16px;
}

/* Error message */
.mirb-grid-error {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .mirb-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mirb-grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .mirb-grid-container {
        gap: 15px;
    }
    
    /* MANTÉM 2 COLUNAS NO MOBILE - NÃO EMPILHA.
       cols-1 incluído (v1.3.0): antes ficava 1 coluna em 481–768px e virava 2
       só abaixo de 480px — incoerência herdada, não intenção responsiva. */
    .mirb-grid-cols-1,
    .mirb-grid-cols-2,
    .mirb-grid-cols-3,
    .mirb-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mirb-grid-title {
        font-size: 22px;
        margin-bottom: 10px;
    }
    
    .mirb-grid-subtitle {
        font-size: 13px;
        margin-bottom: 20px;
    }
    
    .mirb-grid-item-image {
        height: 180px;
    }
    
    .mirb-grid-item-title {
        padding: 12px 8px;
        font-size: 14px;
    }
    
    /* Footer ajustado para mobile */
    .mirb-grid-footer {
        margin-top: 20px;
        padding: 20px 15px;
    }
    
    .mirb-grid-footer-line,
    .mirb-grid-footer-highlight {
        font-size: 13px;
    }
    
    .mirb-grid-footer-line:first-child {
        font-size: 14px;
    }
    
    .mirb-grid-footer-highlight {
        font-size: 14px;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    /* MANTÉM 2 COLUNAS MESMO EM TELAS PEQUENAS */
    .mirb-grid-cols-1,
    .mirb-grid-cols-2,
    .mirb-grid-cols-3,
    .mirb-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mirb-grid-container {
        gap: 10px;
    }
    
    .mirb-grid-title {
        font-size: 20px;
    }
    
    .mirb-grid-subtitle {
        font-size: 12px;
    }
    
    .mirb-grid-item-image {
        height: 150px;
    }
    
    .mirb-grid-item-title {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    .mirb-grid-footer {
        padding: 15px 10px;
    }
    
    .mirb-grid-footer-line,
    .mirb-grid-footer-highlight {
        font-size: 12px;
    }
}

/* Loading state */
.mirb-grid-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* No items state */
.mirb-grid-wrapper.empty {
    text-align: center;
    padding: 40px;
    background: #f9f9f9;
    border-radius: 8px;
}

.mirb-grid-wrapper.empty .mirb-grid-error {
    background: transparent;
    border: none;
    color: #666;
    font-size: 16px;
}

/* =========================================================================
 * Variantes de estilo MBZ (Fase 3)
 *
 * Ativadas pela classe mirb-grid-style-{variant} no wrapper (emitida pelo
 * renderer). Sem classe de variante = visual clássico intocado ("default").
 * Cada variante é escopada no próprio wrapper: múltiplos grids na mesma
 * página não interferem entre si. Paleta MBZ (§3 do AGENTS.md).
 * ========================================================================= */

/* Acessibilidade transversal (não altera o visual em repouso).
   Anel ESCURO nas superfícies claras — #06B6D4 puro sobre branco mede ~2,4:1
   e reprova o mínimo de 3:1 para indicador não textual; o ciano fica como
   glow secundário. Variantes de fundo escuro trocam para anel claro. */
.mirb-grid-item:focus-visible {
    outline: 3px solid #164E63;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(6, 182, 212, 0.35);
}

.mirb-grid-style-cyberpunk .mirb-grid-item:focus-visible,
.mirb-grid-style-neon .mirb-grid-item:focus-visible,
.mirb-grid-style-dark .mirb-grid-item:focus-visible,
.mirb-grid-style-vivid .mirb-grid-item:focus-visible {
    outline-color: #F9FAFB;
}

@media (prefers-reduced-motion: reduce) {
    .mirb-grid-item,
    .mirb-grid-item-image img {
        transition: none;
    }

    .mirb-grid-item:hover {
        transform: none;
    }

    .mirb-grid-item:hover .mirb-grid-item-image img {
        transform: none;
    }
}

/* ===== ⚡ Cyberpunk ===== */
.mirb-grid-wrapper.mirb-grid-style-cyberpunk {
    background: #111827;
    padding: 30px 20px;
    border-radius: 12px;
    border: 1px solid #374151;
    box-shadow: 0 0 24px rgba(236, 72, 153, 0.25), inset 0 0 60px rgba(91, 33, 182, 0.12);
}

.mirb-grid-style-cyberpunk .mirb-grid-title {
    color: #EC4899; /* fallback sem background-clip */
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mirb-grid-style-cyberpunk .mirb-grid-subtitle {
    color: #9CA3AF;
}

.mirb-grid-style-cyberpunk .mirb-grid-item {
    background: #1F2937;
    border: 1px solid #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.mirb-grid-style-cyberpunk .mirb-grid-item:hover {
    border-color: #EC4899;
    box-shadow: 0 0 18px rgba(236, 72, 153, 0.45);
}

.mirb-grid-style-cyberpunk .mirb-grid-item-image {
    background: #111827;
}

.mirb-grid-style-cyberpunk .mirb-grid-item-title {
    background: #1F2937;
    color: #F9FAFB;
}

.mirb-grid-style-cyberpunk .mirb-grid-footer {
    background: #1F2937;
    border-color: #374151;
}

.mirb-grid-style-cyberpunk .mirb-grid-footer-line {
    color: #D1D5DB;
}

.mirb-grid-style-cyberpunk .mirb-grid-footer-line:first-child {
    color: #E5E7EB;
}

.mirb-grid-style-cyberpunk .mirb-grid-footer-highlight {
    color: #22D3EE;
}

/* ===== 🌟 Neon ===== */
.mirb-grid-wrapper.mirb-grid-style-neon {
    background: #0B1120;
    padding: 30px 20px;
    border-radius: 12px;
    border: 1px solid #06B6D4;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.35);
}

.mirb-grid-style-neon .mirb-grid-title {
    color: #22D3EE;
    text-shadow: 0 0 12px rgba(6, 182, 212, 0.65);
    letter-spacing: 1.5px;
}

.mirb-grid-style-neon .mirb-grid-subtitle {
    color: #9CA3AF;
}

.mirb-grid-style-neon .mirb-grid-item {
    background: #0F172A;
    border: 1px solid #06B6D4;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.25);
}

.mirb-grid-style-neon .mirb-grid-item:hover {
    box-shadow: 0 0 22px rgba(6, 182, 212, 0.6);
}

.mirb-grid-style-neon .mirb-grid-item-image {
    background: #0B1120;
}

.mirb-grid-style-neon .mirb-grid-item-title {
    background: #0F172A;
    color: #E0F2FE;
}

.mirb-grid-style-neon .mirb-grid-footer {
    background: #0F172A;
    border-color: #06B6D4;
}

.mirb-grid-style-neon .mirb-grid-footer-line {
    color: #BAE6FD;
}

.mirb-grid-style-neon .mirb-grid-footer-line:first-child {
    color: #E0F2FE;
}

.mirb-grid-style-neon .mirb-grid-footer-highlight {
    color: #22D3EE;
    text-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

/* ===== 🪟 Glass ===== */
/* Opacidade alta (0.88+): sobre página escura, 0.55 virava cinza médio e o
   subtítulo #374151 caía para ~3:1 */
.mirb-grid-wrapper.mirb-grid-style-glass {
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    padding: 30px 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 8px 32px rgba(17, 24, 39, 0.12);
}

.mirb-grid-style-glass .mirb-grid-title {
    color: #111827;
}

.mirb-grid-style-glass .mirb-grid-subtitle {
    color: #374151;
}

.mirb-grid-style-glass .mirb-grid-item {
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 16px rgba(17, 24, 39, 0.1);
}

.mirb-grid-style-glass .mirb-grid-item:hover {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 8px 24px rgba(91, 33, 182, 0.2);
}

.mirb-grid-style-glass .mirb-grid-item-title {
    background: transparent;
    color: #111827;
}

.mirb-grid-style-glass .mirb-grid-footer {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.8);
}

.mirb-grid-style-glass .mirb-grid-footer-highlight {
    color: #5B21B6;
}

/* ===== 🌑 Dark ===== */
.mirb-grid-wrapper.mirb-grid-style-dark {
    background: #1F2937;
    padding: 30px 20px;
    border-radius: 12px;
    border: 1px solid #374151;
}

.mirb-grid-style-dark .mirb-grid-title {
    color: #F9FAFB;
}

.mirb-grid-style-dark .mirb-grid-subtitle {
    color: #9CA3AF;
}

.mirb-grid-style-dark .mirb-grid-item {
    background: #111827;
    border: 1px solid #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.mirb-grid-style-dark .mirb-grid-item:hover {
    border-color: #6B7280;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.mirb-grid-style-dark .mirb-grid-item-image {
    background: #1F2937;
}

.mirb-grid-style-dark .mirb-grid-item-title {
    background: #111827;
    color: #E5E7EB;
}

.mirb-grid-style-dark .mirb-grid-footer {
    background: #111827;
    border-color: #374151;
}

.mirb-grid-style-dark .mirb-grid-footer-line {
    color: #D1D5DB;
}

.mirb-grid-style-dark .mirb-grid-footer-line:first-child {
    color: #E5E7EB;
}

.mirb-grid-style-dark .mirb-grid-footer-highlight {
    color: #F9FAFB;
}

/* ===== 🎨 Vivid ===== */
/* Gradiente termina em tons escuros (#BE185D/#C2410C, não #EC4899/#F97316):
   branco sobre #EC4899 mede ~3,5:1 e sobre #F97316 ~2,8:1 — reprova AA */
.mirb-grid-wrapper.mirb-grid-style-vivid {
    background: linear-gradient(135deg, #5B21B6 0%, #BE185D 55%, #C2410C 100%);
    padding: 30px 20px;
    border-radius: 12px;
}

.mirb-grid-style-vivid .mirb-grid-title {
    color: #FFFFFF;
    text-shadow: 0 2px 8px rgba(17, 24, 39, 0.35);
}

.mirb-grid-style-vivid .mirb-grid-subtitle {
    color: rgba(255, 255, 255, 0.92);
}

.mirb-grid-style-vivid .mirb-grid-item {
    background: #FFFFFF;
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 16px rgba(17, 24, 39, 0.25);
}

.mirb-grid-style-vivid .mirb-grid-item:hover {
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.4);
}

.mirb-grid-style-vivid .mirb-grid-item-title {
    color: #111827;
}

.mirb-grid-style-vivid .mirb-grid-footer {
    background: rgba(17, 24, 39, 0.82);
    border-color: rgba(255, 255, 255, 0.25);
}

.mirb-grid-style-vivid .mirb-grid-footer-line {
    color: #FFFFFF;
}

.mirb-grid-style-vivid .mirb-grid-footer-line:first-child {
    color: #FFFFFF;
}

.mirb-grid-style-vivid .mirb-grid-footer-highlight {
    color: #FBBF24;
    text-shadow: 0 1px 4px rgba(17, 24, 39, 0.45);
}

/* ===== 🌈 Gradient ===== */
.mirb-grid-wrapper.mirb-grid-style-gradient {
    background: linear-gradient(135deg, rgba(91, 33, 182, 0.08) 0%, rgba(236, 72, 153, 0.08) 100%);
    padding: 30px 20px;
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.35);
}

.mirb-grid-style-gradient .mirb-grid-title {
    color: #5B21B6; /* fallback sem background-clip */
    background: linear-gradient(135deg, #5B21B6 0%, #EC4899 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mirb-grid-style-gradient .mirb-grid-subtitle {
    color: #4B5563;
}

.mirb-grid-style-gradient .mirb-grid-item {
    background: #FFFFFF;
    border: 2px solid #8B5CF6;
    box-shadow: 0 2px 10px rgba(91, 33, 182, 0.15);
}

.mirb-grid-style-gradient .mirb-grid-item:hover {
    border-color: #EC4899;
    box-shadow: 0 6px 22px rgba(236, 72, 153, 0.3);
}

.mirb-grid-style-gradient .mirb-grid-item-title {
    color: #111827;
}

.mirb-grid-style-gradient .mirb-grid-footer {
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.35);
}

.mirb-grid-style-gradient .mirb-grid-footer-highlight {
    color: #BE185D;
}

/* Ajuste responsivo comum às variantes com wrapper "cheio" */
@media (max-width: 480px) {
    .mirb-grid-wrapper.mirb-grid-style-cyberpunk,
    .mirb-grid-wrapper.mirb-grid-style-neon,
    .mirb-grid-wrapper.mirb-grid-style-glass,
    .mirb-grid-wrapper.mirb-grid-style-dark,
    .mirb-grid-wrapper.mirb-grid-style-vivid,
    .mirb-grid-wrapper.mirb-grid-style-gradient {
        padding: 20px 12px;
    }
}