/**
 * Alibaba Cloud CAPTCHA Styles
 *
 * The SDK renders custom divs (NOT native <input type="checkbox">).
 * SDK elements: #aliyunCaptcha-checkbox-icon, .aliyunCaptcha-checkbox-icon-checked
 * The SDK's own CSS may fail to load due to CSP or be overridden by the Magento theme.
 * These styles provide fallback rendering for the checkbox widget.
 */

/* ============================================================
   CAPTCHA Container
   ============================================================ */
.alibaba-captcha-container {
    margin: 15px 0;
    width: 100%;
}

/* Force CAPTCHA widget to be full width */
.alibaba-captcha-container > div,
#captcha-element > div {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure CAPTCHA area is clickable and on top */
.alibaba-captcha-container,
#captcha-element,
[id^="alibaba-captcha-"] {
    position: relative;
    z-index: 10;
    pointer-events: auto !important;
}

/* ============================================================
   SDK Checkbox Widget - Embed Window
   ============================================================ */
#aliyunCaptcha-window-embed {
    display: block !important;
    visibility: visible !important;
}

#aliyunCaptcha-checkbox-wrapper {
    display: block !important;
    visibility: visible !important;
}

#aliyunCaptcha-checkbox-body {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    padding: 10px 15px !important;
    min-height: 44px !important;
    cursor: pointer !important;
    visibility: visible !important;
}

#aliyunCaptcha-checkbox-left {
    display: flex !important;
    align-items: center !important;
    flex: 1 !important;
    visibility: visible !important;
}

/* ============================================================
   Checkbox Icon - The actual checkbox square
   ============================================================ */
#aliyunCaptcha-checkbox-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    border: 2px solid #d0d3d8 !important;
    border-radius: 4px !important;
    background: #fff !important;
    margin-right: 10px !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    visibility: visible !important;
    position: relative !important;
    transition: background 0.2s ease, border-color 0.2s ease !important;
    box-sizing: border-box !important;
}

/*
 * Override SDK's auto-checked visual state.
 * The SDK adds 'aliyunCaptcha-checkbox-checked' on load (before real verification),
 * making the checkbox look checked prematurely. We force it to always look unchecked,
 * and only show the checked state via our custom class 'alibaba-captcha-verified'
 * which is added by JS after real server verification succeeds.
 */

/* Always hide the SDK's internal checkmark div */
.aliyunCaptcha-checkbox-icon-checked {
    display: none !important;
}

/* Force checkbox to always look unchecked (override SDK's checked state) */
.aliyunCaptcha-checkbox-checked #aliyunCaptcha-checkbox-icon {
    background: #fff !important;
    border-color: #d0d3d8 !important;
}

/* ============================================================
   Verified State - Only shown after real server verification
   (class 'alibaba-captcha-verified' is added by our JS)
   ============================================================ */
.alibaba-captcha-verified #aliyunCaptcha-checkbox-icon {
    background: #52c41a !important;
    border-color: #52c41a !important;
}

.alibaba-captcha-verified .aliyunCaptcha-checkbox-icon-checked {
    display: block !important;
    width: 6px !important;
    height: 11px !important;
    border: solid #fff !important;
    border-width: 0 2px 2px 0 !important;
    transform: rotate(45deg) !important;
    margin-top: -2px !important;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
#aliyunCaptcha-loading {
    margin-right: 10px;
}

.aliyunCaptcha-loader {
    width: 20px !important;
    height: 20px !important;
    border: 2px solid #e0e0e0 !important;
    border-top: 2px solid #1890ff !important;
    border-radius: 50% !important;
    animation: aliyunCaptchaSpin 0.8s linear infinite !important;
}

@keyframes aliyunCaptchaSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================
   Checkbox Text
   ============================================================ */
#aliyunCaptcha-checkbox-text {
    font-size: 14px !important;
    color: #333 !important;
    user-select: none !important;
    visibility: visible !important;
}

/* ============================================================
   Alibaba Logo
   ============================================================ */
#aliyunCaptcha-checkbox-logo {
    height: 36px !important;
    width: auto !important;
    flex-shrink: 0 !important;
    visibility: visible !important;
}

/* ============================================================
   Error Code Area
   ============================================================ */
#aliyunCaptcha-checkbox-errorCode {
    color: #ff4d4f !important;
    font-size: 12px !important;
    margin-top: 5px !important;
}

/* ============================================================
   Form-specific spacing
   ============================================================ */
.form-login .alibaba-captcha-container {
    margin-top: 20px;
}

.form-create-account .alibaba-captcha-container {
    margin: 20px 0;
}

#contact-form .alibaba-captcha-container {
    margin: 20px 0;
}

.form-password-forget .alibaba-captcha-container,
.password.forget .alibaba-captcha-container {
    margin: 20px 0;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .alibaba-captcha-container {
        margin: 10px 0;
    }
}
