/**
 * Estilos Base para todos os Modais
 * Define a estrutura, o overlay e o comportamento genérico.
 */

:root {
    --modal-card-radius: 24px;
    --modal-border-color: rgba(44, 48, 29, 0.08);
    --modal-background: #fdfbf7;
    --modal-text-color: #2c301d;
    --modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --transition-speed: 0.5s; /* Um pouco mais lento para a animação ser notada */
    --transition-curve: cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(29, 29, 29, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex; /* Mudar para flex para que a transição funcione com o conteúdo */
    align-items: center; 
    justify-content: center;
    opacity: 0; 
    visibility: hidden; 
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease;
}

.modal-overlay.visible {
    opacity: 1; 
    visibility: visible;
}

.modal-content {
    background: var(--modal-background);
    color: var(--modal-text-color);
    width: 92%;
    max-height: 85vh;
    border-radius: var(--modal-card-radius);
    box-shadow: var(--modal-shadow);
    display: flex; 
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--modal-border-color);
    position: relative;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: transform var(--transition-speed) var(--transition-curve), 
                opacity var(--transition-speed) ease;
}

.modal-overlay.visible .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-close {
    position: absolute; 
    top: 15px; 
    right: 15px;
    background: white;
    border: none;
    width: 44px; 
    height: 44px; 
    border-radius: 50%;
    font-size: 28px; 
    color: var(--modal-text-color);
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: all 0.3s ease; 
    z-index: 101;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.modal-close:hover { 
    background: #f0f0f0; 
    transform: rotate(90deg) scale(1.1); 
}

.modal-body-scrollable {
    flex-grow: 1;
    overflow-y: auto;
}

/* === UX REFINADO PARA MOBILE (Bottom Sheet) === */
@media (max-width: 480px) {
    .modal-overlay {
        /* Modal "nasce" da base da tela */
        align-items: flex-end; 
        padding: 0;
    }

    .modal-content {
        width: 100%;
        /* Altura controlada para não ocupar toda a tela */
        height: 90vh; 
        max-height: 90vh;
        
        /* Arredondamento apenas no topo para criar o efeito "sheet" */
        border-radius: 24px 24px 0 0; 
        border-bottom: none;
        
        /* Animação: Desliza de baixo para cima */
        transform: translateY(100%);
        transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .modal-overlay.visible .modal-content {
        transform: translateY(0);
    }

    /* Botão de fechar mais acessível para o polegar */
    .modal-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 22px;
        background: rgba(255, 255, 255, 0.95);
    }
}
