
    /* -------------------------------------------
       Overlay
       ------------------------------------------- */
    .modal-overlay {
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0, 0, 0, 0.5); 
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .modal-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* -------------------------------------------
       Modal Box
       ------------------------------------------- */
    .modal-box {
        position: relative;
        width: 90%;
        max-width: 450px;
        padding: 40px 30px;
        
        /* نکته کلیدی برای حذف پرش: */
        /* یک بردر شفاف هم‌اندازه با بردر نهایی در نظر می‌گیریم */
        border: 4px solid transparent; 
        
        /* شروع بدون گردی */
        border-radius: 0; 
        
        background: transparent;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        
        /* ترنزیشن برای نرم شدن تغییرات بکگراند، بردر و گردی */
        transition: background 0.5s ease, border-color 0.5s ease, border-radius 0.5s ease, box-shadow 0.5s ease;
    }

    /* حالت پر شده (بعد از انیمیشن خط‌ها) */
    .modal-box.filled {
        background: #fff;
        
        /* اینجا بردر رنگ می‌گیرد (چون قبلا شفاف بود، سایز تغییر نمی‌کند و پرش نداریم) */
        border-color: #283891; 
        
        /* اینجا گوشه‌ها گرد می‌شوند */
        border-radius: 30px; 
        
        box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    }

    /* -------------------------------------------
       Animation Lines (Span)
       ------------------------------------------- */
    .modal-box span {
        position: absolute;
        background: #283891;
        display: block;
        border-radius: 2px; /* کمی نرمی لبه خط‌ها */
        transition: opacity 0.3s ease;
    }

    /* وقتی باکس پر شد، خط‌های انیمیشن محو شوند تا بردر اصلیِ گرد دیده شود */
    .modal-box.filled span {
        opacity: 0;
    }

    /* موقعیت خط‌ها (با توجه به ضخامت بردر 4px تنظیم شده تا دقیق روی خط بیفتد) */
    .modal-box span:nth-child(1) { top: -4px; left: -4px; width: 0; height: 4px; }
    .modal-box span:nth-child(2) { top: -4px; right: -4px; width: 4px; height: 0; }
    .modal-box span:nth-child(3) { bottom: -4px; right: -4px; width: 0; height: 4px; }
    .modal-box span:nth-child(4) { bottom: -4px; left: -4px; width: 4px; height: 0; }

    /* Keyframes */
    .modal-overlay.active .modal-box span:nth-child(1) { animation: animateWidth 0.2s linear forwards; animation-delay: 0.1s; }
    .modal-overlay.active .modal-box span:nth-child(2) { animation: animateHeight 0.2s linear forwards; animation-delay: 0.3s; }
    .modal-overlay.active .modal-box span:nth-child(3) { animation: animateWidth 0.2s linear forwards; animation-delay: 0.5s; }
    .modal-overlay.active .modal-box span:nth-child(4) { animation: animateHeight 0.2s linear forwards; animation-delay: 0.7s; }

    @keyframes animateWidth { 0% { width: calc(100% + 8px); } 100% { width: calc(100% + 8px); } } 
    /* نکته: از width: 0 به 100% انیمیشن می‌شود، اما برای پر کردن کامل گوشه‌ها کمی بیشتر در نظر می‌گیریم */
    @keyframes animateWidth { from { width: 0; } to { width: calc(100% + 8px); } }
    @keyframes animateHeight { from { height: 0; } to { height: calc(100% + 8px); } }


    /* -------------------------------------------
       Close Icon (X)
       ------------------------------------------- */
    .close-icon {
        position: absolute;
        top: 15px;
        right: 20px;
        font-size: 28px;
        color: #666;
        cursor: pointer;
        z-index: 100;
        opacity: 0;
        transform: rotate(-90deg); /* چرخش اولیه برای افکت */
        transition: all 0.4s ease;
    }

    .close-icon:hover {
        color: #dc3545;
        transform: rotate(90deg);
    }

    .modal-box.filled .close-icon {
        opacity: 1;
        transform: rotate(0); /* برگشت به حالت عادی */
        transition-delay: 0.3s;
    }

    /* -------------------------------------------
       Content Visibility
       ------------------------------------------- */
    .modal-content-inner {
        opacity: 0;
        transform: translateY(15px);
        width: 100%;
        text-align: center;
        transition: all 0.4s ease;
    }

    .modal-box.filled .modal-content-inner {
        opacity: 1;
        transform: translateY(0);
        transition-delay: 0.2s;
    }
    
    .btn-custom {
        display: block;
        padding: 10px;
        background: #f8f9fa;
        color: #333;
        border-radius: 8px;
        text-decoration: none;
        border: 1px solid #ddd;
        transition: 0.3s;
    }
    .btn-custom:hover {
        background: #e9ecef;
        border-color: #ccc;
    }

