
\documentclass[12pt]{report}
\usepackage[left=2cm,right=2cm,top=2cm,top=2cm]{geometry} 
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xepersian}
\settextfont{Shabnam}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcommand{\boxn}[2]{%
\begin{center}
\par\bigskip%
\begin{tikzpicture}\setRTL
\node[rounded corners, text width=.95\textwidth, align=justify, inner sep=8pt, outer sep=0] (one)
{\medskip\parbox[t]{\textwidth}{\vspace*{22pt}\par\baselineskip=.9cm #2}};
\node[text=black,anchor=north east,align=center, minimum height=20pt, inner xsep=0pt] (two) at (one.north east) {#1 \hspace*{1mm}};
\path[fill=magenta,draw=magenta]
    ($(one.north west)+(0ex,-4.5pt)$) [rounded corners=3pt] --
    ($(two.north west)+(-22pt,-4.5pt)$) --
    ($(two.south west)+(-4pt,0pt)$) [sharp corners] --
    (two.south east) [rounded corners] --
    (one.north east) --
    (one.north west) [sharp corners] -- cycle;
    \node[text=white,anchor=north east,align=center, minimum height=20pt, inner sep=8pt,inner ysep=6.5pt] (for) at ($(one.north east)+(0,1.5pt)$) {#1\hspace*{0.5mm}};
%
\path[draw=magenta,line width=0.8pt]
    (one.south west) [rounded corners] --
    (one.south east) [rounded corners] --
    (one.north east) --
    (one.north west) [rounded corners] -- cycle;
\foreach \x in {10,20,...,100}
\path[opacity=\x*0.01]
    ($(one.north west)+(0.4pt,-6.5pt+\x/100)$) [rounded corners=3pt,draw=gray!\x] --
    ($(two.north west)+(-23.3pt+\x/100,-6.5pt+\x/100)$) [rounded corners=3.5pt,draw=gray!\x] --
    ($(two.south west)+(-5.3pt+\x/100,-1.9pt+\x/100)$) --
    ($(two.south east)+(-0.4pt,-1.9pt+\x/100)$);
\path[draw=white,line width=1.1pt]
    ($(one.north west)+(0.4pt,-5.2pt)$) [rounded corners=3pt] --
    ($(two.north west)+(-22.3pt,-5.2pt)$) [rounded corners=3.5pt] --
    ($(two.south west)+(-4.3pt,-0.6pt)$) --
    ($(two.south east)+(-0.4pt,-0.6pt)$);
\begin{pgfonlayer}{background}
\path[fill=magenta!5]
    (one.south west) [rounded corners] --
    (one.south east) [rounded corners] --
    (one.north east) --
    (one.north west) [rounded corners] -- cycle;
\path[opacity=0.5, top color=magenta!5,bottom color=magenta,middle color=magenta!30]
    (one.south west) [rounded corners] --
    (one.south east) [sharp corners] --
    ($(one.south east)+(0ex,0.8cm)$) --
    ($(one.south west)+(0ex,0.8cm)$) [rounded corners] -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{center}
}
\begin{document}
\noindent
رسم یک کادر رنگی: 

\boxn{این متن چرا برعکس می‌افتد؟}{
این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست. این یک کادر رنگی هست.}
\end{document}