/**
 * TurboJet - Estilos para Modal
 * v2.0 - Adicionados estilos para posicionamento customizável e melhorias de estilização.
 */

.tj-modal-trigger-button,
a.tj-modal-trigger {
    /* Estilos do botão/gatilho permanecem os mesmos */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.tj-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none; /* Controlado por JS */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    /* O background-color é aplicado inline via shortcode */
}

.tj-modal-overlay.tj-modal-visible {
    display: flex; /* MANTIDO: display:flex é crucial para o posicionamento */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* --- NOVAS REGRAS DE POSICIONAMENTO --- */
/* Padrão (Centro) */
.tj-modal-position-center {
    align-items: center;
    justify-content: center;
}
/* Alinhamentos no Topo */
.tj-modal-position-top-left {
    align-items: flex-start;
    justify-content: flex-start;
}
.tj-modal-position-top-center {
    align-items: flex-start;
    justify-content: center;
}
.tj-modal-position-top-right {
    align-items: flex-start;
    justify-content: flex-end;
}
/* Alinhamentos na Base */
.tj-modal-position-bottom-left {
    align-items: flex-end;
    justify-content: flex-start;
}
.tj-modal-position-bottom-center {
    align-items: flex-end;
    justify-content: center;
}
.tj-modal-position-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
}
/* Adiciona um padding ao overlay para que as janelas nos cantos não fiquem coladas na borda */
.tj-modal-overlay[class*="top-"],
.tj-modal-overlay[class*="bottom-"] {
    padding: 20px;
    box-sizing: border-box;
}


.tj-modal-window {
    /* background-color, padding, border-radius e border são agora aplicados inline via shortcode */
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative; 
    /* max-width é aplicado inline */
    max-height: 90vh; /* Mantém uma altura máxima para evitar que o modal seja maior que a tela */
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    display: flex; /* Adicionado para garantir que a altura se ajuste ao conteúdo corretamente */
    flex-direction: column;
}

.tj-modal-overlay.tj-modal-visible .tj-modal-window {
    transform: scale(1);
}

.tj-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    flex-shrink: 0; /* Impede que o header encolha */
}

.tj-modal-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.tj-modal-close {
    background: none;
    border: none;
    font-size: 2em;
    font-weight: bold;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 0 5px;
}
.tj-modal-close:hover {
    color: #555;
}

.tj-modal-content {
    /* O conteúdo crescerá para preencher o espaço disponível */
    flex-grow: 1;
}
.tj-modal-content p:last-child {
    margin-bottom: 0;
}

.tj-modal-footer {
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin-top: 15px;
    text-align: right;
    font-size: 0.9em;
    color: #777;
    flex-shrink: 0; /* Impede que o footer encolha */
}

/* Animações (sem alterações) */
.tj-fade-in .tj-modal-window {
    animation: tj-fadeInAnimation 0.3s ease forwards;
}
.tj-fade-out .tj-modal-window {
    animation: tj-fadeOutAnimation 0.3s ease forwards;
}
@keyframes tj-fadeInAnimation {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes tj-fadeOutAnimation {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

/* Responsividade (sem alterações) */
@media (max-width: 768px) {
    .tj-modal-window {
        padding: 15px;
    }
    .tj-modal-title {
        font-size: 1.25em;
    }
}