/* =========================================================
   1. CABEÇALHO PRINCIPAL DA PÁGINA (Para o shortcode principal)
   ========================================================= */
.ae-agenda-container-global { width: 100%; }
.ae-header-main { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; font-family: sans-serif; }
.ae-header-text h2 { margin: 0 0 5px 0; font-size: 32px; color: var(--ae-main-cor-titulo, #1a202c); font-weight: 900; }
.ae-header-text p { margin: 0; color: var(--ae-main-cor-subtitulo, #718096); font-size: 16px; }
.ae-btn-completo {
    background-color: var(--ae-main-cor-btn-fundo, #1a365d); 
    color: var(--ae-main-cor-btn-texto, #ffffff); 
    padding: 12px 24px; border-radius: 30px; text-decoration: none; font-weight: bold; font-size: 14px; transition: filter 0.2s;
}
.ae-btn-completo:hover { filter: brightness(0.85); }

/* =========================================================
   2. CONTAINER DO CALENDÁRIO PRINCIPAL (Box Branco)
   ========================================================= */
.ae-wrap { font-family: sans-serif; background: #ffffff; padding: 30px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }

.ae-calendar-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.ae-view-toggle { display: flex; background-color: #f1f5f9; padding: 4px; border-radius: 8px; }
.ae-view-toggle button { background: transparent; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; color: #64748b; font-size: 14px; transition: all 0.2s; }
.ae-view-toggle button.active { background: #ffffff; color: #0f172a; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.ae-nav { display: flex; align-items: center; gap: 15px; }
.ae-nav-arrow { font-size: 24px; color: #64748b; cursor: pointer; user-select: none; padding: 0 5px; }
.ae-nav-arrow:hover { color: #000; }
.ae-nav-label { font-size: 18px; font-weight: bold; color: #1a202c; min-width: 200px; text-align: center; }

/* ---------------------------------------------------------
   EXIBIÇÃO MENSAL (Grade Fixa)
--------------------------------------------------------- */
.ae-dias-semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; text-align: center; font-weight: 600; color: #4a5568; margin-bottom: 10px; font-size: 14px; }
.ae-calendario-render, 
.ae-calendario-render.ae-is-mensal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }

/* ---------------------------------------------------------
   EXIBIÇÃO SEMANAL (Flex com Arrasto/Swipe)
--------------------------------------------------------- */
.ae-calendario-render.ae-is-semanal {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 15px;
    padding-bottom: 10px;
    user-select: none;
}
.ae-calendario-render.ae-is-semanal::-webkit-scrollbar { height: 8px; }
.ae-calendario-render.ae-is-semanal::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 4px; }

/* NOVO: Largura da coluna semanal no Desktop mostra todos os 7 dias exatos */
.ae-calendario-render.ae-is-semanal .ae-dia {
    flex: 1; /* Divide o espaço igualmente entre os 7 dias */
    min-width: 0; /* Remove a trava para encaixar perfeitamente */
    scroll-snap-align: start;
}

.ae-dia { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; min-height: 150px; display: flex; flex-direction: column; min-width: 0; }
.ae-dia-header { font-size: 14px; color: #4a5568; margin-bottom: 10px; }
.ae-dia-numero { font-size: 14px; color: #4a5568; margin-bottom: 10px; font-weight: 600; }
.ae-dia-vazio { background: #f8fafc; border: 1px solid transparent; }

/* ---------------------------------------------------------
   CONFIGURAÇÃO 1: TAMANHOS DO CARD (DESKTOP)
--------------------------------------------------------- */
.ae-card { 
    padding: 8px; margin-bottom: 6px; border-radius: 4px; color: #fff; cursor: pointer; transition: transform 0.2s; 
    box-sizing: border-box; overflow: hidden; 
    
    /* Configuração MENSAL (Menor, Largura Restrita) */
    width: 100%; 
    max-width: 140px; 
    height: 65px; 
    min-height: 65px; 
    
    font-size: 11px; 
    line-height: 1.3; 
}
.ae-card:hover { transform: scale(1.02); opacity: 0.95; }
.ae-card strong { display: block; font-size: 12px; margin-bottom: 2px; }

/* Configuração SEMANAL (O Dobro de Altura, Preenche o bloco, Permite quebra de linha) */
.ae-calendario-render.ae-is-semanal .ae-card {
    height: 130px !important;
    min-height: 130px !important;
    max-width: 100% !important; 
    white-space: normal !important;
}

.ae-interno { background-color: #28a745; }
.ae-externo { background-color: #0056b3; }
.ae-sem-itens { color: #a0aec0; font-size: 12px; padding-top: 5px; }
.ae-legenda { margin-top: 30px; font-size: 14px; display: flex; gap: 15px; align-items: center; border-top: 1px solid #e2e8f0; padding-top: 15px; }

/* =========================================================
   3. MODAL / POPUP DE DETALHES
   ========================================================= */
.ae-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 9999; }
.ae-modal-content { background: #fff; padding: 25px; border-radius: 12px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; position: relative; font-family: sans-serif; }
.ae-close { position: absolute; right: 15px; top: 10px; font-size: 28px; cursor: pointer; color: #a0aec0; z-index: 10; background: rgba(255,255,255,0.8); border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; line-height: 1; }
.ae-close:hover { color: #1a202c; background: #e2e8f0; }

/* Estilo da Imagem Retangular no Modal (Contain) */
.ae-modal-imagem {
    width: 100%;
    height: 150px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f1f5f9;
    display: flex;
    justify-content: center;
}
.ae-modal-imagem img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* =========================================================
   4. BOX: PRÓXIMOS EVENTOS (Widget Lateral Customizado)
   ========================================================= */
.ae-box-proximos { background-color: var(--ae-cor-fundo, #0b3024); max-width: var(--ae-largura, 400px); height: var(--ae-altura, auto); font-family: var(--ae-fonte, sans-serif); padding: 24px; border-radius: 12px; box-sizing: border-box; display: flex; flex-direction: column; }
.ae-box-titulo { color: var(--ae-cor-texto, #ffffff); font-size: var(--ae-tamanho-titulo, 24px); font-weight: 800; margin: 0 0 16px 0; }
.ae-box-lista { display: flex; flex-direction: column; gap: 12px; flex-grow: 1; }
.ae-box-card { text-decoration: none; padding: 16px; border-radius: 8px; display: block; transition: transform 0.2s, opacity 0.2s; width: var(--ae-box-card-w, 100%); min-height: var(--ae-box-card-h, auto); box-sizing: border-box; }
.ae-box-card:hover { transform: translateY(-2px); opacity: 0.95; }
.ae-box-interno { background-color: #28a745; color: #ffffff; }
.ae-box-externo { background-color: #0056b3; color: #ffffff; }
.ae-box-meta { font-size: 12px; margin-bottom: 6px; font-weight: 600; color: rgba(255, 255, 255, 0.9); }
.ae-box-title { font-size: var(--ae-tamanho-fonte, 15px); font-weight: bold; line-height: 1.3; }
.ae-box-legenda { margin-top: 16px; font-size: 12px; color: var(--ae-cor-texto, #ffffff); display: flex; gap: 12px; align-items: center; }
.ae-badge { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.ae-badge.verde { background-color: #28a745; }
.ae-badge.azul { background-color: #0056b3; }
.ae-btn-vertodos { display: block; background-color: var(--ae-cor-botao-fundo, #ffffff); color: var(--ae-cor-botao, #c05a26); text-align: center; padding: 14px; border-radius: 30px; text-decoration: none; font-weight: bold; font-size: 16px; margin-top: 24px; transition: filter 0.2s; }
.ae-btn-vertodos:hover { filter: brightness(0.9); }

/* =========================================================
   5. NOVO SHORTCODE: LISTAGEM DE EVENTOS DINÂMICA
   ========================================================= */
.ae-lista-filtrada-container { display: flex; gap: 30px; font-family: var(--ae-lista-fonte, sans-serif); color: #333; max-width: 1200px; margin: 0 auto; }

.ae-sidebar-filtros { width: var(--ae-lista-sidebar-largura, 220px); flex-shrink: 0; background: #fff; padding: 25px; border-radius: 12px; border: 1px solid #e5e7eb; box-shadow: 0 1px 4px rgba(0,0,0,0.02); height: fit-content; }
.ae-sidebar-filtros h3 { margin-top: 0; margin-bottom: 5px; font-size: 20px; color: #111827; font-weight: bold; }
.ae-sidebar-filtros p { font-size: 13px; color: #6b7280; margin-bottom: 25px; }

.ae-filtro-busca input { width: 100%; padding: 12px 12px 12px 35px; border: 1px solid #d1d5db; border-radius: 8px; margin-bottom: 25px; outline: none; box-sizing: border-box; color: #374151; font-family: inherit; font-size: var(--ae-lista-tamanho-texto, 14px); }
.ae-filtro-busca input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.ae-filtro-grupo { margin-bottom: 24px; }
.ae-filtro-grupo h4 { margin: 0 0 12px 0; font-size: 15px; color: #374151; font-weight: 600; }
.ae-filtro-grupo label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: var(--ae-lista-tamanho-texto, 14px); color: #4b5563; cursor: pointer; }
.ae-filtro-grupo input[type="radio"] { cursor: pointer; margin: 0; width: 16px; height: 16px; accent-color: #3b82f6; }

.ae-resultados-main { flex-grow: 1; }
.ae-resultados-header { background: transparent; border: none; box-shadow: none; display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 25px; padding-bottom: 15px; }
.ae-header-info h2 { margin: 0 0 8px 0; font-weight: bold; color: #111827; font-size: var(--ae-lista-tamanho-titulo, 26px); }
.ae-header-info p { margin: 0 0 12px 0; color: #6b7280; font-size: var(--ae-lista-tamanho-texto, 14px); }

.ae-controles-layout { display: flex; gap: 4px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px; }
.ae-btn-layout { display: flex; align-items: center; gap: 6px; border: none; background: transparent; padding: 8px 16px; cursor: pointer; border-radius: 6px; font-size: 14px; font-weight: 500; color: #64748b; transition: all 0.2s; font-family: inherit; }
.ae-btn-layout:hover { color: #0f172a; }
.ae-btn-layout.ativo { background: #ffffff; color: #0f172a; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.ae-tags-ativas { display: flex; gap: 10px; }
.ae-tag { padding: 4px 14px; border-radius: 20px; font-size: 12px; font-weight: bold; }
.ae-tag-crp { background: #e6f4ea; color: #166534; }
.ae-tag-parceiro { background: #e0e7ff; color: #3730a3; }

.ae-evento-item { border-radius: 12px; overflow: hidden; color: #ffffff; text-decoration: none; display: flex; box-shadow: 0 4px 10px rgba(0,0,0,0.06); transition: transform 0.2s, box-shadow 0.2s; }
.ae-evento-item:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }
.ae-evento-item.interno { background-color: var(--ae-lista-cor-fundo-crp, #1b9e4a); }
.ae-evento-item.externo { background-color: var(--ae-lista-cor-fundo-parceiro, #2b65e3); }
.ae-evento-imagem { position: relative; background-color: #f8fafc; overflow: hidden; }
.ae-evento-imagem img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.ae-evento-conteudo { position: relative; display: flex; flex-direction: column; background: transparent; }

.ae-badge-topo { background: #ffffff; padding: 4px 12px; border-radius: 15px; font-size: 12px; font-weight: 700; display: inline-block; }
.ae-evento-item.interno .ae-badge-topo { color: var(--ae-lista-cor-fundo-crp, #1b9e4a); }
.ae-evento-item.externo .ae-badge-topo { color: var(--ae-lista-cor-fundo-parceiro, #2b65e3); }

.ae-evento-conteudo h3 { margin: 0 0 12px 0; color: #ffffff; font-weight: bold; line-height: 1.35; font-size: var(--ae-lista-tamanho-titulo-card, 18px); }
.ae-evento-detalhes { display: flex; gap: 15px; flex-wrap: wrap; margin-bottom: 12px; opacity: 0.95; font-weight: 500; font-size: var(--ae-lista-tamanho-texto, 14px); }
.ae-evento-detalhes span { display: flex; align-items: center; gap: 5px; }
.ae-evento-resumo { opacity: 0.9; margin: 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--ae-lista-tamanho-texto, 14px); }

/* MODO CARDS */
.ae-view-cards { display: grid; gap: 25px; grid-template-columns: repeat(auto-fill, minmax(var(--ae-lista-card-largura-min, 290px), 1fr)); }
.ae-view-cards .ae-evento-item { flex-direction: column; }
.ae-view-cards .ae-evento-imagem { width: 100%; margin: 0; border-radius: 0; height: var(--ae-lista-imagem-altura, 180px); }
.ae-view-cards .ae-evento-conteudo { padding: 20px; }
.ae-view-cards .ae-evento-meta-topo { position: absolute; top: 20px; right: 20px; margin: 0; }
.ae-view-cards .ae-evento-conteudo h3 { padding-right: 70px; } 
.ae-view-cards .ae-data-right { display: none; } 

/* MODO LISTA */
.ae-view-lista { display: flex; flex-direction: column; gap: 20px; }
.ae-view-lista .ae-evento-item { flex-direction: row; align-items: stretch; padding: 20px; width: var(--ae-lista-card-w-lista, 100%); min-height: var(--ae-lista-card-h-lista, auto); box-sizing: border-box; }
.ae-view-lista .ae-evento-imagem { width: var(--ae-lista-largura-img-lista, 280px); min-height: var(--ae-lista-altura-img-lista, 180px); flex-shrink: 0; margin-right: 25px; border-radius: 8px; }
.ae-view-lista .ae-evento-imagem img { border-radius: 8px; }
.ae-view-lista .ae-evento-conteudo { padding: 0; flex-grow: 1; justify-content: center; }
.ae-view-lista .ae-evento-meta-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; position: relative; top: auto; right: auto; }
.ae-view-lista .ae-data-right { display: block; font-size: 16px; font-weight: 700; opacity: 0.95; }
.ae-view-lista .ae-evento-conteudo h3 { padding-right: 0; font-size: calc(var(--ae-lista-tamanho-titulo-card, 18px) + 4px); }


/* =========================================================
   6. RESPONSIVIDADE E DIMENSIONAMENTOS MOBILE/DESKTOP
   ========================================================= */

/* ---------------------------------------------------------
   CONFIGURAÇÃO 2: TAMANHO DO CARD - DESKTOP MÉDIO / NOTEBOOKS
--------------------------------------------------------- */
@media (max-width: 1024px) {
    .ae-calendario-render { gap: 6px; }
    .ae-dias-semana { gap: 6px; font-size: 12px; }
    .ae-dia { padding: 6px; min-height: 100px; }

    /* Mensal */
    .ae-card {
        height: 52px !important;
        min-height: 52px !important;
        padding: 6px !important;
        font-size: 10px !important;
    }
    .ae-card strong {
        font-size: 11px !important;
    }

    /* Semanal - Dobro */
    .ae-calendario-render.ae-is-semanal .ae-card {
        height: 104px !important;
        min-height: 104px !important;
    }
}

/* Responsividade da Listagem Filtrada */
@media (max-width: 850px) {
    .ae-lista-filtrada-container { flex-direction: column; }
    .ae-sidebar-filtros { width: 100%; box-sizing: border-box; margin-bottom: 20px; }
    .ae-resultados-header { flex-direction: column; align-items: flex-start; gap: 15px; padding-bottom: 5px; }
    
    .ae-view-lista .ae-evento-item { flex-direction: column; padding: 0; width: 100%; min-height: auto; }
    .ae-view-lista .ae-evento-imagem { width: 100%; min-height: auto; margin: 0; border-radius: 0; height: calc(var(--ae-lista-imagem-altura, 180px) + 20px); }
    .ae-view-lista .ae-evento-imagem img { border-radius: 0; }
    .ae-view-lista .ae-evento-conteudo { padding: 20px; }
    .ae-view-lista .ae-evento-meta-topo { position: absolute; top: 20px; right: 20px; margin: 0; display: block; }
    .ae-view-lista .ae-data-right { display: none; }
    .ae-view-lista .ae-evento-conteudo h3 { padding-right: 70px; font-size: var(--ae-lista-tamanho-titulo-card, 18px); }
}

/* ---------------------------------------------------------
   CONFIGURAÇÃO 3: TAMANHO DO CARD - CELULARES GRANDES / TABLETS
--------------------------------------------------------- */
@media (max-width: 768px) {
    /* Regra do SWIPE para o calendário semanal (Mobile) */
    .ae-calendario-render.ae-is-semanal .ae-dia {
        flex: 0 0 60%; /* Ocupa 60% da tela, mantendo o arraste para o lado */
        min-width: unset;
    }

    .ae-calendario-render { gap: 4px; }
    .ae-dias-semana { gap: 4px; font-size: 11px; }
    .ae-dia { padding: 4px; min-height: 80px; }
    .ae-dia-header, .ae-dia-numero { font-size: 11px; margin-bottom: 4px; }

    /* Mensal (Estilo Etiqueta Limpa) */
    .ae-card {
        height: 40px !important; 
        min-height: 40px !important;
        padding: 6px !important;
        font-size: 10px !important;
        line-height: 1.2 !important;
        white-space: nowrap; 
        overflow: hidden;
        text-overflow: ellipsis; 
    }
    .ae-card strong {
        display: block !important; 
        font-size: 10px !important;
        margin-right: 0;
        margin-bottom: 2px;
    }

    /* Semanal - Dobro da altura (Permite quebra de linha pois tem mais espaço) */
    .ae-calendario-render.ae-is-semanal .ae-card {
        height: 80px !important;
        min-height: 80px !important;
        white-space: normal !important; 
    }
}

/* ---------------------------------------------------------
   CONFIGURAÇÃO 4: TAMANHO DO CARD - CELULARES PADRÃO E PEQUENOS
--------------------------------------------------------- */
@media (max-width: 400px) {
    /* Mensal */
    .ae-card {
        height: 24px !important; 
        min-height: 24px !important;
        padding: 4px !important;
        font-size: 9px !important;
        line-height: 16px !important;
    }
    .ae-card strong {
        display: inline-block !important; 
        font-size: 9px !important;
        margin-right: 4px;
        margin-bottom: 0 !important;
    }

    /* Semanal - Dobro da altura */
    .ae-calendario-render.ae-is-semanal .ae-card {
        height: 48px !important;
        min-height: 48px !important;
        white-space: normal !important; 
        line-height: 1.2 !important;
    }
    
    /* Semanal: Como tem mais altura, joga o título pra linha de baixo da hora */
    .ae-calendario-render.ae-is-semanal .ae-card strong {
        display: block !important;
        margin-bottom: 2px !important;
    }
}