/* =========================================
   1. تنظیمات کلی کپچا (Form Group)
   ========================================= */
.custom-captcha-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.custom-captcha-legend {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    border-bottom: 2px solid #e63946;
    padding-bottom: 5px;
    margin-bottom: 15px;
    display: inline-block;
}

.custom-captcha-group {
    margin-bottom: 15px;
}

.custom-captcha-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    display: block;
    font-size: 14px;
}

/* =========================================
   2. چیدمان فیلد و تصویر (حالت عادی و دسکتاپ)
   ========================================= */
.custom-captcha-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 100%;
}

.custom-captcha-input {
    flex: 1;
    height: 46px;
    border-radius: 8px !important;
    border: 1px solid #ddd;
    padding: 10px 15px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    text-align: center;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
}

.custom-captcha-input::placeholder {
    font-family: inherit;
    font-weight: 400;
    color: #999;
}

.custom-captcha-input:focus {
    border-color: #e63946;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
    background-color: #fff;
    outline: none;
}

/* =========================================
   3. استایل کادر تصویر کپچا
   ========================================= */
.captcha-image-box {
    height: 46px;
    border-radius: 8px;
    border: 1px solid #ddd;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9f9f9;
    transition: all 0.3s ease;
    position: relative;
}

.captcha-image-box:hover {
    border-color: #e63946;
    background-color: #fff;
}

.captcha-image-box img {
    height: 100%;
    width: auto;
    display: block;
    object-fit: cover;
}

/* آیکون رفرش (↻) */
.captcha-image-box::after {
    content: '↻';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 14px;
    color: #999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.captcha-image-box:hover::after {
    opacity: 1;
}

.custom-captcha-error {
    margin-top: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #e63946;
}

/* =========================================
   4. استایل پایه فوتر (خبرنامه) - دسکتاپ
   ========================================= */
.input-captcha {
    width: 100%;
}

.input-captcha .custom-captcha-fieldset {
    margin-bottom: 10px;
}

.input-captcha .custom-captcha-label {
    font-size: 13px;
    margin-bottom: 5px;
    display: block;
}

.input-captcha .custom-captcha-wrapper {
    display: flex !important;
    flex-direction: row !important; /* در دسکتاپ کنار هم */
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
}

.input-captcha .custom-captcha-input {
    flex: 1 !important;
    height: 40px !important;
    font-size: 13px !important;
    margin-bottom: 0 !important;
    background-color: #fff !important;
}

.input-captcha .captcha-image-box {
    width: auto !important;
    height: 40px !important;
    justify-content: center !important;
    background-color: #fff !important;
}

/* =========================================
   5. ریسپانسیو و اصلاح قطعی برای موبایل (فرم‌ها و فوتر)
   ========================================= */
@media (max-width: 575px) {
    /* --- استایل فرم‌های اصلی در موبایل --- */
    .custom-captcha-wrapper {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .custom-captcha-input {
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
        margin: 0 !important;
        margin-bottom: 0 !important;
        padding: 10px 15px !important;
        height: 46px !important;
        
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-bottom: none !important;
    }
    
    .captcha-image-box {
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
        height: 46px !important;
        margin: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
        
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-top: 1px solid #ddd !important;
        
        justify-content: center !important;
        background-color: #f9f9f9 !important;
    }
    
    .captcha-image-box img {
        height: 100% !important;
        width: auto !important;
        margin: 0 auto !important;
    }

    /* --- اصلاح مخصوص فوتر در موبایل --- */
    /* بازنویسی قوانین فوتر برای چیدمان ستونی و یکپارچه */
    .input-captcha .custom-captcha-wrapper {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important; /* حذف فاصله */
        width: 100% !important;
    }

    .input-captcha .custom-captcha-input {
        width: 100% !important;
        height: 46px !important; /* هم‌ارتفاع با فرم‌های اصلی */
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-bottom: none !important;
    }

    .input-captcha .captcha-image-box {
        width: 100% !important;
        height: 46px !important;
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-top: 1px solid #ddd !important;
        justify-content: center !important;
        background-color: #f9f9f9 !important;
    }
}